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

No comments: