[Zope-Checkins] SVN: Zope/branches/2.10/lib/python/Products/PythonScripts/ Merged r72753:72754 from 2.9 branch.
Log message for revision 72755: Merged r72753:72754 from 2.9 branch. Raise SyntaxError when encountering invalid PythonScript headers. Changed: U Zope/branches/2.10/lib/python/Products/PythonScripts/PythonScript.py U Zope/branches/2.10/lib/python/Products/PythonScripts/tests/testPythonScript.py A Zope/branches/2.10/lib/python/Products/PythonScripts/tests/tscripts/ns_bind_invalid.ps -=- Modified: Zope/branches/2.10/lib/python/Products/PythonScripts/PythonScript.py === --- Zope/branches/2.10/lib/python/Products/PythonScripts/PythonScript.py 2007-02-22 10:17:20 UTC (rev 72754) +++ Zope/branches/2.10/lib/python/Products/PythonScripts/PythonScript.py 2007-02-22 10:19:26 UTC (rev 72755) @@ -417,7 +417,7 @@ k = k.strip().lower() v = v.strip() if not mdata.has_key(k): -SyntaxError, 'Unrecognized header line %s' % line +raise SyntaxError, 'Unrecognized header line %s' % line if v == mdata[k]: # Unchanged value continue Modified: Zope/branches/2.10/lib/python/Products/PythonScripts/tests/testPythonScript.py === --- Zope/branches/2.10/lib/python/Products/PythonScripts/tests/testPythonScript.py 2007-02-22 10:17:20 UTC (rev 72754) +++ Zope/branches/2.10/lib/python/Products/PythonScripts/tests/testPythonScript.py 2007-02-22 10:19:26 UTC (rev 72755) @@ -197,6 +197,9 @@ bound = f.__render_with_namespace__({'yes': 1, 'no': self.fail}) self.assertEqual(bound, 1) +def testNSBindInvalidHeader(self): +self.assertRaises(SyntaxError, self._filePS, 'ns_bind_invalid') + def testBooleanMap(self): res = self._filePS('boolean_map')() self.failUnless(res) Copied: Zope/branches/2.10/lib/python/Products/PythonScripts/tests/tscripts/ns_bind_invalid.ps (from rev 72754, Zope/branches/2.9/lib/python/Products/PythonScripts/tests/tscripts/ns_bind_invalid.ps) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PythonScripts/ Merged r72753:72754 from 2.9 branch.
Log message for revision 72756: Merged r72753:72754 from 2.9 branch. Raise SyntaxError when encountering invalid PythonScript headers. Changed: U Zope/trunk/lib/python/Products/PythonScripts/PythonScript.py U Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py A Zope/trunk/lib/python/Products/PythonScripts/tests/tscripts/ns_bind_invalid.ps -=- Modified: Zope/trunk/lib/python/Products/PythonScripts/PythonScript.py === --- Zope/trunk/lib/python/Products/PythonScripts/PythonScript.py 2007-02-22 10:19:26 UTC (rev 72755) +++ Zope/trunk/lib/python/Products/PythonScripts/PythonScript.py 2007-02-22 10:22:19 UTC (rev 72756) @@ -417,7 +417,7 @@ k = k.strip().lower() v = v.strip() if not mdata.has_key(k): -SyntaxError, 'Unrecognized header line %s' % line +raise SyntaxError, 'Unrecognized header line %s' % line if v == mdata[k]: # Unchanged value continue Modified: Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py === --- Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py 2007-02-22 10:19:26 UTC (rev 72755) +++ Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py 2007-02-22 10:22:19 UTC (rev 72756) @@ -197,6 +197,9 @@ bound = f.__render_with_namespace__({'yes': 1, 'no': self.fail}) self.assertEqual(bound, 1) +def testNSBindInvalidHeader(self): +self.assertRaises(SyntaxError, self._filePS, 'ns_bind_invalid') + def testBooleanMap(self): res = self._filePS('boolean_map')() self.failUnless(res) Copied: Zope/trunk/lib/python/Products/PythonScripts/tests/tscripts/ns_bind_invalid.ps (from rev 72754, Zope/branches/2.9/lib/python/Products/PythonScripts/tests/tscripts/ns_bind_invalid.ps) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-dev] raising exceptiosn [was: SVN: Zope/branches/2.9/lib/python/Products/PythonScripts/ Raise SyntaxError when encountering invalid PythonScript headers.]
Stefan H. Holek wrote: Log message for revision 72754: Raise SyntaxError when encountering invalid PythonScript headers. Changed: U Zope/branches/2.9/lib/python/Products/PythonScripts/PythonScript.py U Zope/branches/2.9/lib/python/Products/PythonScripts/tests/testPythonScript.py A Zope/branches/2.9/lib/python/Products/PythonScripts/tests/tscripts/ns_bind_invalid.ps -=- Modified: Zope/branches/2.9/lib/python/Products/PythonScripts/PythonScript.py === --- Zope/branches/2.9/lib/python/Products/PythonScripts/PythonScript.py 2007-02-22 05:58:28 UTC (rev 72753) +++ Zope/branches/2.9/lib/python/Products/PythonScripts/PythonScript.py 2007-02-22 10:17:20 UTC (rev 72754) @@ -416,7 +416,7 @@ k = k.strip().lower() v = v.strip() if not mdata.has_key(k): -SyntaxError, 'Unrecognized header line %s' % line +raise SyntaxError, 'Unrecognized header line %s' % line if v == mdata[k]: # Unchanged value continue Stefan, thanks for the fix. Just note that according to PEP8 and PEP3100, this style of raising exceptions will go away (see http://mail.python.org/pipermail/python-dev/2005-August/055190.html). The whole Zope code base has already been converted to the new style long ago, new code should also adhere to it. -- http://worldcookery.com -- Professional Zope documentation and training Next Zope 3 training at Camp5: http://trizpug.org/boot-camp/camp5 ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Zope Tests: 7 OK
Summary of messages to the zope-tests list. Period Wed Feb 21 12:00:00 2007 UTC to Thu Feb 22 12:00:00 2007 UTC. There were 7 messages: 7 from Zope Unit Tests. Tests passed OK --- Subject: OK : Zope-2.6 Python-2.1.3 : Linux From: Zope Unit Tests Date: Wed Feb 21 21:06:12 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-February/007307.html Subject: OK : Zope-2.6 Python-2.3.6 : Linux From: Zope Unit Tests Date: Wed Feb 21 21:07:42 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-February/007308.html Subject: OK : Zope-2.7 Python-2.3.6 : Linux From: Zope Unit Tests Date: Wed Feb 21 21:09:12 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-February/007309.html Subject: OK : Zope-2.8 Python-2.3.6 : Linux From: Zope Unit Tests Date: Wed Feb 21 21:10:42 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-February/007310.html Subject: OK : Zope-2.9 Python-2.4.4 : Linux From: Zope Unit Tests Date: Wed Feb 21 21:12:18 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-February/007311.html Subject: OK : Zope-2.10 Python-2.4.4 : Linux From: Zope Unit Tests Date: Wed Feb 21 21:13:48 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-February/007312.html Subject: OK : Zope-trunk Python-2.4.4 : Linux From: Zope Unit Tests Date: Wed Feb 21 21:15:18 EST 2007 URL: http://mail.zope.org/pipermail/zope-tests/2007-February/007313.html ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-PAS] ScriptablePlugin woes...
There's a bug in the ScriptablePlugin, which might render a PAS-enabled instance useless. In manage_updateInterfaces, the call to 'directlyProvides' passes *all* provided interfaces, and not only the ones previously directlyProvided. klass_interfaces = [x for x in implementedBy(ScriptablePlugin)] directlyProvides( self, *(klass_interfaces + new_interfaces) ) While this is not completely wrong, it has caused me lots of grief, because some references to interfaces in Products.Five.bbb got persisted that way, and now that Five.bbb is gone those instances of the ScriptablePlugin are broken, and you can't get in through the ZMI to remove them. Even after that is corrected there is still an issue if some directlyProvided interface goes away, because zope.interface.declarations.Provides doesn't cope with this. I've reported this other issue on the zope3-dev list a few minutes ago. A workaround for PAS would be to define __setstate__/__getstate__ on ScriptablePlugin and 'clean up' the Provides declaration. -- Sidnei da Silva Enfold Systemshttp://enfoldsystems.com Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214 ___ Zope-PAS mailing list Zope-PAS@zope.org http://mail.zope.org/mailman/listinfo/zope-pas
[Zope] metal:fill-slot and tal:condition
Hi everybody, I am stuck with the following problem. I would appreciate it very much if you could help me with it. So I have a ZPT where a macro is defined with several slots; one of the slots like below: tal:block metal:define-slot=slot_issue SLOT DEFAULT CONTENT /tal:block The common way to put other content in the slot is: tal:block metal:fill-slot=slot_issue CUSTOM SLOT CONTENT /tal:block Now, in a ZPT that uses the above marco I want to replace the default slot content with other stuff *only* if a condition is fulfilled: tal:block tal:condition=condition-code metal:fill-slot=slot_issue CUSTOM SLOT CONTENT /tal:block If the condition-code returns True then the CUSTOM SLOT CONTENT is put instead of the default slot content - correct. If the condition-code returns False then nothing will be displayed - this is not correct?!. I also tried somthing like: tal:block tal:condition=condition-code tal:block metal:fill-slot=slot_issue CUSTOM SLOT CONTENT /tal:block /tal:block In this case the content of the slot is CUSTOM SLOT CONTENT in both cases - the result is True or False. The only solution that I can think of is not elegant at all because I have to duplicate the slot_issue's default content: tal:block metal:fill-slot=slot_issue tal:block tal:condition=condition-code CUSTOM SLOT CONTENT /tal:block tal:block tal:condition=python:not condition-code SLOT DEFAULT CONTENT /tal:block /tal:block Is there other wat to accomplish this? Thank you very much, Dragos ___ 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 )
[Zope] How to create a global variable?
Hi! I've a python script which creates a dictionnary each time it's called. This dictionnary is always the same. I would increase the performance if I could generate and cache the dictionnary once, then reuse it. I'm looking for a space like REQUEST.SESSION that is the same for each user of my website (other solutions are welcome). Do you know how to do that? Thank you. ___ 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 )
[Zope] Re: metal:fill-slot and tal:condition
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dragos Chirila wrote: Hi everybody, I am stuck with the following problem. I would appreciate it very much if you could help me with it. So I have a ZPT where a macro is defined with several slots; one of the slots like below: tal:block metal:define-slot=slot_issue SLOT DEFAULT CONTENT /tal:block The common way to put other content in the slot is: tal:block metal:fill-slot=slot_issue CUSTOM SLOT CONTENT /tal:block Now, in a ZPT that uses the above marco I want to replace the default slot content with other stuff *only* if a condition is fulfilled: tal:block tal:condition=condition-code metal:fill-slot=slot_issue CUSTOM SLOT CONTENT /tal:block If the condition-code returns True then the CUSTOM SLOT CONTENT is put instead of the default slot content - correct. If the condition-code returns False then nothing will be displayed - this is not correct?!. I also tried somthing like: tal:block tal:condition=condition-code tal:block metal:fill-slot=slot_issue CUSTOM SLOT CONTENT /tal:block /tal:block In this case the content of the slot is CUSTOM SLOT CONTENT in both cases - the result is True or False. The only solution that I can think of is not elegant at all because I have to duplicate the slot_issue's default content: tal:block metal:fill-slot=slot_issue tal:block tal:condition=condition-code CUSTOM SLOT CONTENT /tal:block tal:block tal:condition=python:not condition-code SLOT DEFAULT CONTENT /tal:block /tal:block Is there other wat to accomplish this? You might modify the macro to allow this, making the default content a separate macro:: html metal:define-macro=slotted body h1 Slotted /h1 div metal:define-slot=slot_issue metal:default metal:define-macro=default_issue DEFAULT SLOT CONTENT metal:default /div /body /html The template which includes the macro would then be:: html metal:use-macro=context/other_template/macros/slotted body div metal:fill-slot=slot_issue tal:block condition=condition-code CUSTOM SLOT CONTENT /tal:block tal:block condition=not:condition-code div metal:use-macro=context/other_template/macros/default_issue/ /tal:block /div /body /html It may help to remember that macros are actually inlined into the including template, rather than being called as a function would be. Tres. - -- === Tres Seaver +1 540-429-0999 [EMAIL PROTECTED] Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF3YQz+gerLs4ltQ4RAjetAKCpQdrYi6Vl0LeWkAvE6sFVt2RwOACg0GgZ tYguZqyYKbTohGOmh6in5gw= =Q5Bv -END PGP SIGNATURE- ___ 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 )
[Zope] Re: metal:fill-slot and tal:condition
Dragos Chirila schrieb: Hi everybody, I am stuck with the following problem. I would appreciate it very much if you could help me with it. [snip] If I understand correctly you want to fill a slot if a condition is true else leave the default. A typical slot-modell looks something like this: Template I: a metal:define-macro=A b metal:define-slot=B default /b /a Template II: a metal:use-macro=here/TemplateI/macros/A b metal:fill-slot=B custom /b /a A different approach, a use-macro-modell: Template I: a metal:define-macro=A tal:define=macros here/getmacros b metal:use-macro=macros/B/ /a Python Script getmacros: macros = {} # default_macros, custom_macros are page templates. macros.update(container.default_macros.macros) if blah: macros.update(container.custom_macros.macros) return macros This is oversimplified, but I hope it helps you to find a solution. Regards, Tonico ___ 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 )
[Zope] Re: How to create a global variable?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 jerome prudent wrote: Hi! I've a python script which creates a dictionnary each time it's called. This dictionnary is always the same. I would increase the performance if I could generate and cache the dictionnary once, then reuse it. I'm looking for a space like REQUEST.SESSION that is the same for each user of my website (other solutions are welcome). Do you know how to do that? Thank you. http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ZopeServices.stx#2-28 Tres. - -- === Tres Seaver +1 540-429-0999 [EMAIL PROTECTED] Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF3Y5Q+gerLs4ltQ4RAp1aAKDQovh4Kw6k8rDsuZSfXVGerzQadQCdGv5t xf7N1mTtG0CIU59Y193DXuw= =/rpy -END PGP SIGNATURE- ___ 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 )
[Zope] __bobo_traverse__ and wrappers
Hi all! Some days ago I begin this threat: http://www.mail-archive.com/zope@zope.org/msg26355.html Dieter point me to the solution and I try something like: def __bobo_traverse__(self, REQUEST, nombre): obj = getattr(self, nombre, None) if obj is None: self.REQUEST.set('TraversalRequestNameStack', self.REQUEST[TraversalRequestNameStack] + [nombre]) resultado = self() if type(resultado) == type(unicode()): return WrapperUnicode(resultado) elif type(resultado) == type(str()): return WrapperStr(resultado) else: return resultado return obj and the wrappers: class WrapperStr(str): __roles__ = None class WrapperUnicode(unicode): __roles__ = None But when I try to launch this zope raises a NotFound exception If I inspect de content of resultado I could see an unicode string then the WrapperUnicode is used to wrap the result Can you point me where the problem is, please? Thanks a lot! -- Mis Cosas http://blogs.sistes.net/Garito ___ 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 )
Re: [Zope] How to create a global variable?
snip - Original Message - From: jerome prudent To: zope@zope.org Sent: Thursday, February 22, 2007 5:50 AM Subject: [Zope] How to create a global variable? Hi! I've a python script which creates a dictionnary each time it's called. This dictionnary is always the same. I would increase the performance if I could generate and cache the dictionnary once, then reuse it. I'm looking for a space like REQUEST.SESSION that is the same for each user of my website (other solutions are welcome). /snip You could easily create a property field on a folder that contains the 'global' information. Any script or method that has access to that folder can access that property field. Jonathan ___ 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 ) ___ 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 )
Re: [Zope] How to create a global variable?
Ok, Thank you! 2007/2/22, Jonathan [EMAIL PROTECTED]: snip - Original Message - From: jerome prudent To: zope@zope.org Sent: Thursday, February 22, 2007 5:50 AM Subject: [Zope] How to create a global variable? Hi! I've a python script which creates a dictionnary each time it's called. This dictionnary is always the same. I would increase the performance if I could generate and cache the dictionnary once, then reuse it. I'm looking for a space like REQUEST.SESSION that is the same for each user of my website (other solutions are welcome). /snip You could easily create a property field on a folder that contains the 'global' information. Any script or method that has access to that folder can access that property field. Jonathan ___ 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 ) ___ 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 )
Re: [Zope] How to create a global variable?
On Thu, Feb 22, 2007 at 11:50:51AM +0100, jerome prudent wrote: Hi! I've a python script which creates a dictionnary each time it's called. This dictionnary is always the same. I would increase the performance if I could generate and cache the dictionnary once, then reuse it. I'm looking for a space like REQUEST.SESSION that is the same for each user of my website (other solutions are welcome). Do you know how to do that? RAM Cache Manager. -- Paul Winkler http://www.slinkp.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 )
[Zope] Resizing an Image with PIL via a Form Upload
I'm trying to resize an image uploaded from a form using PIL. I got it to work on an existing image but I can't seem to get it to work on an image that's uploaded through the form. The ID of the file I'm trying to upload is DSCF0004.jpg. The form, script and traceback are listed below. Thanks in advance. form action=processed/imgSizer method=post enctype=multipart.form-data input type=file name=original_id input type=submit name=submit value= Add /form (imgSizer External Method) 1 def makeImages(self, original_id): 2 3import PIL.Image 4import PIL 5from StringIO import StringIO 6import os.path 7 8original_image=getattr(self, original_id) 9original_file=StringIO(str(original_image.data)) ... returns: Traceback (innermost last): * Module ZPublisher.Publish, line 115, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 41, in call_object * Module Products.ExternalMethod.ExternalMethod, line 225, in __call__ __traceback_info__: ((Folder at /dev/imgtest/processed, 'DSCF0004.jpg'), {}, None) * Module .../Zope/Extensions/imgSizer.py, line 9, in makeImages AttributeError: DSCF0004.jpg ___ 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 )
Re: [Zope] Resizing an Image with PIL via a Form Upload
Jusst a shot in the dark: can you try to use a name without a dot inside? -- Marco Bizzarri http://iliveinpisa.blogspot.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 )
Re: [Zope] Resizing an Image with PIL via a Form Upload
- Original Message - From: Tom Von Lahndorff [EMAIL PROTECTED] To: zope@zope.org Sent: Thursday, February 22, 2007 1:29 PM Subject: [Zope] Resizing an Image with PIL via a Form Upload I'm trying to resize an image uploaded from a form using PIL. I got it to work on an existing image but I can't seem to get it to work on an image that's uploaded through the form. The ID of the file I'm trying to upload is DSCF0004.jpg. The form, script and traceback are listed below. Thanks in advance. form action=processed/imgSizer method=post enctype=multipart.form-data input type=file name=original_id input type=submit name=submit value= Add /form (imgSizer External Method) 1 def makeImages(self, original_id): 2 3import PIL.Image 4import PIL 5from StringIO import StringIO 6import os.path 7 8original_image=getattr(self, original_id) 9original_file=StringIO(str(original_image.data)) just a guess, but i don't think getattr is returning what you think it is returning. The image has not been 'stored' anywhere yet, it is just a FileUpload instance. To get at the information in this instance: # the var name used in your form is misleading, it is not just the image id fileName = self.REQUEST['original_id'].filename fileData = self.REQUEST['original_id'].read() hth Jonathan ___ 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 )
Re: [Zope] Resizing an Image with PIL via a Form Upload
On Feb 22, 2007, at 1:29 PM, Tom Von Lahndorff wrote: 8original_image=getattr(self, original_id) 9original_file=StringIO(str(original_image.data)) [and later] AttributeError: DSCF0004.jpg I think your line numbers are off by one, because I'd think it is the getattr that would be causing the Attribute Error (at most, line 9 could give an attribute error for something called data. Zope turns file upload objects into ZPublisher.HTTPRequest.FileUpload instances. and pass them to your method. FileUpload instances have an interface similar to python file objects, you can .read(), .seek(), .close() or do whatever you want to them and might not need to wrap the contents into a StringIO object first. (your trying to fetch the file as an attribute of self seems to imply that you think the form data is already uploaded into zope and is an Image object in a folder. It isn't there yet, and won't be unless you store it there.) I think if you removed lines 8 and 9 (by your numbering) and renamed the second argument to the method to original_file, things would work as you need: 1 def makeImages(self, original_file): 2 3import PIL.Image 4import PIL 5import os.path 6 ... ___ 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 )
[Zope] Error Tracing in Zope 2.6
Can anyone give me some pointers on tracing errors in Zope 2.6? I'm already using the DTML var error-tb or whatever it is. And that can be helpful at times. But I was wondering if there's some other way to pinpoint which line in the DTML file is throwing the error. I'm moving my Zope setup from Linux to Windows and apparently there are some syntax that needs to change when migrating over (aside from my SQL command, since I'm going from Oracle to MS SQL Server). Some of these files are big, and there's a done of files to go through, so going through by hand is just not an option. If anyone can give me some pointers to more specifically locate erroneous lines, or if you can give me some tips on what syntax to look out for during the migration, I'd really appreciate it. -- David VanKirk ___ 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 )
Re: [Zope] Error Tracing in Zope 2.6
- Original Message - From: David VanKirk [EMAIL PROTECTED] To: Zope Mailing List zope@zope.org Sent: Thursday, February 22, 2007 5:10 PM Subject: [Zope] Error Tracing in Zope 2.6 Can anyone give me some pointers on tracing errors in Zope 2.6? I'm already using the DTML var error-tb or whatever it is. And that can be helpful at times. But I was wondering if there's some other way to pinpoint which line in the DTML file is throwing the error. I'm moving my Zope setup from Linux to Windows and apparently there are some syntax that needs to change when migrating over (aside from my SQL command, since I'm going from Oracle to MS SQL Server). Some of these files are big, and there's a done of files to go through, so going through by hand is just not an option. If anyone can give me some pointers to more specifically locate erroneous lines, or if you can give me some tips on what syntax to look out for during the migration, I'd really appreciate it. The easiest thing to do is look in the error_log (ZMI, root folder). That will provide a full traceback for errors. If you can not determine the cause of the errors yourself, you can post specific questions/tracebacks. Jonathan ___ 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 )
Re: [Zope] Resizing an Image with PIL via a Form Upload
Thanks for everyone's help. I got it to work, here's the script. It creates 4 images, enhances them and adds some properties to the largest one. -- def makeImages(self, imagefile, newkeywords, newcaption): import PIL.Image, ImageEnhance, ImageFilter import PIL from StringIO import StringIO import os.path import datetime import time # create the data in a new PIL Image. image=PIL.Image.open(imagefile) image=image.convert('RGB') image=image.filter(ImageFilter.SHARPEN) image=image.resize((640, 480), PIL.Image.ANTIALIAS) image2=image.resize((320, 240), PIL.Image.ANTIALIAS) image3=image.resize((160, 120), PIL.Image.ANTIALIAS) image4=image.resize((80, 60), PIL.Image.ANTIALIAS) # get the data in memory. newimage_file=StringIO() image.save(newimage_file, JPEG) newimage_file.seek(0) newimage_file2=StringIO() image2.save(newimage_file2, JPEG) newimage_file2.seek(0) newimage_file3=StringIO() image3.save(newimage_file3, JPEG) newimage_file3.seek(0) newimage_file4=StringIO() image4.save(newimage_file4, JPEG) newimage_file4.seek(0) # create an id for the image now = datetime.datetime.now() newimageid=now.strftime('%Y%m%d%H%M%S') newimage_id=newimageid + '-640.jpg' newimage_id2=newimageid + '-320.jpg' newimage_id3=newimageid + '-160.jpg' newimage_id4=newimageid + '-80.jpg' # if there's an old image, delete it if newimage_id in self.objectIds(): self.manage_delObjects([newimage_id]) if newimage_id2 in self.objectIds(): self.manage_delObjects([newimage_id2]) if newimage_id3 in self.objectIds(): self.manage_delObjects([newimage_id3]) if newimage_id4 in self.objectIds(): self.manage_delObjects([newimage_id4]) # create the Zope image object for the new image self.manage_addProduct['OFSP'].manage_addImage(newimage_id, newimage_file, '') self.manage_addProduct['OFSP'].manage_addImage(newimage_id2, newimage_file2, '') self.manage_addProduct['OFSP'].manage_addImage(newimage_id3, newimage_file3, '') self.manage_addProduct['OFSP'].manage_addImage(newimage_id4, newimage_file4, '') # now find the new zope object so we can modify # its properties. newimage_image=getattr(self, newimage_id) newimage_image.manage_addProperty('keywords', '', 'string') newimage_image.manage_addProperty('caption', '', 'string') newimage_image.manage_addProperty('imageid', '', 'string') newimage_image.manage_changeProperties(keywords=newkeywords, caption=newcaption, imageid=newimageid) newimage_image2=getattr(self, newimage_id2) newimage_image2.manage_addProperty('imagefile2', '', 'string') newimage_image3=getattr(self, newimage_id3) newimage_image3.manage_addProperty('imagefile3', '', 'string') newimage_image4=getattr(self, newimage_id4) newimage_image4.manage_addProperty('imagefile4', '', 'string') -- On Feb 22, 2007, at 4:11 PM, Andrew Langmead wrote: On Feb 22, 2007, at 1:29 PM, Tom Von Lahndorff wrote: 8original_image=getattr(self, original_id) 9original_file=StringIO(str(original_image.data)) [and later] AttributeError: DSCF0004.jpg I think your line numbers are off by one, because I'd think it is the getattr that would be causing the Attribute Error (at most, line 9 could give an attribute error for something called data. Zope turns file upload objects into ZPublisher.HTTPRequest.FileUpload instances. and pass them to your method. FileUpload instances have an interface similar to python file objects, you can .read(), .seek(), .close() or do whatever you want to them and might not need to wrap the contents into a StringIO object first. (your trying to fetch the file as an attribute of self seems to imply that you think the form data is already uploaded into zope and is an Image object in a folder. It isn't there yet, and won't be unless you store it there.) I think if you removed lines 8 and 9 (by your numbering) and renamed the second argument to the method to original_file, things would work as you need: 1 def makeImages(self, original_file): 2 3import PIL.Image 4import PIL 5import os.path 6 ... ___ 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 )
Re: [Zope-DB] ZMySQLDA on solaris10
Comunian Alessandro wrote at 2007-2-22 12:30 +0100: ... import _mysql ImportError: ld.so.1: python: fatal: relocation error: file /home/wwhypda/plone/instance_test01/lib/python/_mysql.so: symbol mysql_errno: referenced symbol not found You MySQL-python does not fit with your MySQL version: MySQL-python (that is _mysql.so) expects the MySQL client library to define a symbol mysql_errno and either the client library is not linked at all to _mysql or it does not define the symbol. Check whether you can find a more up to date version of MySQL-python (one that promissed to work with your MySQL version). -- Dieter ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db