[Zope3-dev] ZODB with Blob support

2006-08-10 Thread Luis De la Parra

Hi,

sorry for the delay, but I was almost 3 weeks without access to my
computer...
In case someone is interested, this is what I did to get zope.fle to work
with Blobs...   like I said:  it seems to work ok, but deleting a file
leaves the blob object lying on the filesystem (even after packing the
DB) -- oh, and I still haven't figured out how to make the security
declarations for the file handle, so for the test I just skipped security
altogether:

1) Modify the externals to use the BLOB-branch of ZODB:
2) put zope.file and zope.mimetypes in my instance, and replace the stringio 
in zope.file with a Blob

regards. luis



patch 1:  Zope3/file_blob_Zope3.patch:

Property changes on: src
___
Name: svn:externals
   - docutils       svn://svn.zope.org/repos/main/docutils/tags/0.4.0
ZConfig        svn://svn.zope.org/repos/main/ZConfig/trunk/ZConfig
BTrees         -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/BTrees
persistent     -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/persistent
ThreadedAsync  -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ThreadedAsync
transaction    -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/transaction
ZEO            -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ZEO
ZODB           -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ZODB
twisted        -r 15340 
svn://svn.twistedmatrix.com/svn/Twisted/branches/releases/2.1.x/twisted
zdaemon        -r 40792 
svn://svn.zope.org/repos/main/zdaemon/trunk/src/zdaemon

   + docutils       svn://svn.zope.org/repos/main/docutils/tags/0.4.0
ZConfig        svn://svn.zope.org/repos/main/ZConfig/trunk/ZConfig
BTrees         -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/BTrees
persistent     -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/persistent
ThreadedAsync  -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ThreadedAsync
transaction    -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/transaction
ZEO            -r 69196 
svn://svn.zope.org/repos/main/ZODB/branches/3.7/src/ZEO
ZODB           
svn://svn.zope.org/repos/main/ZODB/tags/blob-technical-preview/src/ZODB
twisted        -r 15340 
svn://svn.twistedmatrix.com/svn/Twisted/branches/releases/2.1.x/twisted
zdaemon        -r 40792 
svn://svn.zope.org/repos/main/zdaemon/trunk/src/zdaemon


Index: zope.conf.in
===
--- zope.conf.in(revision 69370)
+++ zope.conf.in(working copy)
@@ -46,10 +46,20 @@
 # /sshserver
 
 # Standard Filestorage
+#zodb
+#  filestorage
+#    path Data.fs
+#  /filestorage
+#/zodb
+
+# Filestorge with Blob support
 zodb
-  filestorage
-    path Data.fs
-  /filestorage
+  blobstorage
+     blob-dir blobs
+     filestorage
+        path Data.fs
+     /filestorage
+  /blobstorage
 /zodb
 
 accesslog


patch 2 :  Zope3/src/zope/file/file_blob.patch

Index: configure.zcml
===
--- configure.zcml  (revision 69216)
+++ configure.zcml  (working copy)
@@ -27,6 +27,7 @@
 
   !-- set up permissions for the accessor objects --
 
+!--  FIXME: Do we still need this ?
   class class=.file.Reader
     require
         permission=zope.View
@@ -44,7 +45,14 @@
         attributes=close flush write
         /
   /class
-
+  *** / FIXME --  
+  
+  !-- this is not working.. :-(   --
+  class class=file 
+    allow attributes=read /
+    require
+        permission=zope.View attributes=write writelines truncate /
+  /class
   !-- Subscriber to update the mimeType field on content-type
        changes. --
   subscriber
Index: download.py
===
--- download.py (revision 69216)
+++ download.py (working copy)
@@ -23,6 +23,10 @@
 import zope.publisher.http
 
 
+#FIXME: this is bad.. but I haven't found a way to make security
declarations 
on the file handle object (inheriting from a normal python file object).. 
so for this test we just turn off security all together  =(
+from zope.security.proxy import removeSecurityProxy
+
+
 class Download(object):
 
     zope.interface.implements(
@@ -87,7 +91,9 @@
         # application/database; ZODB BLOBs will provide a equivalent
         # feature once available.
         #
-        data = context.open(rb).read()
+        file = context.open(rb)
+        file = removeSecurityProxy(file) #FIXME
+        data = file.read()
         self.headers += (Content-Length, str(context.size)),
         self.body = bodyIterator(cStringIO.StringIO(data))
 
Index: file.py
===
--- file.py (revision 69216)
+++ file.py (working copy)
@@ -15,8 +15,13 @@
 
 __docformat__ = reStructuredText
 
-import cStringIO
+#import os
+#import stat
+from ZODB.Blobs.Blob import Blob
 

Re: [Zope3-dev] ZODB with Blob support

2006-07-23 Thread Christian Theune

Hi,

Luis De la Parra wrote:

Hello,

has anyone tried the zodb with blob support in zope3 ?
I just was wondering if there are any plans to support it in the (near)
future.


There might be, as soon as we get it into the main line of ZODB. Chris 
and I are working on this every now and then. Due to some feedback we 
got recently, we'll integrate the blob branch into main ZODB in 
approximately Mid-August.



Today I changed the externals in my checkout to point to the blob-branch and
replaced the stringio in zope.file with a blob object, and it really
(almost) worked out of the box. The only things I had to do was to add some
removeSecurityProxys in the upload/download views because I couldn't figure
out how to make security declarations on the blob/file object, and replace
the size attribute with a property to get the size from the blob object.

the only thing that is still not working right now, is that deleting file
objects in the zodb leaves the files in the blob directory lying around,
and packing the database doesnt remove them either..


Humm. That's either a bug or a problem in the pattern of how to use 
blobs. I'll try to look into it. Do you think you can check your changes 
on Zope 3 into a branch so I can have a look at it? Alternatively I can 
use a patch.


Christian

--
gocept gmbh  co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - [EMAIL PROTECTED] - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development

___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



[Zope3-dev] ZODB with Blob support

2006-07-21 Thread Luis De la Parra

Hello,

has anyone tried the zodb with blob support in zope3 ?
I just was wondering if there are any plans to support it in the (near)
future.

Today I changed the externals in my checkout to point to the blob-branch and
replaced the stringio in zope.file with a blob object, and it really
(almost) worked out of the box. The only things I had to do was to add some
removeSecurityProxys in the upload/download views because I couldn't figure
out how to make security declarations on the blob/file object, and replace
the size attribute with a property to get the size from the blob object.

the only thing that is still not working right now, is that deleting file
objects in the zodb leaves the files in the blob directory lying around,
and packing the database doesnt remove them either..

regards.
luis


___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com