I'm trying to reformat a date that I'm getting from our Sybase server. I get it in yyyy/mm/dd format and I'm trying to change it to mm/dd/yyyy format. I've created a DTML method called fixDate that looks like this: <dtml-call expr="REQUEST.set('date', _.str(date))"> <dtml-let newDate="date.split('/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> <dtml-var month>/<dtml-var day>/<dtml-var year> </dtml-let> It works if I call http://www.ourdomain.com/fixDate?date=2002/12/25, but if I try to use it from a DTML document I get: Error Type: NameError Error Value: global name 'REQUEST' is not defined If I take out the first line then I get: Error Type: AttributeError Error Value: split which is what prompted me to put it in to begin with. Any ideas? TIA Rick
<dtml-let newDate="date.split('/')" month="newDate[1]" day="newDate[2]" ^^^^^^^^^^^^^^^^^ !!!!!! newDate="_.string.split(date,'/')" ...
- aj ----- Original Message ----- From: "D. Rick Anderson" <ruger@comnett.net> To: <zope@zope.org> Sent: Monday, February 25, 2002 11:56 Subject: [Zope] another one
I'm trying to reformat a date that I'm getting from our Sybase server. I get it in yyyy/mm/dd format and I'm trying to change it to mm/dd/yyyy format. I've created a DTML method called fixDate that looks like this:
<dtml-call expr="REQUEST.set('date', _.str(date))"> <dtml-let newDate="date.split('/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> <dtml-var month>/<dtml-var day>/<dtml-var year> </dtml-let>
It works if I call http://www.ourdomain.com/fixDate?date=2002/12/25, but if I try to use it from a DTML document I get:
Error Type: NameError Error Value: global name 'REQUEST' is not defined
If I take out the first line then I get:
Error Type: AttributeError Error Value: split
which is what prompted me to put it in to begin with. Any ideas?
TIA
Rick
Not sure about the lack of the REQUEST object problem - but I believe that the split statement belongs in the string library so you should have: <dtml-let newDate="_.string.split(date,'/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> Plus - I probably wouldn't use the name date as a variable name - can be trouble! Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of D. Rick Anderson Sent: Monday, February 25, 2002 10:57 AM To: zope@zope.org Subject: [Zope] another one I'm trying to reformat a date that I'm getting from our Sybase server. I get it in yyyy/mm/dd format and I'm trying to change it to mm/dd/yyyy format. I've created a DTML method called fixDate that looks like this: <dtml-call expr="REQUEST.set('date', _.str(date))"> <dtml-let newDate="date.split('/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> <dtml-var month>/<dtml-var day>/<dtml-var year> </dtml-let> It works if I call http://www.ourdomain.com/fixDate?date=2002/12/25, but if I try to use it from a DTML document I get: Error Type: NameError Error Value: global name 'REQUEST' is not defined If I take out the first line then I get: Error Type: AttributeError Error Value: split which is what prompted me to put it in to begin with. Any ideas? TIA Rick
OK. I changed it to _.string.split(date, '/') and I'm still getting the same error (I've used the varible.split() format before with no problems, but thanks for the alternative!). I still get: Error Type: AttributeError Error Value: split Any more thoughts? Like I said, it works if you call it directly from a browser. Thanks again, Rick
Not sure about the lack of the REQUEST object problem - but I believe that the split statement belongs in the string library so you should have: <dtml-let newDate="_.string.split(date,'/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> Plus - I probably wouldn't use the name date as a variable name - can be trouble!
Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of D. Rick Anderson Sent: Monday, February 25, 2002 10:57 AM To: zope@zope.org Subject: [Zope] another one
I'm trying to reformat a date that I'm getting from our Sybase server. I get it in yyyy/mm/dd format and I'm trying to change it to mm/dd/yyyy format. I've created a DTML method called fixDate that looks like this:
<dtml-call expr="REQUEST.set('date', _.str(date))"> <dtml-let newDate="date.split('/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> <dtml-var month>/<dtml-var day>/<dtml-var year> </dtml-let>
It works if I call http://www.ourdomain.com/fixDate?date=2002/12/25, but if I try to use it from a DTML document I get:
Error Type: NameError Error Value: global name 'REQUEST' is not defined
If I take out the first line then I get:
Error Type: AttributeError Error Value: split
which is what prompted me to put it in to begin with. Any ideas?
TIA
Rick
_______________________________________________ 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 )
Your not going to like this, but I tried your code exactly (apart from changing the way that the date is generated - I used a string) and it works. Is there a problem with what is being put into your 'date' variable from your Sybase server? What exactly is it returning? What does Zope think it is getting? Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of D. Rick Anderson Sent: Monday, February 25, 2002 11:51 AM To: lnason@bcm.tmc.edu; zope@zope.org Subject: RE: [Zope] another one OK. I changed it to _.string.split(date, '/') and I'm still getting the same error (I've used the varible.split() format before with no problems, but thanks for the alternative!). I still get: Error Type: AttributeError Error Value: split Any more thoughts? Like I said, it works if you call it directly from a browser. Thanks again, Rick
Not sure about the lack of the REQUEST object problem - but I believe that the split statement belongs in the string library so you should have: <dtml-let newDate="_.string.split(date,'/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> Plus - I probably wouldn't use the name date as a variable name - can be trouble!
Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of D. Rick Anderson Sent: Monday, February 25, 2002 10:57 AM To: zope@zope.org Subject: [Zope] another one
I'm trying to reformat a date that I'm getting from our Sybase server. I get it in yyyy/mm/dd format and I'm trying to change it to mm/dd/yyyy format. I've created a DTML method called fixDate that looks like this:
<dtml-call expr="REQUEST.set('date', _.str(date))"> <dtml-let newDate="date.split('/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> <dtml-var month>/<dtml-var day>/<dtml-var year> </dtml-let>
It works if I call http://www.ourdomain.com/fixDate?date=2002/12/25, but if I try to use it from a DTML document I get:
Error Type: NameError Error Value: global name 'REQUEST' is not defined
If I take out the first line then I get:
Error Type: AttributeError Error Value: split
which is what prompted me to put it in to begin with. Any ideas?
TIA
Rick
_______________________________________________ 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 )
split is a method of the string class now (Python 2, Zope 2.4, 2.5), which is why you can do either: _.string.split(date, '/') or date.split('/') As far as the REQUEST object, it's somewhat baffling. Can you show us how you are calling your DTML method from your DTML Document? -Paul D. Rick Anderson wrote:
OK. I changed it to _.string.split(date, '/') and I'm still getting the same error (I've used the varible.split() format before with no problems, but thanks for the alternative!). I still get:
Error Type: AttributeError Error Value: split
Any more thoughts? Like I said, it works if you call it directly from a browser.
Thanks again,
Rick
Not sure about the lack of the REQUEST object problem - but I believe that the split statement belongs in the string library so you should have: <dtml-let newDate="_.string.split(date,'/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> Plus - I probably wouldn't use the name date as a variable name - can be trouble!
Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of D. Rick Anderson Sent: Monday, February 25, 2002 10:57 AM To: zope@zope.org Subject: [Zope] another one
I'm trying to reformat a date that I'm getting from our Sybase server. I get it in yyyy/mm/dd format and I'm trying to change it to mm/dd/yyyy format. I've created a DTML method called fixDate that looks like this:
<dtml-call expr="REQUEST.set('date', _.str(date))"> <dtml-let newDate="date.split('/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> <dtml-var month>/<dtml-var day>/<dtml-var year> </dtml-let>
It works if I call http://www.ourdomain.com/fixDate?date=2002/12/25, but if I try to use it from a DTML document I get:
Error Type: NameError Error Value: global name 'REQUEST' is not defined
If I take out the first line then I get:
Error Type: AttributeError Error Value: split
which is what prompted me to put it in to begin with. Any ideas?
TIA
Rick
_______________________________________________ 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 )
D. Rick Anderson writes:
I'm trying to reformat a date that I'm getting from our Sybase server. I get it in yyyy/mm/dd format and I'm trying to change it to mm/dd/yyyy format. I've created a DTML method called fixDate that looks like this:
<dtml-call expr="REQUEST.set('date', _.str(date))"> <dtml-let newDate="date.split('/')" month="newDate[1]" day="newDate[2]" year="newDate[0]"> <dtml-var month>/<dtml-var day>/<dtml-var year> </dtml-let>
It works if I call http://www.ourdomain.com/fixDate?date=2002/12/25, but if I try to use it from a DTML document I get:
Error Type: NameError Error Value: global name 'REQUEST' is not defined Looks like a standard error: calling a DTML object without its two positional arguments. Please read the "Calling DTML objects" section in
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
If I take out the first line then I get:
Error Type: AttributeError Error Value: split Then your "date" is a "DateTime" object which does not have a "split" method (as you probably understand).
You can use "_.str(date).split('/')", instead. Dieter
participants (5)
-
Andreas Jung -
D. Rick Anderson -
Dieter Maurer -
Laurie Nason -
Paul Erickson