Dear List, i am using zope2.3.1, python 1.5.2 and interbase adapter gvibda096. I am accessing an interbase DATE type column via a zsql-method and want to reformat the returned date (yyyy/mm/dd), but i can't figure out how? I tried without success: 1.) <dtml-var "_.DateTime(_['gueltig_von'])"></td> Error: AttributeError 2.) <dtml-var "gueltig_von.strftime('%d.%m.%Y')"> Error: File /usr/local/Zope-2.3.1-src/lib/python/DocumentTemplate/DT_Util.py, line 334, in eval (Object: gueltig_von.strftime('%d.%m.%Y')) (Info: gueltig_von) File <string>, line 0, in ? File /usr/local/Zope-2.3.1-src/lib/python/DocumentTemplate/DT_Util.py, line 127, in careful_getattr AttributeError: (see above) 3.) With this script: |#create_date(datum_string) | from string import split, join | list_date = split(datum_string,"/") | return list_date[2]+"."+list_date[1]+"."+list_date[0] <dtml-var "create_date(datum=_['gueltig_von'])"> Error Type: TypeError Error Value: argument 1: expected read-only character buffer, instance found File /usr/local/Zope-2.3.1-src/lib/python/Products/PythonScripts/PythonScript.py, line 336, in _exec (Object: create_date) (Info: ({'script': <PythonScript instance at 8cdc120>, 'context': <r instance at 8add6e8>, 'container': <Folder instance at 8cdbb98>, 'traverse_subpath': []}, (), {'datum': <Products.gvibDA.gvib.gvib.Date instance at 8cff7b8>}, None)) File Script (Python), line 5, in create_date TypeError: (see above) Could anybody think of another method to reformat the column values or has this problem to do with gvibda? TIA, Michael -- ------------------------------------------------------------- Michael Schulz in medias res GmbH, D-79100 Freiburg
On 13 Jul 2001, at 12:33, Michael Schulz wrote:
i am using zope2.3.1, python 1.5.2 and interbase adapter gvibda096.
I am accessing an interbase DATE type column via a zsql-method and want to reformat the returned date (yyyy/mm/dd), but i can't figure out how? I tried without success:
1.) <dtml-var "_.DateTime(_['gueltig_von'])"></td> Error: AttributeError
<dtml-var "_.DateTime(_['gueltig_von'].tuple())" fmt="%Y/%m/%d" The .tuple() method of a Date or DateTime object returns a tuple.
Dear List, Hi Brad, 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: --- File /usr/local/Zope-2.3.1-src/lib/python/DocumentTemplate/DT_Var.py, line 278, in render (Object: _.DateTime(_['GUELTIG_VON'].tuple())) File /usr/local/Zope-2.3.1-src/lib/python/DocumentTemplate/DT_Util.py, line 334, in eval (Object: _.DateTime(_['GUELTIG_VON'].tuple())) (Info: _) File <string>, line 0, in ? File /usr/local/Zope-2.3.1-src/lib/python/DocumentTemplate/DT_Util.py, line 140, in careful_getattr File /usr/local/Zope-2.3.1-src/lib/python/OFS/DTMLMethod.py, line 261, in validate (Object: stellengesuche_output) File /usr/local/Zope-2.3.1-src/lib/python/AccessControl/SecurityManager.py, line 144, in validate File /usr/local/Zope-2.3.1-src/lib/python/AccessControl/ZopeSecurityPolicy.py, line 168, in validate Unauthorized: tuple --- Hmm, why i am not authorized to access the method tuple()? Any hints? 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. Thanks, Michael Brad Clements wrote:
On 13 Jul 2001, at 12:33, Michael Schulz wrote:
i am using zope2.3.1, python 1.5.2 and interbase adapter gvibda096.
I am accessing an interbase DATE type column via a zsql-method and want to reformat the returned date (yyyy/mm/dd), but i can't figure out how? I tried without success:
1.) <dtml-var "_.DateTime(_['gueltig_von'])"></td> Error: AttributeError
<dtml-var "_.DateTime(_['gueltig_von'].tuple())" fmt="%Y/%m/%d"
The .tuple() method of a Date or DateTime object returns a tuple.
-- ----------------------------------------------------------- Michael Schulz mschulz@webgis.de www.webgis.de
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
Hey Brad, thanks, this one did it!
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
Since i am rather a newbie to zope and python, allow me one more question on this subject: what is the difference between the objects the mysql-adapter returns for a date column and the result of the interbase adapter? Cheers, michael -- ----------------------------------------------------------- Michael Schulz mschulz@webgis.de www.webgis.de
On 17 Jul 2001, at 12:17, Michael Schulz wrote:
Since i am rather a newbie to zope and python, allow me one more question on this subject: what is the difference between the objects the mysql-adapter returns for a date column and the result of the interbase adapter?
Sorry, I do not know. I don't use mysql. Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com AOL-IM: BKClements
participants (2)
-
Brad Clements -
Michael Schulz