Did not find a how-to for your problem?

Ask me to write the how-to post by writing to the mailing-list at cps-devel [@] lists [.] nuxeo [.] com or writing to me to joseluisdelarosa+cpshowto [@] gmail [.] com. Note: I'll keep all conversations on the official mailing list.
Showing posts with label proxies. Show all posts
Showing posts with label proxies. Show all posts

Tuesday, June 19, 2007

How to get a proxy from a widget.

The howto for today is about a question sent by Miguel Sánchez to the mailing list cps-devel [@] lists [.] nuxeo [.] org and answered by M.A. Darche.

The problem is how to get the contextual document or object from inside the code of a widget.

The answer is to get the datamodel and retrieve the object from it, i.e., test the snippet below in any of the methods of the widget (render, validate, prepare, etc.)



dm = datastructure.getDataModel()
ob = dm.getProxy()
print ob
ob = dm.getObject()
print ob
ob = dm.getContext()
print ob




You can find the original answer in this url http://permalink.gmane.org/gmane.comp.web.zope.cps.devel/3381

Wednesday, June 6, 2007

How to enable translations

CPS has a powerful engine of proxies to revisions and translations management but the link to translate documents is not enable by default.
  1. Go to portal_workflow

  2. In all the workflows with identifiers workspace_content_wf, workspace_folder_wf, section_content_wf and section_folder_wf.

  3. Create a new transition with id translate or if it's already created complete these properties:

    Transition type: Initiated by user action
    Script (before): add_language_to_proxy
    Permissions: Modify portal content
    Name (formatted): action_translate
    URL (formatted): %(content_url)s/content_translate_form
    Category: workflow
    All fields left, empty or unchecked.

  4. Create a new transition with id delete_translation or if it's already created complete this properties:

    Transition type: Initiated by user action
    Script (before): delete_language_from_proxy
    Expression: python:not state_change.object.isDefaultLanguage()
    Name (formatted): action_delete_translation
    URL (formatted): %(content_url)s/content_delete_translation
    Category: workflow
    All fields left, empty or unchecked.

  5. Now, go to the portal, say to the folder workspaces or a new document you had created and check that there's a new link called New translation.

  6. Click the action New translation and a form to select the destination language will be shown. Notice that the current language of the document is not shown in the combo box.

  7. Finally, click the button Create a revision for translation.

  8. The revision you are watching is in the language shown. Click the Ed it link and translate the texts of the document to the language.

  9. To switch to one revision or the other, just click the flags shown on the right of the breadcrumbs and the document should change its language as you change the language of the site.
Yes, CPS is good for multilanguage too XD.

See you soon, Hasta la vista, Arrivederci, Au revoir, Auf wiedersehen, Até logo, Sayonara baby...