[Zope] guarded_getitem and zsql method results

Chris McDonough chrism@zope.com
Wed, 05 Sep 2001 09:21:11 -0400


It appears that you're trying to split a DateTime object instead of a
string.

Shriek@gmx.co.uk wrote:
> 
> It's been about 18 months since I last looked at Zope and a lot seems
> to have changed, especially in terms of security (eg. the administrator
> no longer being able to create objects etc).  Most changes I've got to
> grips with but this one I can't figure out -
> 
> I loop over the results from a ZSQL method which returns a variable
> mydate that I wanted to split into year, month, day values.
> 
> <dtml-in ZSQL_SelectDates>
>     <dtml-call "REQUEST.set('myyear', _.string.split('mydate', '-')[0])">
>     ... other code
> </dtml-in>
> 
> This causes an error -
> 
>   File <string>, line 2, in f
>     (Object: guarded_getitem)
>   File C:\PROGRA~1\ZOPE-L~1\bin\lib\string.py, line 114, in split
>   File C:\PROGRA~1\ZOPE-L~1\lib\python\DateTime\DateTime.py, line 1106, in
> __getattr__
> AttributeError: split
> 
> OK, I know there are multiple ways for me to get around this -
> a) use a slice such as  mydate[0:4] should work.
> b) force the variable 'mydate' into the REQUEST first.
>    eg. <dtml-call "REQUEST.set('mydate', mydate)">
>        <dtml-call "REQUEST.set('myyear', _.string.split('mydate','-')[0])">
>   etc
> 
> But what I really want to know is why can't I use string.split() on the
> variables returned from a ZSQL method ?
> 
> Thank you.
> 
> Stephen.
> 
> ps. All this Guarded stuff looks new. What's its purpose ?
> 
> --
> Sent through GMX FreeMail - http://www.gmx.net
> 
> _______________________________________________
> 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 )

-- 
Chris McDonough                           Zope Corporation
http://www.zope.org                    http://www.zope.com

""" Killing hundreds of birds with thousands of stones """