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.

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

How to enable internationalization

Adding Language to your Site.



First, have you created the site yet?

If you have do it: Go to Localizer at ZMI ( in your site) and select Languages tab. Select the language you want to add to the portal and click add button.

If not: Select the languages you must to have enabled in your site at the add site form.

Translating labels.



When you have enabled a language, you can translate the defined labels of your site. You can see these labels if you go to Localizer->Contents, and select a Message Catalog (typically default). here, you can easily find and change the values of any label.

But, what happen if I want to save these translations in my project? what happen if i want to define my own labels? The best way to do that is:

1. You must to have a i18n folder in your project. Remember How to Implement a Product or How to implement a new product with Eclipse and Subversion.

2. Create at least one *.po file to each of the languages. I.e: es.po to espanish language, en.po to english language...

3. It's so easy to declare labels and translate it:

en.po

msgid "my_own_label"
msgstr "My Own Label"

es.po

msgid "my_own_label"
msgstr "Mi Propia Etiqueta"


4. To import your internationalization files, go to Localizer in ZMI and select a Messages Catalog (typically default). On Import/Export Tab, browse to your *.po file and import it by selecting the correct language.

5. Well, now you can use your labels anywhere on your code. How can i do it??
Usually in zope page template, we use the next syntax:


<span i18n:translate="my_own_label">MY OWN LABEL</span>


Some advices:

If you put an i18n tag in a page template but you haven't declared the label on Localizer, then the server shows the html content, I mean, MY OWN LABEL in our example.
The right way is to write a descriptive content on this.

When you're going to write page templates, put all your labels on *.po files, to fill it later, if you prefer.

Monday, June 18, 2007

How to add new transforms

CPS is configured out-of-the-box to index some types of documents. The indexation relies on a type of object called Transforms contained in the tool portal_transforms. This products allows to index the content of pdf, doc, ppt, and other files format. The steps below show how to add some new transforms:

  1. Install dependencies as debian packages:

    apt-get install lynx pdftohtml python-docutils xpdf ppthtml wv


  2. Go to the tool portal_transforms from ZMI.

  3. Add new objects objects of type Transform and fill the form with the values in the table below.










    Identifier Module
    ppt_to_html Products.PortalTransforms.transforms.ppt_to_html
    pdf_to_html Products.PortalTransforms.transforms.pdf_to_html
    pdf_to_text Products.PortalTransforms.transforms.pdf_to_text

  4. Upload a ppt or pdf file and search for some word of the content in the search form.

Was your uploaded file listed in the search results? Work finished!