[Zope] guarded_getitem and zsql method results
Shriek@gmx.co.uk
Shriek@gmx.co.uk
Wed, 5 Sep 2001 07:51:49 +0200 (MEST)
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