manage_addImage from python
Hi, Inside python code I tried using : self.manage_addImage('newid','localfs/image.gif',content_type='image/gif') the "newid" object is created but its content is the STRING "localfs/image.gif" where I expected the CONTENT of the file localfs/image.gif what do I miss ? -- _/ _/ _/_/_/ _/_/ Michel.Vayssade@UTC.fr Service Informatique _/ _/ _/ _/ T:33/0-3.44.23.49.24 Universite de Technologie _/ _/ _/ _/ F:33/0-3.44.23.46.77 BP 20.529 60205 Compiegne _/_/ _/ _/_/ _ mv@utc.fr __/www.utc.fr/~vayssade____ France
On Mon, Oct 22, 2001 at 12:11:34PM +0200, Michel Vayssade wrote:
Inside python code I tried using : self.manage_addImage('newid','localfs/image.gif',content_type='image/gif')
the "newid" object is created but its content is the STRING "localfs/image.gif" where I expected the CONTENT of the file localfs/image.gif
what do I miss ?
You missed exactly this - content :) Put the content of the object instead of its name as the second parameter. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
On Mon, 22 Oct 2001, Oleg Broytmann wrote:
On Mon, Oct 22, 2001 at 12:11:34PM +0200, Michel Vayssade wrote:
Inside python code I tried using : self.manage_addImage('newid','localfs/image.gif',content_type='image/gif')
the "newid" object is created but its content is the STRING "localfs/image.gif" where I expected the CONTENT of the file localfs/image.gif
what do I miss ? You missed exactly this - content :) Put the content of the object instead of its name as the second parameter.
right ! ok here is the code that work : file = "filesystem/myimage.gif" ffi = open(file, 'r') self.manage_addImage('imageid',ffi,content_type='image/gif') ffi.close() and OK but now : trying the "same" trick with : name = 'myfile' file = name+'.py' # the file is Extentions/myfile.py ffi = open(file, 'r') self.manage_addExternalMethod (name,name,ffi,'mymethod') ffi.close() I got : Error Type: AttributeError Error Value: manage_addExternalMethod I have done: from Products.ExternalMethod.ExternalMethod import manage_addExternalMethod I tried a lot of ways calling this method, but none work .. Probably somebody has already get it work ? thanks the list is very helpfull at least its good for morale seeing you are not alone in the dark :) -- _/ _/ _/_/_/ _/_/ Michel.Vayssade@UTC.fr Service Informatique _/ _/ _/ _/ T:33/0-3.44.23.49.24 Universite de Technologie _/ _/ _/ _/ F:33/0-3.44.23.46.77 BP 20.529 60205 Compiegne _/_/ _/ _/_/ _ mv@utc.fr __/www.utc.fr/~vayssade____ France
manage_addExternalMethod is not called on "self". the attribute error happens because self does not know this method. you also don't need to read in the contents and pass them into the constructor for external methods, you just need the module and the function names. if "self" is the container you want that external method to go into you call it like this:: manage_addExternalMethod ( self, name, name, 'myfile', 'mymethod' ) jens On Tuesday, October 23, 2001, at 05:30 , Michel Vayssade wrote:
On Mon, 22 Oct 2001, Oleg Broytmann wrote:
On Mon, Oct 22, 2001 at 12:11:34PM +0200, Michel Vayssade wrote:
Inside python code I tried using : self.manage_addImage('newid','localfs/image.gif',content_type='image/gif' )
the "newid" object is created but its content is the STRING "localfs/image.gif" where I expected the CONTENT of the file localfs/image.gif
what do I miss ? You missed exactly this - content :) Put the content of the object instead of its name as the second parameter.
right ! ok here is the code that work :
file = "filesystem/myimage.gif" ffi = open(file, 'r') self.manage_addImage('imageid',ffi,content_type='image/gif') ffi.close() and OK
but now : trying the "same" trick with :
name = 'myfile' file = name+'.py' # the file is Extentions/myfile.py ffi = open(file, 'r') self.manage_addExternalMethod (name,name,ffi,'mymethod') ffi.close() I got : Error Type: AttributeError Error Value: manage_addExternalMethod
I have done: from Products.ExternalMethod.ExternalMethod import manage_addExternalMethod
I tried a lot of ways calling this method, but none work .. Probably somebody has already get it work ?
thanks
the list is very helpfull at least its good for morale seeing you are not alone in the dark :)
-- _/ _/ _/_/_/ _/_/ Michel.Vayssade@UTC.fr Service Informatique _/ _/ _/ _/ T:33/0-3.44.23.49.24 Universite de Technologie _/ _/ _/ _/ F:33/0-3.44.23.46.77 BP 20.529 60205 Compiegne _/_/ _/ _/_/ _ mv@utc.fr __/www.utc.fr/~vayssade____ France
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Jens Vagelpohl -
Michel Vayssade -
Oleg Broytmann