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

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Mon Apr 10 18:23:37 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 #8 by cigydd on Apr 10, 2006 6:23 pm

Thank you, camil7, for your extensive help!

I want just to help, nothing more or less.
So I contacted the boa-constructor developers in the Usenet group gmane.comp.lang.ide.boa-constructor.user at news.gmane.org NNTP server. I explained what's going on and supplied a link to this bug issue.
I hope they will answer soon.

BTW. have a nice Easter.
________________________________________
= Comment - Entry #7 by camil7 on Apr 10, 2006 5:12 pm


Uploaded:  "col_2066.patch.txt"
 - http://www.zope.org/Collectors/Zope/2066/col_2066.patch.txt/view
Cigydd: ajung is by default in a bad mood when he looks into the 
collector, never mind :)
 
In general its a good idea first to ask on the mailing lists
before putting in a bug here. This *should* be documented on the 
main Collector page ....

Anyway here is a patch with a unittest against the current svn head.
This seems to prove that the patch does not break the tests.

However I am in doubt if storing the script body in unicode
is a good idea. It has never been done like that, and it is not
possible to do that via the ZMI.
 It seemsthe boa constructor sends the data via the parameter 'body:utf-8:text'
while the ZMI only provides a 'body:text'
(i.e. no implicit marshalling to unicode).

 I suspect the boa constructor is abusing the ZMI interface
to pull in unicode - most probably thinking its good style to do 
so. Maybe ask the people developing boa why they did it that way
and why they think its a good idea.

________________________________________
= 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