I have the following code that works on one Zope install and does not work
on another. I would like to be able to use the same code under both, but am
at a loss as to why there is a difference. I do not control the Zope
servers running this application. Any help would be appreciated:
On one server, the following code works fine: python:
myrecordset[0][0].strftime('%m/%d/%Y')
But, when I move the page template containing that code to a different
server, the following error is generated:
Exception Type AttributeError
Exception Value 'str' object has no attribute 'strftime'
Traceback (innermost last):
Module ZPublisher.Publish, line 98, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 39, in call_object
Module Shared.DC.Scripts.Bindings, line 306, in __call__
Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
Module Products.PageTemplates.ZopePageTemplate, line 228, in _exec
Module Products.PageTemplates.PageTemplate, line 95, in pt_render
Module TAL.TALInterpreter, line 200, in __call__
Module TAL.TALInterpreter, line 244, in interpret
Module TAL.TALInterpreter, line 703, in do_useMacro
Module TAL.TALInterpreter, line 244, in interpret
Module TAL.TALInterpreter, line 726, in do_defineSlot
Module TAL.TALInterpreter, line 244, in interpret
Module TAL.TALInterpreter, line 669, in do_condition
Module TAL.TALInterpreter, line 244, in interpret
Module TAL.TALInterpreter, line 477, in do_setGlobal_tal
Module Products.PageTemplates.TALES, line 220, in evaluate
URL: /Time/time_home.html
Line 60, Column 4
Expression:
Names:
{'container': ,
'default': ,
'here': ,
'loop': ,
'modules': ,
'nothing': None,
'options': {'args': ()},
'repeat': ,
'request': http://myserver.mydomain.org/Time/time_home.html>,
'root': ,
'template': ,
'traverse_subpath': [],
'user': lford}
Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__
__traceback_info__: myrecordset[0] [0].strftime('%m/%d/%Y')
Module Python expression "myrecordset[0] [0].strftime('%m/%d/%Y')", line 1,
in
AttributeError: 'str' object has no attribute 'strftime'
I can get it to run properly on this server by rewriting the code to:
DateTime(sqlwkstart[0][0].strftime('%m/%d/%Y')
However, if I then take this corrected code and move it back to the first
server, I get the following error:
===
Exception Type TypeError
Exception Value unsupported operand type(s) for /
Traceback (innermost last):
Module ZPublisher.Publish, line 98, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 39, in call_object
Module Shared.DC.Scripts.Bindings, line 252, in __call__
Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
Module Products.PageTemplates.ZopePageTemplate, line 228, in _exec
Module Products.PageTemplates.PageTemplate, line 95, in pt_render
Module TAL.TALInterpreter, line 200, in __call__
Module TAL.TALInterpreter, line 244, in interpret
Module TAL.TALInterpreter, line 703, in do_useMacro
Module TAL.TALInterpreter, line 244, in interpret
Module TAL.TALInterpreter, line 726, in do_defineSlot
Module TAL.TALInterpreter, line 244, in interpret
Module TAL.TALInterpreter, line 669, in do_condition
Module TAL.TALInterpreter, line 244, in interpret
Module TAL.TALInterpreter, line 477, in do_setGlobal_tal
Module Products.PageTemplates.TALES, line 217, in evaluate
URL: /Time/time_home.html
Line 60, Column 4
Expression:
Names:
{'container': ,
'default': ,
'here': ,
'loop': ,
'modules': ,
'nothing': None,
'options': {'args': ()},
'repeat': ,
'request': http://otherserver.otherdomain.org/Time/time_home.html>,
'root': ,
'template': ,
'traverse_subpath': [],
'user': lford}
Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__
__traceback_info__: DateTime(myrecordset[0][0]).strftime('%m/%d/%Y')
Module Python expression
"DateTime(myrecordset[0][0]).strftime('%m/%d/%Y')", line 2, in f
Module DateTime.DateTime, line 684, in __init__
Module DateTime.DateTime, line 281, in _calcSD
TypeError: unsupported operand type(s) for /
===
The DateTime.py modules are the same rev. on these 2 boxes. The Zope builds
are slightly different, but both are 2.6. The first appears to be using
Python 2.1, the other Python 2.2.3. The latter box is using a Debian
package of Zope and python-mysql.
Where do I start tracking this down?
Lee
mail2web - Check your email from the web at
http://mail2web.com/ .
___
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )