[Zope] guarded_getitem and zsql method results

Shriek@gmx.co.uk Shriek@gmx.co.uk
Wed, 5 Sep 2001 14:00:49 +0200 (MEST)


<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

Sorry, self-correction. The above doesn't work either. 
Is there any reason why variables returned from a <dtml-in ZSQL_mymethod>
can not be sliced or string split ?  This seems very strange. 

Thanks.

Stephen.

-- 
Sent through GMX FreeMail - http://www.gmx.net