[ZCM] [ZC] 2066/ 6 Comment "Unicode sent into ZPythonScript_edit"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Sat Apr 8 19:44:24 EDT 2006


Issue #2066 Update (Comment) "Unicode sent into ZPythonScript_edit"
 Status Rejected, Zope/bug+solution low
To followup, visit:
  http://www.zope.org/Collectors/Zope/2066

==============================================================
= Comment - Entry #6 by cigydd on Apr 8, 2006 7:44 pm

Hello,

here is what boa-constructor says me in a popup error-message-box (it's a traceback):

Unexpected Zope exception: Traceback (most recent call last): File
"/usr/lib/zope/lib/python/ZPublisher/Publish.py", line 175, in
publish_module_standard response = publish(request, module_name,
after_list, debug=debug) File
"/usr/lib/zope/lib/python/ZPublisher/Publish.py", line 132, in publish
sys.exc_info()[2], File
"/usr/lib/zope/lib/python/ZPublisher/Publish.py", line 101, in publish
request, bind=1) File "/usr/lib/zope/lib/python/ZPublisher/mapply.py",
line 88, in mapply if debug is not None: return
debug(object,args,context) File
"/usr/lib/zope/lib/python/ZPublisher/Publish.py", line 39, in
call_object result=apply(object,args) # Type s to step into published
object. File
"/usr/lib/zope/lib/python/Products/PythonScripts/PythonScript.py", line
133, in ZPythonScriptHTML_editAction self.ZPythonScript_edit(params,
body) File
"/usr/lib/zope/lib/python/Products/PythonScripts/PythonScript.py", line
149, in ZPythonScript_edit body = body.read() AttributeError: 'unicode'
object has no attribute 'read'

I read something about the unittests recently and it's something special for me. Maybe if someone will go through it he will reach the same solution I supplied before; maybe not.

But I just cannot imagine from where the 'unicode' object came when Zope expects only 'str' on the line 148 of <zope-path>/lib/python/Products/PythonScripts/PythonScript.py (see the last item in the traceback). It's because boa-constructor doesn't have an ability to catch this error and debug Zope... Maybe this error was caused by boa-constr. itself but there was no trace of its code in the traceback.

So please if someone would navigate me how to write a unittest for this purpose I could supply you one.

Cigydd
________________________________________
= Reject - Entry #5 by ajung on Apr 8, 2006 8:09 am

 Status: Pending => Rejected

You could have provide the full traceback as requested. 
I can not smell what the error is on _your_ system. If you think that something has to be fixed because it breaks on _your_ system then you should provide the necessary informations.
________________________________________
= Comment - Entry #4 by cigydd on Apr 8, 2006 8:04 am

A bit bureaucratic... Excuse me, I'm a newbie here and I give it up.

I understand that Zope has to have such restrictions in combination with Python versions due to the need security and stability, and that there are rules that I haven't been aware of.

I'm afraid that my report was just for nothing. So I don't actually add any furher information.

Cigydd
________________________________________
= Edit - Entry #3 by ajung on Apr 8, 2006 7:32 am

 Changes: edited transcript, importance (medium => low)
________________________________________
= Comment - Entry #2 by ajung on Apr 8, 2006 7:32 am

When you talk about errors then *please* provide the full
traceback. If you propose a patch then please include a unittest
that actually checks and demonstrates the intended behavior of the patch.

Btw. Python 2.4 + Zope 2.7.7 is not a supported combination
________________________________________
= Request - Entry #1 by Anonymous User on Apr 8, 2006 7:20 am

Hi all,

I begin to use boa-constructor to edit Zope content, especially Python scripts.
I encountered an exception saying that the "body" object doesn't have the attribute "read()".
It occured in the file /usr/lib/zope/lib/python/Products/PythonScripts/PythonScript.py in the procedure ZPythonScript_edit on the line 149.

I propose a change on the line 148, which stands like:

####################################
if type(body) is not type(''):
####################################

to this code:

####################################
if  type(body) is not type('')\
and type(body) is not type(u''):
####################################

- just for the procedure to accept an unicode object, which was my case.

Thank you all for the great project called Zope.

Cigydd
==============================================================



More information about the Zope-Collector-Monitor mailing list