i'm attempting to learn zope3, beginning with grok. i''ve managed to get
most of the functionality i need, but don't have a complete understanding of
the interworkings of the system. essentially i'm writing a small app that i
use to control mpd (music player deamon) by way of libmpdclient.py.
currently i'm held back by the inability to upload a file to the filesystem.
i understand that ZOBD.blob completes this funcionality. zope.conf is
configured for blobs, but i fail to understand how to save a blob to the
directory configured there. i've read this:
i've also looked the doc tests that come with z3c.blobfile. i've also found
information which states that zope.file (not zope.app.file) includes blob
funcionality. nonetheless, i've not been able to make it work. hopefully a
bit of code will help clarify the problem. the following works to save a
file to the zodb. i've tried many variations using blobfile and extfile
from zope import interface, schema
from megrok.form.fields import File
name = schema.TextLine(title=u"Name")
data = File(title=u"Audio file")
def __init__(self, data, name):
self.data = data
self.name = name
form_fields = grok.AutoFields(Audio)
def add(self, **data):
obj = Audio(**data)
self.context[name] = obj
this setup works to save a file to the zodb.
i've tried changing "from megrok.form.fields import File" to "from
z3c.blobfile import File". i've also tried having IAudio subclass IBlobFile,
to no avail.
in the archives of this list i've also found some references to z3c.extfile
and have tried subclassing it instead. can anyone give specific pointers on
how to modify the above code so that it stores files on the filesystem?
thanks for any and all help,
Zope3-users mailing list