[Zope-dev] Python API? - handling file properties

Chimezie Thomas-Ogbuji chimezie@ogbuji.net
Tue, 28 Mar 2000 15:27:39 -0700


I'm trying to put up a page where company documents can be retrieved and
added by users.  I created a Zope Product and ZClass (CompanyObjects and
CompanyDocs respectively).  I inherited the CompanyDocs ZClass from the
File Class, however I'm not sure how to access the File functionality
via python.  I want to create a python method that sets the Document
properties and file from a form, however I don't know how to
update/upload the file passed in from the form into the CompanyDocs
ZClass.  This is the python method (using the "Adding A ZClass
programatically HOWTO" as a start)



def addACompanyDoc(self, id, file, title, author, desc, REQUEST=None):
""" """
# Get the actual destination object, using the this()
# method, to be sure we get it in the right context..
self=self.this()

# Create the new instance
newob=self.Control_Panel.Products.CompanyObjects.CompanyDoc(id)
newob.id=id

#change properties using the example in the "Using Z Class Instances"
newob.manage_changeProperties({
	'title':title
	'author':author
	'description': desc
})

# Add the new instance to the target object
self._setObject(id, newob)

How do I change the object content to the file passed in from the form?
Is there a more elegant solution that this?  The PDFile example was
helpful however it assumes you are adding the file via the Zope
management interface, not using External methods and python.

Also is there a python module file that defines all the methods that can
be called on Zope objects (the self argument to all python external
methods)? I'm pretty sure its not ZClass.py.  This would be infinitely
helful since there is really no good resource for the Zope Python API
(besides the HOWTOS)

Chimezie Ogbuji