[ZPT] Re: Zope Persistent Objects
Casey Duncan
casey at zope.com
Tue Mar 23 13:26:57 EST 2004
On Tue, 23 Mar 2004 12:14:16 -0600
"Nguyen, Joe" <Joe.Nguyen at coair.com> wrote:
> Hi,
>
>
>
> Simple question; if I passed in a dictionary from an external method.
> How would I keep that dictionary persistent so that I can refer to it
> anytime? For instance,
What do you mean by anytime?
This request?
In this case use:
REQUEST.set('dictObj', dictObj)
to store and
dictObj = REQUEST['dictObj']
to retreive.
For this user's session?
In that case use:
REQUEST.SESSION['dictObj'] = dictObj
to store and
dictObj = REQUEST.SESSION['dictObj']
to retreive.
Forever (including after Zope restarts) is a bit more involved, but in
the external method you could set it as as attribute of some object
(like the cmf portal or folder object), but that is a hack. It's easy
though in the ext. method:
portal = self.portal_url.getPortalObject()
portal.dictObj = dictObj
to retrieve (from a python script) use:
dictObj = context.dictObj
If you want to do this the "right way" you should store the dict values
as properties or store the whole dict in a custom Zope object.
hth,
-Casey
>
>
>
> In a python script, I would have something similar to dictObject =
> passInDictionaryObject.
>
> How do I make this so I can retrieve "dictObject" anytime I want to?
> Do I use ZODB? I've read over it a little but im nto sure if that's
> the right way to go. Can I just do a test =
> context.REQUEST.get('dictObject') without passing variables? Please
> help.
>
>
>
> Joe
>
>
>
>
>
>
More information about the ZPT
mailing list