[Twisted-Python] twisted newbie question about woven and model
Donovan Preston
dp at twistedmatrix.com
Thu Jun 5 11:16:48 MDT 2003
On Thursday, June 5, 2003, at 12:12 AM, Philippe Lafoucrière wrote:
> On Wed, 2003-06-04 at 09:43, Philippe Lafoucrière wrote:
>> Hum
>> I get an exception when I use object/title
>>
>> exceptions.Exception: Node had a model=object/title attribute, but the
>> submodel was not found in [<twisted.web.woven.model.Wrapper instance
>> at
>> 0x843be3c: wrapped data: <ObjectManager instance at 0x8a24b5c>>].
>>
>> (with model = object)
>
>
> Someone can help me ?? this still doesn't work !
Woven needs to know how to request Submodels of a Model object in order
to work. It does this using objects which conform to the IModel
protocol. Since no IModel adapter has been registered for your
ObjectManager class, Woven wraps it in a generic Wrapper. The generic
Wrapper does not allow submodel access at all, which is why you are
getting the exception.
There are two solutions to your problem: The first is to make
ObjectManager a subclass of model.AttributeModel. AttributeModel is an
implementation of IModel which exposes attributes of an object as
submodels. This is probably the easiest because all the code is already
written for you.
The second solution is to write an IModel adapter which exposes
attributes of the adapted object as submodels. I have never done this
before, but it seems like a logical thing to do.
Attached are two pieces of code that show each technique.
Hope this helps! dp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attributeModelSubclass.rpy
Type: application/octet-stream
Size: 351 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20030605/7ed52ecc/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attributeAdapter.rpy
Type: application/octet-stream
Size: 733 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20030605/7ed52ecc/attachment-0005.obj>
More information about the Twisted-Python
mailing list