[Zope-dev] Storing part of an object on the file system

Arno Gross arno.gross@consotec.de
Fri, 9 Feb 2001 07:05:21 -0100


I had a similar problem. I'm using ExtImage, but I need some extensions for it.
Because I using a RDMBS (currently MySQL) I wanted to have all the meta data
in my RDMBS.  
For all my objects there is normally a 'InsertMethod'. This can be a ZSQL
method (if just MySQL is involved) or it can be a DTML method.
For inserting an Picture object I have two steps in my DMTL InsertMethod:
<dtml-let ret="manage_addProduct['ExtFile'].manage_addExtImage(title=_['PICTURE.TITLE'], 
       descr=_['PICTURE.DESCR'],                                                
       file=_['PICTURE.FILE'],                                         
       content_type='',                                         
       create_prev=create_prev,                                 
       maxx=maxx,                                       
       maxy=maxy,                                             
       ratio=ratio,                                                 
       permission_check=permission_check,                               
       REQUEST=REQUEST)">                             
<dtml-if expr="_.string.find(ret,'success') != -1">
   <dtml-call "REQUEST.set('PICTURE.PIC_NAME_ID',_.string.strip(getImageName(message=ret)))">
   <dtml-call "REQUEST.set('PICTURE.TITLE',_['PICTURE.TITLE'])">
   <dtml-call PictureInsertMethod>  // this is a ZSQL Method
   <dtml-call "RESPONSE.redirect('SearchResult?GALERIE.GALERIE_ID='+ _.str(_['GALERIE.GALERIE_ID']))">
  <dtml-else>
    <dtml-var ret>
  </dtml-if>
</dtml-let> 

Okay, it's not transaction safe for now, but  that's is acceptable in my
environment. Of course there can be some improvements.
Hint: I extended ExtImage for dynamic resizing. A preview is computed on the
fly. Maybe there is a need for this. I will send the extension to Gregor.

Best regards
  Arno Gross, arno.gross@consotec.de

On Thu, 08 Feb 2001, you wrote:
> Ok whack idea #34... Well sort of, the idea was sparked by ExtFile (yes its
> all his fault honest). We want to have files on the file system for many
> reasons which I won't go into now, just take it for granted. But we also
> want some of the objects information to be in the standard data.fs, so we
> can catalog it use acquisition provide a simple interface to it and so on.
> So far you are saying thats ExtFile and you are right.
> 
> But we want to extend it to any object anywhere, instead of storing the data
> attribute in the object and pickling it in the ZODB I want to be able to
> store the data attribute on the file system. This gives us loads of
> advantages we also thought this would be extremely useful to other people.
> We've bounced around ideas on how to do this and here the only two so far:
> 
> -    we could overload the data attribute with a class that on Pickling into
> the ZODB instead writes it on to the filesystem...
> -    we could in the ZODB put a hack to say if pickling something with so
> and so attribute do this instead...
> 
> I feel like this something I should just not be doing, but it would be great
> if I could get it work...
> 
> --
>   Andy McKay.
> 
> 
> 
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )