LinguaPlone's API

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

LinguaPlone's API

Raphael Ritz
Hi,

not sure whether this is the right list, but anyway:

In preparing a multilingual version of my PloneBook product
(now that we have it in German as well), I'm facing the following
situation (Python-2.3.5, Zope-2.8.2, Plone-2.1.1, LP-0.8.5):

Generating translations "manually", i.e, TTW/TTP works fine :-)

Generation translations from code gives me trouble. :-(

1. After the upload, the entire site appears to be empty
    and dysfunctional!
2. The folder containing the translated docs isn't
    even accessible in ZMI (it shows the empty frontpage
    of the site instead)
3. I get the following traceback in such cases
Traceback (innermost last):
   Module ZPublisher.Publish, line 113, in publish
   Module ZPublisher.mapply, line 88, in mapply
   Module ZPublisher.Publish, line 40, in call_object
   Module Shared.DC.Scripts.Bindings, line 311, in __call__
   Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
   Module App.special_dtml, line 175, in _exec
   Module DocumentTemplate.DT_Let, line 76, in render
   Module DocumentTemplate.DT_In, line 703, in renderwob
TypeError: id() takes exactly one argument (0 given)

4. Digging deeper, it looks like the portlets are at least
    involved in the trouble (do I need PlonePortlets still?)

Maybe I'm just using the wrong API?

Here is how I tried to add a translation from code ('Chapter' is
a custom LP aware content type; getChapter_ids() returns the
ids of the canonical - English - version: _getChapterBody
just gets the body in the right language):

     security.declareProtected(CMFCorePermissions.ModifyPortalContent,
                               'updateTranslations')
     def updateTranslations(self, path, languages=('de',)):
         for language in languages:
             self._updateTranslation(path, language)

     def _updateTranslation(self, path, language):
         for id in self.getChapter_ids():
             chapter = getattr(self,id)
             if not chapter.hasTranslation(language):
                 chapter.addTranslation(language)
             translation = chapter.getTranslation(language)
             self._setChapterProperties(translation, language)
             body = self._getChapterBody(path, language, id)
             self._setChapterBody(translation, language, body)

     def _setChapterProperties(self, chapter, language='en'):
         chapter.setTitle(CHAPTER_TITLES[language].get(id,id))
         chapter.setDescription(CHAPTER_DESCRIPTIONS[language].get(id,' '))
         chapter.setLanguage(language)
         for prop in ('left_slots', 'right_slots'):
             if prop not in chapter.propertyIds():
                 chapter.manage_addProperty(prop,
                                            (),
                                            'lines',
                                            )

     def _setChapterBody(self, chapter, language, body):
         chapter.setText(body,encoding='utf-8')
         chapter.setContentType('text/restructured')
         chapter.reindexObject()

Anyone seeing what I'm doing wrong here?

Any examples out there on how to add content programmatically
to a Plone/LinguaPlone site?

Thanks for any pointers.

Raphael



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Reply | Threaded
Open this post in threaded view
|

Re: LinguaPlone's API

Alexander Limi
Administrator
On Wed, 19 Oct 2005 08:23:07 -0700, Raphael Ritz  
<[hidden email]> wrote:

> (do I need PlonePortlets still?)

No. :)

(I can't answer the rest of your post, unfortunately :)

--
_____________________________________________________________________

      Alexander Limi · Chief Architect · Plone Solutions · Norway

  Consulting · Training · Development · http://www.plonesolutions.com
_____________________________________________________________________

       Plone Co-Founder · http://plone.org · Connecting Content
   Plone Foundation · http://plone.org/foundation · Protecting Plone



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Alexander Limi · http://limi.net

Reply | Threaded
Open this post in threaded view
|

Re: LinguaPlone's API

Dorneles Treméa (PSOL)
In reply to this post by Raphael Ritz
Hey Raphael,

> not sure whether this is the right list, but anyway:
>
> In preparing a multilingual version of my PloneBook product
> (now that we have it in German as well), I'm facing the following
> situation (Python-2.3.5, Zope-2.8.2, Plone-2.1.1, LP-0.8.5):
>
> Generating translations "manually", i.e, TTW/TTP works fine :-)

this means that our tests are good enough... :-)

> Generation translations from code gives me trouble. :-(

Lets see...

> 1. After the upload, the entire site appears to be empty
>     and dysfunctional!
> 2. The folder containing the translated docs isn't
>     even accessible in ZMI (it shows the empty frontpage
>     of the site instead)
> 3. I get the following traceback in such cases
> Traceback (innermost last):
>    Module ZPublisher.Publish, line 113, in publish
>    Module ZPublisher.mapply, line 88, in mapply
>    Module ZPublisher.Publish, line 40, in call_object
>    Module Shared.DC.Scripts.Bindings, line 311, in __call__
>    Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
>    Module App.special_dtml, line 175, in _exec
>    Module DocumentTemplate.DT_Let, line 76, in render
>    Module DocumentTemplate.DT_In, line 703, in renderwob
> TypeError: id() takes exactly one argument (0 given)

Ouch!

> 4. Digging deeper, it looks like the portlets are at least
>     involved in the trouble (do I need PlonePortlets still?)

As Alex said, not realy.

> Maybe I'm just using the wrong API?

Probably... :-)

> Here is how I tried to add a translation from code ('Chapter' is
> a custom LP aware content type; getChapter_ids() returns the
> ids of the canonical - English - version: _getChapterBody
> just gets the body in the right language):
>
> [...]
>
>      def _setChapterProperties(self, chapter, language='en'):
>          chapter.setTitle(CHAPTER_TITLES[language].get(id,id))
>          chapter.setDescription(CHAPTER_DESCRIPTIONS[language].get(id,' '))
>          chapter.setLanguage(language)
>          for prop in ('left_slots', 'right_slots'):
>              if prop not in chapter.propertyIds():
>                  chapter.manage_addProperty(prop,
>                                             (),
>                                             'lines',
>                                             )
> [...]
>
> Anyone seeing what I'm doing wrong here?

I can bet that what's going wrong is the (unnecessary? as the
translation is already created witha language set?) setLanguage
call.

setLanguage will move the object to the appropriate folder and
this can cause you some problems.

> Any examples out there on how to add content programmatically
> to a Plone/LinguaPlone site?

What about the LP tests? :-)

> Thanks for any pointers.

HTH,

--
_____________________________________________________________________

       Dorneles Treméa · Developer · Plone Solutions · Brazil

 Consulting · Training · Development · http://www.plonesolutions.com
_____________________________________________________________________

  Plone Foundation · http://plone.org/foundation · Protecting Plone



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n
Reply | Threaded
Open this post in threaded view
|

Re: LinguaPlone's API

Raphael Ritz
Dorneles Treméa wrote:
> Hey Raphael,
>

Hi Dorneles,

thanks for your help!

Of course I caused the problem myself and for everyones
pleasure I even tell you now how ;-)

[..]

>>3. I get the following traceback in such cases
>>Traceback (innermost last):
>>   Module ZPublisher.Publish, line 113, in publish
>>   Module ZPublisher.mapply, line 88, in mapply
>>   Module ZPublisher.Publish, line 40, in call_object
>>   Module Shared.DC.Scripts.Bindings, line 311, in __call__
>>   Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
>>   Module App.special_dtml, line 175, in _exec
>>   Module DocumentTemplate.DT_Let, line 76, in render
>>   Module DocumentTemplate.DT_In, line 703, in renderwob
>>TypeError: id() takes exactly one argument (0 given)
>
>
> Ouch!

[..]

>>
>>     def _setChapterProperties(self, chapter, language='en'):

Note how the following call is using the 'id' as key for
the lookup but the 'id' isn't passed along to the method call
(because I forgot to include it there)

>>         chapter.setTitle(CHAPTER_TITLES[language].get(id,id))

This then results in 'chapter.title' being the 'id' method
which get's invoked when calling Title().
Don't ask me why this didn't fail to begin with but then
of course this screwed everything up. Passing the id along
to the call fixed everything.

>>         chapter.setDescription(CHAPTER_DESCRIPTIONS[language].get(id,' '))
>>         chapter.setLanguage(language)
[..]
> I can bet that what's going wrong is the (unnecessary? as the
> translation is already created witha language set?) setLanguage
> call.
>
> setLanguage will move the object to the appropriate folder and
> this can cause you some problems.

Not sure here. If I skip the language setting (for english at least)
I cannot switch back from German to English in the browser (get a
'translation not found' instead).

If I do set it, all seems to be fine :-)

>
>
>>Any examples out there on how to add content programmatically
>>to a Plone/LinguaPlone site?
>
>
> What about the LP tests? :-)

That's where I actually got this from ;-)

Raphael




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Plone-i18n mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-i18n