DateTime inside an in loop
I want to use DateTime on a date value returned in a ZSQLMethod. E.g. Say the SQL for get_records() ZSQLMethod is SELECT ID, adate FROM DateValues I want to do something like this: <dtml-in expr="get_records()"> <dtml-var ID> <dtml-var expr="_.DateTime(adate).strftime('%d-%b')"> </dtml-in> I have tried all sorts of syntax to get a result, with no result. Question 1: Can someone tell me the correct syntax please? Question 2: Can someone 'teach me to fish' by showing me the path to some documentation on namespaces? I have searched and read a fair amount today without actually getting enlightenment:-( Thanks a lot Neil
Neil, what's the traceback? cheers, Garry On 23 Jun 2001, at 17:51, Neil Burnett wrote: From: "Neil Burnett" <neil@efc.be> To: <zope@zope.org> Subject: [Zope] DateTime inside an in loop Date sent: Sat, 23 Jun 2001 17:51:13 +0200
I want to use DateTime on a date value returned in a ZSQLMethod.
E.g. Say the SQL for get_records() ZSQLMethod is
SELECT ID, adate FROM DateValues
I want to do something like this:
<dtml-in expr="get_records()"> <dtml-var ID> <dtml-var expr="_.DateTime(adate).strftime('%d-%b')"> </dtml-in>
I have tried all sorts of syntax to get a result, with no result.
Question 1: Can someone tell me the correct syntax please?
Question 2: Can someone 'teach me to fish' by showing me the path to some documentation on namespaces? I have searched and read a fair amount today without actually getting enlightenment:-(
Thanks a lot
Neil
_______________________________________________ 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 )
+-------------------------------------------+ Garry Steedman mailto:gs@styrax.com Styrax Associates http://www.styrax.com/ "The Good Man has no shape." +-------------------------------------------+
Garry My live example uses the variable LastModified, not adate. I tried to simplify the dtml example so it would be clearer. The ZSQLMethod works fine and I can put the actual date returned into the DateTime function and it works. Heres my dtml: <dtml-in expr="get_log(PeopleID=9999)"> <dtml-var expr="_.DateTime(LastModified).strftime('%d-%b')"> </dtml-in> I have tried many variations: <dtml-var expr="_.DateTime('LastModified').strftime('%d-%b')"> <dtml-var expr="_.DateTime(['LastModified']).strftime('%d-%b')"> <dtml-var expr="_.DateTime(_['LastModified']).strftime('%d-%b')"> <dtml-var expr="_.DateTime(['sequence-var-LastModified']).strftime('%d-%b')"> <dtml-var expr="_.DateTime(_['sequence-var-LastModified']).strftime('%d-%b')"> All with slightly different failures. Thanks for looking Neil <!-- Traceback (innermost last): File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 223, in publish_module File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 187, in publish File C:\PROGRA~1\WebSite\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 171, in publish File C:\PROGRA~1\WebSite\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: test) File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: test) File C:\PROGRA~1\WebSite\lib\python\OFS\DTMLMethod.py, line 189, in __call__ (Object: test) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_String.py, line 540, in __call__ (Object: test) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_In.py, line 719, in renderwob (Object: get_log(PeopleID=9999)) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_Util.py, line 339, in eval (Object: _.DateTime(LastModified).strftime('%d-%b')) (Info: LastModified) File <string>, line 0, in ? File C:\PROGRA~1\WebSite\lib\python\DateTime\DateTime.py, line 733, in __init__ File C:\PROGRA~1\WebSite\lib\python\DateTime\DateTime.py, line 352, in _calcSD TypeError: (see above) -->
-----Original Message----- From: Garry Steedman [mailto:gs@styrax.com] Sent: 23 June 2001 20:26 To: Neil Burnett; zope@zope.org Subject: Re: [Zope] DateTime inside an in loop
Neil,
what's the traceback?
cheers,
Garry
On 23 Jun 2001, at 17:51, Neil Burnett wrote:
From: "Neil Burnett" <neil@efc.be> To: <zope@zope.org> Subject: [Zope] DateTime inside an in loop Date sent: Sat, 23 Jun 2001 17:51:13 +0200
I want to use DateTime on a date value returned in a ZSQLMethod.
E.g. Say the SQL for get_records() ZSQLMethod is
SELECT ID, adate FROM DateValues
I want to do something like this:
<dtml-in expr="get_records()"> <dtml-var ID> <dtml-var expr="_.DateTime(adate).strftime('%d-%b')"> </dtml-in>
I have tried all sorts of syntax to get a result, with no result.
Question 1: Can someone tell me the correct syntax please?
Question 2: Can someone 'teach me to fish' by showing me the path to some documentation on namespaces? I have searched and read a fair amount today without actually getting enlightenment:-(
Thanks a lot
Neil
_______________________________________________ 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 )
+-------------------------------------------+ Garry Steedman mailto:gs@styrax.com Styrax Associates http://www.styrax.com/
"The Good Man has no shape." +-------------------------------------------+
Hi Neil, this is probably a _very_ poor hack, but if it helps, well and good! i expect others will reply with more style ;-) anyway, this works for me: <dtml-in get_dates> <li><dtml-with dateOfBirth><dtml-var expr="'%s-%s' % (dd(), mm())"> </dtml-with> </dtml-in> HTH, Garry PS: i'm in BXL too! On 23 Jun 2001, at 18:47, Neil Burnett wrote: From: "Neil Burnett" <neil@efc.be> To: <zope@zope.org> Subject: RE: [Zope] DateTime inside an in loop Date sent: Sat, 23 Jun 2001 18:47:10 +0200
Garry
My live example uses the variable LastModified, not adate. I tried to simplify the dtml example so it would be clearer. The ZSQLMethod works fine and I can put the actual date returned into the DateTime function and it works.
Heres my dtml:
<dtml-in expr="get_log(PeopleID=9999)"> <dtml-var expr="_.DateTime(LastModified).strftime('%d-%b')"> </dtml-in>
I have tried many variations: <dtml-var expr="_.DateTime('LastModified').strftime('%d-%b')"> <dtml-var expr="_.DateTime(['LastModified']).strftime('%d-%b')"> <dtml-var expr="_.DateTime(_['LastModified']).strftime('%d-%b')"> <dtml-var expr="_.DateTime(['sequence-var-LastModified']).strftime('%d-%b')"> <dtml-var expr="_.DateTime(_['sequence-var-LastModified']).strftime('%d-%b')">
All with slightly different failures.
Thanks for looking
Neil
<!-- Traceback (innermost last): File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 223, in publish_module File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 187, in publish File C:\PROGRA~1\WebSite\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 171, in publish File C:\PROGRA~1\WebSite\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: test) File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: test) File C:\PROGRA~1\WebSite\lib\python\OFS\DTMLMethod.py, line 189, in __call__ (Object: test) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_String.py, line 540, in __call__ (Object: test) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_In.py, line 719, in renderwob (Object: get_log(PeopleID=9999)) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_Util.py, line 339, in eval (Object: _.DateTime(LastModified).strftime('%d-%b')) (Info: LastModified) File <string>, line 0, in ? File C:\PROGRA~1\WebSite\lib\python\DateTime\DateTime.py, line 733, in __init__ File C:\PROGRA~1\WebSite\lib\python\DateTime\DateTime.py, line 352, in _calcSD TypeError: (see above)
-->
-----Original Message----- From: Garry Steedman [mailto:gs@styrax.com] Sent: 23 June 2001 20:26 To: Neil Burnett; zope@zope.org Subject: Re: [Zope] DateTime inside an in loop
Neil,
what's the traceback?
cheers,
Garry
On 23 Jun 2001, at 17:51, Neil Burnett wrote:
From: "Neil Burnett" <neil@efc.be> To: <zope@zope.org> Subject: [Zope] DateTime inside an in loop Date sent: Sat, 23 Jun 2001 17:51:13 +0200
I want to use DateTime on a date value returned in a ZSQLMethod.
E.g. Say the SQL for get_records() ZSQLMethod is
SELECT ID, adate FROM DateValues
I want to do something like this:
<dtml-in expr="get_records()"> <dtml-var ID> <dtml-var expr="_.DateTime(adate).strftime('%d-%b')"> </dtml-in>
I have tried all sorts of syntax to get a result, with no result.
Question 1: Can someone tell me the correct syntax please?
Question 2: Can someone 'teach me to fish' by showing me the path to some documentation on namespaces? I have searched and read a fair amount today without actually getting enlightenment:-(
Thanks a lot
Neil
_______________________________________________ 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 )
+-------------------------------------------+ Garry Steedman mailto:gs@styrax.com Styrax Associates http://www.styrax.com/
"The Good Man has no shape." +-------------------------------------------+
_______________________________________________ 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 )
+-------------------------------------------+ Garry Steedman mailto:gs@styrax.com Styrax Associates http://www.styrax.com/ "The Good Man has no shape." +-------------------------------------------+
Yup. It works for me too:-) Thanks a bunch. Regards Neil
-----Original Message----- From: Garry Steedman [mailto:gs@styrax.com] Sent: 23 June 2001 21:26 To: Neil Burnett; zope@zope.org Subject: RE: [Zope] DateTime inside an in loop
Hi Neil,
this is probably a _very_ poor hack, but if it helps, well and good!
i expect others will reply with more style ;-)
anyway, this works for me:
<dtml-in get_dates> <li><dtml-with dateOfBirth><dtml-var expr="'%s-%s' % (dd(), mm())"> </dtml-with> </dtml-in>
HTH,
Garry
PS: i'm in BXL too!
On 23 Jun 2001, at 18:47, Neil Burnett wrote:
From: "Neil Burnett" <neil@efc.be> To: <zope@zope.org> Subject: RE: [Zope] DateTime inside an in loop Date sent: Sat, 23 Jun 2001 18:47:10 +0200
Garry
My live example uses the variable LastModified, not adate. I tried to simplify the dtml example so it would be clearer. The ZSQLMethod works fine and I can put the actual date returned into the DateTime function and it works.
Heres my dtml:
<dtml-in expr="get_log(PeopleID=9999)"> <dtml-var expr="_.DateTime(LastModified).strftime('%d-%b')"> </dtml-in>
I have tried many variations: <dtml-var expr="_.DateTime('LastModified').strftime('%d-%b')"> <dtml-var expr="_.DateTime(['LastModified']).strftime('%d-%b')"> <dtml-var expr="_.DateTime(_['LastModified']).strftime('%d-%b')"> <dtml-var expr="_.DateTime(['sequence-var-LastModified']).strftime('%d-%b')"> <dtml-var expr="_.DateTime(_['sequence-var-LastModified']).strftime('%d-%b')">
All with slightly different failures.
Thanks for looking
Neil
<!-- Traceback (innermost last): File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 223, in publish_module File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 187, in publish File C:\PROGRA~1\WebSite\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 171, in publish File C:\PROGRA~1\WebSite\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: test) File C:\PROGRA~1\WebSite\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: test) File C:\PROGRA~1\WebSite\lib\python\OFS\DTMLMethod.py, line 189, in __call__ (Object: test) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_String.py, line 540, in __call__ (Object: test) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_In.py, line 719, in renderwob (Object: get_log(PeopleID=9999)) File C:\PROGRA~1\WebSite\lib\python\DocumentTemplate\DT_Util.py, line 339, in eval (Object: _.DateTime(LastModified).strftime('%d-%b')) (Info: LastModified) File <string>, line 0, in ? File C:\PROGRA~1\WebSite\lib\python\DateTime\DateTime.py, line 733, in __init__ File C:\PROGRA~1\WebSite\lib\python\DateTime\DateTime.py, line 352, in _calcSD TypeError: (see above)
-->
-----Original Message----- From: Garry Steedman [mailto:gs@styrax.com] Sent: 23 June 2001 20:26 To: Neil Burnett; zope@zope.org Subject: Re: [Zope] DateTime inside an in loop
Neil,
what's the traceback?
cheers,
Garry
On 23 Jun 2001, at 17:51, Neil Burnett wrote:
From: "Neil Burnett" <neil@efc.be> To: <zope@zope.org> Subject: [Zope] DateTime inside an in loop Date sent: Sat, 23 Jun 2001 17:51:13 +0200
I want to use DateTime on a date value returned in a ZSQLMethod.
E.g. Say the SQL for get_records() ZSQLMethod is
SELECT ID, adate FROM DateValues
I want to do something like this:
<dtml-in expr="get_records()"> <dtml-var ID> <dtml-var expr="_.DateTime(adate).strftime('%d-%b')"> </dtml-in>
I have tried all sorts of syntax to get a result, with no result.
Question 1: Can someone tell me the correct syntax please?
Question 2: Can someone 'teach me to fish' by showing me the path to some documentation on namespaces? I have searched and read a fair amount today without actually getting enlightenment:-(
Thanks a lot
Neil
_______________________________________________ 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 )
+-------------------------------------------+ Garry Steedman mailto:gs@styrax.com Styrax Associates http://www.styrax.com/
"The Good Man has no shape." +-------------------------------------------+
_______________________________________________ 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 )
+-------------------------------------------+ Garry Steedman mailto:gs@styrax.com Styrax Associates http://www.styrax.com/
"The Good Man has no shape." +-------------------------------------------+
Neil Burnett writes:
I want to use DateTime on a date value returned in a ZSQLMethod.
E.g. Say the SQL for get_records() ZSQLMethod is
SELECT ID, adate FROM DateValues
I want to do something like this:
<dtml-in expr="get_records()"> <dtml-var ID> <dtml-var expr="_.DateTime(adate).strftime('%d-%b')"> </dtml-in>
I have tried all sorts of syntax to get a result, with no result.
Question 1: Can someone tell me the correct syntax please? Your syntax is good.
But, if your field "adate" is defined as a date in your table, it probably is already a "DateTime" object. Try to remove the "_.DateTime(...)", just use "adate".
Question 2: Can someone 'teach me to fish' by showing me the path to some documentation on namespaces? I have searched and read a fair amount today without actually getting enlightenment:-( The Zope book or
URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html Dieter
-----Original Message----- From: Dieter Maurer [mailto:dieter@handshake.de] Sent: 23 June 2001 22:36 To: Neil Burnett Cc: zope@zope.org Subject: Re: [Zope] DateTime inside an in loop
Neil Burnett writes:
I want to use DateTime on a date value returned in a ZSQLMethod.
E.g. Say the SQL for get_records() ZSQLMethod is
SELECT ID, adate FROM DateValues
I want to do something like this:
<dtml-in expr="get_records()"> <dtml-var ID> <dtml-var expr="_.DateTime(adate).strftime('%d-%b')"> </dtml-in>
I have tried all sorts of syntax to get a result, with no result.
Question 1: Can someone tell me the correct syntax please? Your syntax is good.
But, if your field "adate" is defined as a date in your table, it probably is already a "DateTime" object. Try to remove the "_.DateTime(...)", just use "adate".
Yes it is a date string, but I need to format it to be easy to read. I assumed I could do that with DateTime.
Question 2: Can someone 'teach me to fish' by showing me the path to some documentation on namespaces? I have searched and read a fair amount today without actually getting enlightenment:-( The Zope book or
The version I have doesn't help. I'll download the latest.
URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
Lots of good reading there, thanks.
Dieter
participants (3)
-
Dieter Maurer -
Garry Steedman -
Neil Burnett