[Zope] Interbase and Date datatype

Brad Clements bkc@murkworks.com
Mon, 16 Jul 2001 09:09:31 -0400


On 16 Jul 2001, at 15:11, Michael Schulz wrote:

> sorry to bother you again. I tried the solution you suggested, but when
> trying to access the document an authentication window appears (i am logged
> in as manager) ?!? The error message shows:
> 
> line 168, in validate Unauthorized: tuple ---
> 
> Hmm, why i am not authorized to access the method tuple()? Any hints?

Yes, this happens because tuple doesn't have a doc string. or maybe because Date 
class doesn't have proper Zope security handling, or even the     
__allow_access_to_unprotected_subobjects__=1 hack.


Simple solution is to create an Extension method that does the cast for you.


mycast.py

from DateTime import DateTime


def DateTimeCast(s):
    """convert an interbase Timestamp to datetime"""
    if not s: return s
    try:
        return apply(DateTime,s.tuple())
    except AttributeError:
        return DateTime(s)


(okay, this does a little more than you need, but you get the idea)


> 
> Perhaps someone coulod tell what kind of object i am dealing with, after
> retrieving data from a DATE column of an interbase db? the returned object
> is not a string, nor i am able to convert it into one.

Yes, you can call str() on the object. Did you try it?

Anyway, it's defined in gvib.py

> 
> 


Brad Clements,                bkc@murkworks.com   (315)268-1000
http://www.murkworks.com                          (315)268-9812 Fax
netmeeting: ils://ils.murkworks.com               AOL-IM: BKClements