[Grok-dev] Re: save file to filesystem

Dirceu Pereira Tiegs dirceutiegs at gmail.com
Thu Feb 28 17:04:05 EST 2008


Hey,

Sorry about the delay. :-(

On Thu, Feb 28, 2008 at 9:43 AM, Martijn Faassen <faassen at startifact.com> wrote:
>  I don't think we can reuse the IBlobFile interface here. We are
>  talking about the interface marking
>  the *field*, and we can't reuse the interface marking the file for this.
>
>  I'm also not sure whether we should be subclassing schema.File for
>  this, though not sure we shouldn't
>  either. What does namedfile do? We should follow its pattern.

+1

collective.namedfile uses this:

from zope.schema import Field
from interfaces import INamedFile

class NamedFile(Field):
    """A NamedFile field
    """
    implements(INamedFile)

>  >  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):
>  >     implements(INamedFile)
>  >
>  >     def __init__(self, data='', contentType='', filename=None):
>  >         File.__init__(self, data, contentType)
>  >         self.filename=filename
>
>  Yes, that looks right to me.

+1.

>  It's basically a subclass of the widget in namedfile, that overrides
>  the one method that
>  instantiates the NamedFile object and instead you instantiate your new
>  BlobNamedFile object.
>  You also need to hook the widget up to the field, along the lines of
>  what happens in BlobNamedFile.

+1

>  Thinking about it, it might make the most sense to get the namedfile
>  package adjusted for blob support
>  first. You need to discuss that with the creators - there might be
>  dependency issues where the ZODB that
>  namedfile is usually used with is not modern enough to support blobs.
>  If you need help discussing things with the
>  people who maintain that package please let me know (just cc me in on
>  any email discussion).

Actually including z3c.blobfile as a dependency of
collective.namedfile will cause the installation of ZODB 3.8.
collective.namedfile is primarly used by Plone 3, so I don't know if
it's a good idea.

>  After it's integrated, we can do a very easy inclusion in megrok.form.
>
>  I hope Dirceu also joins in the thread and helps you!

I'm here :-)! Sorry again about the delay.

Regards,
-- 
Dirceu Pereira Tiegs
Weimar Consultoria

Hospedagem Plone, Zope e Python
http://www.pytown.com


More information about the Grok-dev mailing list