Hello I have added an image through the form as - <form action="createimage" method="post" enctype="multipart/form-data"> <input type="text" name="id"> <input type="text" name="title"> <input type="file" name="file"> <input type="submit"> </form> this is processed by a script called "createimage" as in your forms method defined: ## Script (Python) "doupload" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=id, title, file ##title= ## context.Pictures.manage_addImage(id,title,file) ALTHOUGH - This does create the image in the Pictures folder. But the type in the context are 'application/octet-stream' and not as an image/jpeg as I need it to be. HOW can I identify the correct type for the file in the code please Many thanks Eva Rowe
I am busy converting a single Zope page to a Python cgi using the standalone ZPT implementation from sourceforge. Most of it seems to work just fine, but I am finding that although the Batch object is available and ported(?), it does not seem to work. Whenever I try to access batch/next/first with a short list, the renderer complains that next.first is not defined. The ZPT codes looks like this ... batch python:modules['ZUtils'].Batch(...); next batch/next ... <a tal:condition="next" Looking at Batch.py, it appears that Batch.next is actually a LazyNextBatch object, which only defines the Zope-specific __of__ operator. This makes sense, but I am rather surprised that standalone ZTP does not handle this correctly in Expressions.py Anyone have any suggestions about how to fix this? TIA, Best regards, Richard Wesley Co-President, Electric Fish, Inc. <http://www.electricfish.com/> (v) +1-206-493-1690x210 (f) +1-206-493-1697 (h) +1-206-632-4536 (m) +1-206-409-4536
Richard Wesley wrote:
I am busy converting a single Zope page to a Python cgi using the standalone ZPT implementation from sourceforge. Most of it seems to work just fine, but I am finding that although the Batch object is available and ported(?), it does not seem to work.
Whenever I try to access batch/next/first with a short list, the renderer complains that next.first is not defined. The ZPT codes looks like this
... batch python:modules['ZUtils'].Batch(...); next batch/next ...
<a tal:condition="next"
Looking at Batch.py, it appears that Batch.next is actually a LazyNextBatch object, which only defines the Zope-specific __of__ operator. This makes sense, but I am rather surprised that standalone ZTP does not handle this correctly in Expressions.py
Anyone have any suggestions about how to fix this?
You should probably pose the question to the folks responsible for that project. It may be a known problem, or they might know that they haven't gotten around to it yet. Or that it's impossible outside the context of Zope. I've never looked at it, so I can't say either way. --jcc
Hi The problem is the order of the parameters in method 'manage_addImage': Here is definition from Image.py: def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ .... So, it's: context.Pictures.manage_addImage(id, file, title) Dragos
Hello I have added an image through the form as -
<form action="createimage" method="post" enctype="multipart/form-data"> <input type="text" name="id"> <input type="text" name="title"> <input type="file" name="file"> <input type="submit"> </form>
this is processed by a script called "createimage" as in your forms method defined: ## Script (Python) "doupload" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=id, title, file ##title= ## context.Pictures.manage_addImage(id,title,file)
ALTHOUGH - This does create the image in the Pictures folder. But the type in the context are 'application/octet-stream' and not as an image/jpeg as I need it to be.
HOW can I identify the correct type for the file in the code please
Many thanks Eva Rowe
_______________________________________________ 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 )
participants (4)
-
Dragos Chirila -
Eva Rowe -
J Cameron Cooper -
Richard Wesley