[Twisted-Python] twisted newbie question about woven and model

Donovan Preston dp at twistedmatrix.com
Wed Jun 4 01:33:20 MDT 2003


On Wednesday, June 4, 2003, at 12:25 AM, Philippe Lafoucrière wrote:

> hi all
>
> I'am trying to display some information via a .rpy script. My model is 
> a
> complex object with several properties such as :
>
> object.title
> object.name
> object.creationDate
> ...
>
> The only way I found to display title & name is
>
> <span model="object" view="None">
> 	<span model="title" view="Text" />
> 	...
> </span>
>
> Is it possible to access directly object.title ?
> model="object.title" doesn't work of course.

Certainly. Woven uses / rather than . as the submodel name separator. 
So simply do this:

<span model="object/title" view="Text" />

/ is used rather than . because / can indicate any method of accessing 
a conceptual child object, whether it occurs by attribute access, 
dictionary or list lookup, or method call; it's up to the IModel 
adapter to decide how to access children. I believe this is covered in 
the "Model in Depth" section of the documentation.

Hope that helps!

Donovan





More information about the Twisted-Python mailing list