[Zope3-dev] Job Board Example

Barry A. Warsaw barry@zope.com
Mon, 17 Jun 2002 22:31:48 -0400


>>>>> "GvR" == Guido van Rossum <guido@python.org> writes:

    GvR> Cool!!!

Indeed!  I love internationalization even more as a monolingual
American. :)

    GvR> You don't need the file='configure.zcml' part since that's
    GvR> the default value. :-)

Ah, cut-n-paste from products.zcml.in, but we probably don't need that
attribute in that file either (besides, the value is incorrect now;
I'll remove it).

    GvR> It seems that JobBoardEx and JobBoardI18n define some
    GvR> conflicting resources that make it impossible to have both
    GvR> configured.

I see the same error.
    
    GvR> I would like to see that fixed.

Yep.  Shouldn't it be possible to create two different implementations
of IJobList, especially as you say, the full package names are different.
    
    GvR> This seems strange since the full package names are
    GvR> different.  Could this be a Zope3 bug?  The only conflict
    GvR> seems to be the zmi:factory directive; once I have created an
    GvR> i18n job board, I can have both existing in parallel.

Really?  How?  I can't enable both include directives without getting
the error, but you need the include directive or you get a traceback
like this when clicking on the un-included job board:

-------------------- snip snip --------------------
NotFoundError

Traceback (innermost last):

    * Module Zope.Publisher.Publish, line 36, in publish
    * Module Zope.Publisher.Browser.BrowserRequest, line 457, in traverse
    * Module Zope.App.ZopePublication.Browser.Publication, line 38, in getDefaultTraversal
    * Module Zope.App.ZopePublication.Traversers, line 32, in browserDefault
    * Module Zope.ComponentArchitecture, line 111, in getDefaultViewName
    * Module Zope.ComponentArchitecture.GlobalViewService, line 146, in getDefaultViewName

NotFoundError: No default view name found for object <security proxied
ZopeProducts.JobBoardEx.JobList.JobList instance at 0x8619e04>
-------------------- snip snip --------------------

Ah, ok, comment out one of the zmi:factory directives and they'll both
work.

    GvR> (1) I'd like to have an explicit control over the language
    GvR> (in addition to the browser preference).  I'd think this
    GvR> would be handy for demos.

I agree (that's something Mailman has via a language selection
widget).  I'll see about adding that to the JobBoardI18n.

    GvR> (2) How do I start a new translation?  Do I just clone the
    GvR> locale/en directory and start hacking on the files, or is
    GvR> there more to it?

For now, the best steps are

- clone locale/en/LC_MESSAGES/jobboard.po to
  locale/xx/LC_MESSAGES/jobboard.po where `xx' is your new language
  code.

- Edit your new jobboard.po to change the msgstr entries to the
  translation in your language (po-mode in Emacs is really handy here;
  let me know if you need a copy -- I don't think it comes with XEmacs
  by default).

- Use msgfmt to generate the jobboard.mo file from the newly
  translated jobboard.po file.

- Restart Zope.

    GvR> (3) I think I've hit a bug in the i18n code.  In the i18n
    GvR> version, try to submit a job.  When I click on the preview
    GvR> button, I get a traceback saying "TypeError: coercing to
    GvR> Unicode: need string or buffer, NoneType found", at line 104
    GvR> in SimpleTranslationService (in interpolate).

I get a different error using the English translation.  I get through
Preview but when I hit Submit I get:

-------------------- snip snip --------------------
AttributeError

Traceback (innermost last):

    * Module Zope.Publisher.Publish, line 39, in publish
    * Module Zope.App.ZopePublication.ZopePublication, line 117, in callObject
    * Module Zope.Publisher.mapply, line 106, in mapply
      __traceback_info__: <security proxied __builtin__.instance method instance at 0x861efec>
    * Module ZopeProducts.JobBoardI18n.JobCreateView, line 18, in create
    * Module Zope.PageTemplate.PageTemplate, line 95, in __call__
    * Module Zope.PageTemplate.PageTemplate, line 113, in pt_render
      Warning: Macro expansion failed
      Warning: exceptions.AttributeError: 'Context' object has no attribute 'translate'
    * Module Zope.TAL.TALInterpreter, line 164, in __call__
    * Module Zope.TAL.TALInterpreter, line 203, in interpret
    * Module Zope.TAL.TALInterpreter, line 529, in do_insertTranslation
    * Module Zope.TAL.TALInterpreter, line 609, in translate

AttributeError: 'Context' object has no attribute 'translate'
-------------------- snip snip --------------------

Clearly some opportunities for debugging.  I'll work on those tomorrow
if Stephan doesn't use his timezone advantage to beat me to it. :)

-Barry