Runtime error in python scripts
Hi I just got a query from someone testing my Zope application "f2w helpdesk" (on sourceforge). They got an error in a Python Script: Error Type: RuntimeError Error Value: Script (Python) task_originator_phone has errors. with the following traceback: -------------------------------------------- Traceback (innermost last): File /usr/lib/python2.1/site-packages/ZPublisher/Publish.py, line 223, in publish_module [snip... the usual stuff ] (Object: edit_open_request) File /usr/lib/python2.1/site-packages/DocumentTemplate/DT_Util.py, line 231, in eval (Object: task_originator_phone(r_originator)) (Info: task_originator_phone) File <string>, line 2, in f File /usr/share/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 324, in __call__ (Object: task_originator_phone) File /usr/share/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 354, in _bindAndExec (Object: task_originator_phone) File /usr/share/zope/lib/python/Products/PythonScripts/PythonScript.py, line 354, in _exec (Object: task_originator_phone) (Info: ({'script': <PythonScript instance at 88b7548>, 'context': <r instance at 88ce2f0>, 'container': <Folder instance at 8829200>, 'traverse_subpath': []}, ('OPSC',), {}, ())) RuntimeError: (see above) ---------------------------------- They are clearly using Python 2.1, and hence Zope 2.4. I am using Zope 2.3.3 on Debian, and I can't duplicate the error myself. What I am asking is, have there been any incompatible changes between Zope 2.3 and Zope 2.4 in the syntax or handling of Python scripts? The script is as follows, in case it gives any clues. ## Script (Python) "task_originator_phone" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=r_originator ##title= ## results = context.sel_k_1(k_id=r_originator) contact = results and results[0] # None if no results, first row if there are any visible = "" # The text to appear on the page title = "" # The title text (hover help, on some Browsers) if contact: if contact.k_ext: visible = contact.k_ext + " " + contact.k_location # Prefer ext and location title = contact.k_phone_1 or contact.k_phone_2 # help is a phone number else: visible = contact.k_phone_1 or contact.k_phone_2 # settle for a phone number if visible: return '%s' % (title,visible) else: return "" ---------- I will be grateful for any clues as to what I can do to make my scripts compatible with both versions of Zope, if that is indeed the problem. If the problem is I've done something stupid, please someone let me know about that too :) Peter Harris **************************************************************************** This message and any files transmitted with it are confidential. The contents may not be disclosed or used by anyone other than the addressee. If you have received this communication in error, please delete the message and notify JBB (Greater Europe) Plc immediately on 0141-248-5771. The views expressed in this email are not necessarily the views of JBB (Greater Europe) PLC. As it has been transmitted over a public network, JBB (Greater Europe) PLC makes no representation nor accepts any liability for the email's accuracy or completeness unless expressly stated to the contrary. Should you, as the intended recipient, suspect that the message has been intercepted or amended, please notify JBB (Greater Europe) Plc immediately on 0141-248-5771. ****************************************************************************
Harris Peter wrote:
Hi I just got a query from someone testing my Zope application "f2w helpdesk" (on sourceforge). They got an error in a Python Script:
Error Type: RuntimeError Error Value: Script (Python) task_originator_phone has errors.
with the following traceback: -------------------------------------------- Traceback (innermost last): File /usr/lib/python2.1/site-packages/ZPublisher/Publish.py, line 223, in publish_module [snip... the usual stuff ] (Object: edit_open_request) File /usr/lib/python2.1/site-packages/DocumentTemplate/DT_Util.py, line 231, in eval (Object: task_originator_phone(r_originator)) (Info: task_originator_phone) File <string>, line 2, in f File /usr/share/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 324, in __call__ (Object: task_originator_phone) File /usr/share/zope/lib/python/Shared/DC/Scripts/Bindings.py, line 354, in _bindAndExec (Object: task_originator_phone) File /usr/share/zope/lib/python/Products/PythonScripts/PythonScript.py, line 354, in _exec (Object: task_originator_phone) (Info: ({'script': <PythonScript instance at 88b7548>, 'context': <r instance at 88ce2f0>, 'container': <Folder instance at 8829200>, 'traverse_subpath': []}, ('OPSC',), {}, ())) RuntimeError: (see above) ---------------------------------- They are clearly using Python 2.1, and hence Zope 2.4. I am using Zope 2.3.3 on Debian, and I can't duplicate the error myself.
What I am asking is, have there been any incompatible changes between Zope 2.3 and Zope 2.4 in the syntax or handling of Python scripts?
No, the syntax is not different in this case, but the object code has apparently changed from python 1.5.2 to python 2.1. I have seen this several times moving from 2.3.3 to newer zopes. Usually, one just needs to go to the offending python script and submit it to the ZODB again. This forces a recompile and save, which takes care of the vast majority of these errors. Two things that I have had to watch out for:: string.letters() returns different things in the two pythons. Also, I have seen some weirdness with strftime that I have not got a good handle on; it acts like DateTime.strftime() has changed a lot or disappeared. I worked around this by keeping the dates as strings, which was OK because I was just storing them in a database anyway. hth, --Jim Washington
participants (2)
-
Harris Peter -
Jim Washington