[Zope] Modifying a zclass property

Andreas Jung Andreas Jung <andreas@andreas-jung.com>
Mon, 23 Jun 2003 13:20:23 +0200


I don't know the implementations details of the "context" object but
I consider "context" as read-only. What you want (I think) is to modify
the REQUEST by

context.REQUEST.set(key, value).

-aj

--On Montag, 23. Juni 2003 13:16 Uhr +0200 Fernando Martins 
<fmartins@hetnet.nl> wrote:

> Hello,
>
> I was going through the zope book's chapter "Extending Zope" and I
> implemented a method called feed (the animal in a ZooExhibit). This method
> is not in the book, and I coded it as:
>
> from DateTime import DateTime
> context.propertysheets.ExhibitProperties.manage_changeProperties(last_mea
> l_t ime = DateTime())
> return context.index_html()
>
> This works, but my first (unsuccessfull) try was:
>
> from DateTime import DateTime
> context.last_meal_time = DateTime()
> return context.index_html()
>
> This gives an error:
>
> Error Type: TypeError
> Error Value: attribute-less object (assign or del)
>
> Why is last_meal_time not an attribute of the instance? In another method,
> isHungry, from the book, I can retrieve its value:
>
> if (DateTime().timeTime() - context.last_meal_time.timeTime() >  60 * 60 *
> 8):
>
> What's going on?
>
> Also, is there any difference between using container and context for an
> instance of a ZClass?
>
> Thanks,
> Fernando
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )