[Grok-dev] Re: save file to filesystem

kev mictlan.tecutli.0 at gmail.com
Wed Feb 27 23:38:31 EST 2008

ok so trying to understand how to set this up

> * a special 'BlobFile' field that stores the information in the ZODB

¿seems like a simple addition to megrok.form.fields? something like:

from z3c.blobfile.interfaces import IBlobFile

 class BlobFile(schema.File):

> * probably a BlobNamedFile storage object that subclasses from the
> existing blobfile File object, but adds a filename (which the named
> file bits need)

i took a look in collective.namedfile and saw how NamedFile is set up in
file.py. copying that to blobfile.py and renaming a few things leaves me
with this:

from zope.interface import implements
from z3c.blobfile import File
from interfaces import INamedFile

class BlobNamedFile(File):

    def __init__(self, data='', contentType='', filename=None):
        File.__init__(self, data, contentType)

> * a new BlobNamedFileWidget widget  that subclasses NamedFileWidget
> and creates a BlobNamedFile instead of a
>   NamedFile. With a few tweaks to collective.namedfile we could make
> this widget subclass really minimal, just introducing
>   a file object factory in it or looking up some utility or adapter to
> configure it, but even without that, it's going to be short.

the widget part is a bit more intimidating :)

More information about the Grok-dev mailing list