[silva-dev] Accessing model or node via REQUEST

Clemens Robbenhaar robbenhaar at espresto.com
Thu Sep 25 14:51:42 CEST 2003


Hi Benno,


 > I'm working on the widgets part of a new SilvaExtension. Now I encountered
 > the problem that sometimes I can access the model (via
 > context.REQUEST.model), sometimes the node (context.REQUEST.node). In a
 > particular case I find the node in the REQUEST, but I need the model.
 > Therefore, my questions:
 > - Wich mechanism sets the model and/or the node to the REQUEST?

 Setting the "model" is done as a side effect of travering the "edit"
(or "public") Attribute of the content object.

 Setting the "node" is done as a side effect of 
calling "service_editor.getWider(node)"

 > - How can I ensure that I find the model in the REQUEST?

 The problem is that some edit operations of a model actually operate on
the xml nodes, and are reached via traversing to the xml node via the
"nodePath", i.e. somewhat like: 
  "/silva/content/0/widget,e0,e2,e16/insert" 
 triggers the "insert.py" in the widget for some node defiened by the 
path "e0,e2,e19" (having no human readable sematics af far as I know)

 In this case Zope dies _not_ traverse the "content/edit", anf thus does
not set the REQUEST.model

 The recommended way to accedd the model inside a widget is 

 container.REQUEST.node.get_content()

instead. This gets the model via acquisition and could be always the
right thing (except if You have XML inside a non-content SilvaObject,
i.e. soemthing not deriving from Content).

Hope this helps,
Clemens
 > 
 > PS: I'm working still with Silva 0.9.1.x.
 >

PS: I too, still did not have the time to upgrade the pluggable widgets :(



More information about the silva-dev mailing list