[Zope] DateTime problem

cleehoff at austin.rr.com cleehoff at austin.rr.com
Tue Nov 8 15:35:58 EST 2005


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
<ZopePageTemplate at /Time/time_home.html> 
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: <PythonExpr myrecordset[0] [0].strftime('%m/%d/%Y')>
Names:
{'container': <Folder instance at 8b00df8>,
 'default': <Products.PageTemplates.TALES.Default instance at 0x87bdefc>,
 'here': <Folder instance at 8b00df8>,
 'loop': <SafeMapping instance at 9f62368>,
 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter
instance at 0x87a4814>,
 'nothing': None,
 'options': {'args': ()},
 'repeat': <SafeMapping instance at 9f62368>,
 'request': <HTTPRequest,
URL=http://myserver.mydomain.org/Time/time_home.html>,
 'root': <Application instance at 8b4e870>,
 'template': <ZopePageTemplate at /Time/time_home.html>,
 '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 <expression>
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
<ZopePageTemplate at /Time/time_home.html> 
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: <PythonExpr DateTime(myrecordset[0][0]).strftime('%m/%d/%Y')>
Names:
{'container': <Folder instance at 9ffb358>,
 'default': <Products.PageTemplates.TALES.Default instance at 0x86e7bd4>,
 'here': <Folder instance at 116166a8>,
 'loop': <SafeMapping instance at d507258>,
 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter
instance at 0x86db91c>,
 'nothing': None,
 'options': {'args': ()},
 'repeat': <SafeMapping instance at d507258>,
 'request': <HTTPRequest,
URL=http://otherserver.otherdomain.org/Time/time_home.html>,
 'root': <Application instance at a0f6a40>,
 'template': <ZopePageTemplate at /Time/time_home.html>,
 '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/ .




More information about the Zope mailing list