[Zope] CoreSessionTracking - looping over items

Chris McDonough chrism@digicool.com
Mon, 23 Jul 2001 17:22:15 -0400


Hi Pawel,

PythonScripts, like DTML, can't access attributes of objects which start
with an underscore.  Please read this HowTo in order to understand how to
use external methods:
http://www.zope.org/Documentation/How-To/ExternalMethods .

As far as returning the whole _sdc object for use in DTML, do this:

def getInternalSessionDataContainer(session_data_manager):
    return session_data_manager._sdc

<dtml-with "getInternalSessionDataContainer(session_data_manager)">
   ...
</dtml-with>

... where session_data_manager is the session data manager you're using.

HTH,

- C


----- Original Message -----
From: "Pawel Lewicki" <lewicki@provider.pl>
To: <zope@zope.org>; "Chris McDonough" <chrism@digicool.com>
Sent: Monday, July 23, 2001 4:42 PM
Subject: Re: [Zope] CoreSessionTracking - looping over items


>
> ----- Original Message -----
> From: "Chris McDonough" <chrism@digicool.com>
> To: "Pawel Lewicki" <lewicki@provider.pl>
> Cc: <zope@zope.org>
> Sent: Monday, July 23, 2001 7:14 PM
> Subject: Re: [Zope] CoreSessionTracking - looping over items
>
>
> > Please try to keep correspondence on the list.
> >
> > THis can't be done from DTML if you're using an internal session data
> > container because DTML can't access attributes with a leading
underscore.
> > Either use an external session data container or use an external method.
> > For instance, here's an external method that returns the number of
session
> > data objects in the internal session data container, along with some
DTML
> > that calls it.
> >
> > def numberOfDataObjects(session_data_manager):
> >     return len(session_data_manager._sdc)
> >
> > <dtml-var "numberOfDataObjects(session_data_manager)">
>
> I tried with python script but at zope says "Names starting with "_" are
not
> allowed ", so I suppose it should be method defined in the external file.
Is
> it enough to put .py file in Extensions directory with this piece of code?
> I've never tried external methods. The idea comes from ZopeBook and
> description of defining Brains to Z SQL Methods. It is the only reference
I
> have on mind at the moment.
> As it doesn't work it should be something different. What should I do to
> make numberOfDataObjects visible to dtml document? And with the same
> solution is it possible to return the whole _sdc attribute as sliceable
> object to iterate with <dtml-in>?
>
> Pawel Lewicki
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>