[Zope3-dev] Important IFile bug!

Roger Ineichen dev at projekt01.ch
Mon Jan 17 10:50:29 EST 2005


Ok.

> -----Original Message-----
> From: zope3-dev-bounces+dev=projekt01.ch at zope.org 
> [mailto:zope3-dev-bounces+dev=projekt01.ch at zope.org] On 
> Behalf Of Jim Fulton
> Sent: Monday, January 17, 2005 4:00 PM
> To: dev at projekt01.ch
> Cc: zope3-dev at zope.org
> Subject: Re: [Zope3-dev] Important IFile bug!
> 
> Roger Ineichen wrote:
> > Ok I see...
> > 
> > 
> >>-----Original Message-----
> >>From: Jim Fulton [mailto:jim at zope.com] 
> >>Sent: Monday, January 17, 2005 12:58 PM
> >>To: dev at projekt01.ch
> >>Cc: zope3-dev at zope.org
> >>Subject: Re: [Zope3-dev] Important IFile bug!
> >>
> >>Roger Ineichen wrote:
> >>
> >>> Hi jim
> >>>
> >>>
> >>>>-----Original Message-----
> >>>>From: Jim Fulton [mailto:jim at zope.com] 
> >>>>Sent: Friday, January 14, 2005 5:30 PM
> >>>>To: dev at projekt01.ch
> >>>>Cc: zope3-dev at zope.org
> >>>>Subject: Re: [Zope3-dev] Important IFile bug!
> >>>>
> >>>>Roger Ineichen wrote:
> >>>>
> >>>>...
> >>>>
> >>>>
> >>>>
> >>>>>Ok, what can I do?
> >>>>>
> >>>>>Should I implement a IData field and enhance this field?
> >>>>
> >>>>I think you should define an IMime schema that defines methods
> >>>>to get and set the data. I suggest that this should be a
> >>>>file-like interface, with, at least, read and write.
> >>>>It should have a mime-type attribute and an encoding
> >>>>attribute, for use with text.
> >>>>
> >>>>Then you should define a mine field (IMImeField/MimeField)
> >>>>for data with this interface.
> >>>
> >>>
> >>>This whould mean we change the IFile implementation?
> >>
> >>IFile should be changes to use a mime field.
> >>
> >>
> >>>Or can we Implement IMime with the attribute
> >>>contentType?
> >>
> >>We should define a mime data type and provide a field
> >>and widget to support it.
> >>
> >>
> >>>like:
> >>>
> >>>class IMime(Interface):
> >>>
> >>>  contentType = BytesLine(
> >>>        title = _(u'Content Type'),
> >>>        description=_(u'[...].'),
> >>>        default='',
> >>>        required=False,
> >>>        missing_value=''
> >>>        )
> >>>
> >>>class IFile(IIMime):
> >>>
> >>>  data = FileData(*) (
> >>>        title=_(u'Data'),
> >>>        description=_(u'[...]'),
> >>>        default='',
> >>>        missing_value='',
> >>>        required=False,
> >>>        )
> >>>
> >>>(*)The field FileData will replace the 
> >>>Bytes field and validate Bytes and FileChunk.
> >>
> >>No
> >>
> >>class IMime(Interface):
> >>
> >>     data = ...
> >>
> >>     contentType = ...
> >>
> >>     encoding = ...
> >>
> >>class IFile(Interface):
> >>
> >>    def open(mode='r'):
> >>        # return a file-like object for reading or updating the
> >>        # file value
> >>
> >>    # For backward compatibility, a deprecated data attr
> >>    data = ... # as is now
> 
> Waaaaaaa, I got that wrong! Waaaaa waaaa waaaaa.
> (I edited the wrong interface.)
> 
> Sorry, This should have been:
> 
> class IMime(Interface):
> 
>       def open(mode='r'):
>          # return a file-like object for reading or updating the
>          # file value
> 
>       contentType = ...
> 
>       encoding = ...
> 
> class IFile(Interface):
> 
>      contents = Mime(...)
> 
>      # For backward compatibility, a deprecated data attr
>      data = ... # as is now
> 
> 
> 
> > 
> > 
> > And the class File looks like:
> > 
> > Class File(Persistent):
> > 
> >   implements(IFile, IMime)
> > 
> >   def __init__(self, data='', contentType='', encoding=''):
> >       self.data = data
> >       self.contentType = contentType
> >       self.encoding = encoding
> 
> 
> No:
> 
>      implements(IFile)
> 
>      def __init__(self, contents):
>          self.contents = contents
> 
>      def _getData(self):
> 	return self.contents.open().read()
> 
>      def _setData(self, v):
> 	self.contents.open('w').write(v)
> 
> > 
> > 
> > or:
> > 
> > Class Mime(Persistent):
> > 
> >   implements(IMime)
> > 
> >   def __init__(self, data='', contentType='', encoding=''):
> >       self.data = File(data)
> >       self.contentType = contentType
> >       self.encoding = encoding
> 
> Right, you need this, with the above.  You also need to
> provide an open method and a MimeFile object that has read
> and write methods for updating the mome object.  The mime
> object does the chunking that we do now.
> 
> > 
> > 
> > Can you give me some hints about what stores what?
> 
> Mime objects store mime bodies, content types and encoding.
> Note that the mime bodies should use the sort of chunking
> tricks we have now.  File objects should hold mime objects.
> We also need mime fields and widgets.
> 
> Sorry for my confused previous message. My interfaces had
> attributes and I realized we needed a file-like API
> for the mime data to handle large files.  I was in a
> bit of a hurry and edited the wrong interface.
> 
> Jim

Thanks for your advise, I will try to implement it this week.

Regards
Roger Ineichen

Projekt01 GmbH
www.projekt01.ch
_____________________________
END OF MESSAGE  



More information about the Zope3-dev mailing list