Hello Zope users! Maybe you can help me with the following scenario: I'm developing a community site in zope. I don't use CMF or Plone, since I wouldn't be using much of the functionality anyway and therefore would only slow down the site with it. All user data is stored in MySQL. exUserFolder is used for authentication. Registered users should be able to upload photos to my site. These photos may be viewed by other registered users, but no anonymous users (no anonymous access to photos allowed). Now, how do I do this best? Is there any "best practice" on how to give each user a personal gallery? Creating a single folder for every user, and putting images in there for every category? Or should I put all in one big folder, maybe assigning matching photos to users via a table in the database with user-filename columns? There may be around 30 000 users and 200 000 photos. I thought of using the "Photo Folder" product, maybe setting its properties to "external filesystem", so the ZopeDB doesn't get too large. Anybody has experience on that one? Is it possible to use the external filesystem and still prevent anonymous access? Any help would be appreciated! Gregor
I would use the Photo product because it provides a well rounded interface to deal with picture resizing and thumbnail generation. There's no need to remove garbage code out of templates in order to seize it. Furthermore, as a Photo object is a regular Zope one, you can take advantage of Zope's security machinery, so the only thing you'll need to do is to set the 'view' permission of your photos container to "Authenticated". Also, you don't need to use a Photo Folder. Moreover, chances are that you'll need a (Zope2.7.X) mounted BTreesFolder2 one in order to storage thousands of photos, and a ZCatalog to catalog them and retrieve those that belongs to your current user. Be sure that you use the largest drive you can get, as you'll need twice the space of the largest expected size of your photos container, so you don't have any problem when you pack the database. Ausum ----- Original Message ----- From: Gregor Melhorn To: zope@zope.org Sent: Thursday, November 04, 2004 9:31 AM Subject: [Zope] Application Design and Photos Hello Zope users! Maybe you can help me with the following scenario: I'm developing a community site in zope. I don't use CMF or Plone, since I wouldn't be using much of the functionality anyway and therefore would only slow down the site with it. All user data is stored in MySQL. exUserFolder is used for authentication. Registered users should be able to upload photos to my site. These photos may be viewed by other registered users, but no anonymous users (no anonymous access to photos allowed). Now, how do I do this best? Is there any "best practice" on how to give each user a personal gallery? Creating a single folder for every user, and putting images in there for every category? Or should I put all in one big folder, maybe assigning matching photos to users via a table in the database with user-filename columns? There may be around 30 000 users and 200 000 photos. I thought of using the "Photo Folder" product, maybe setting its properties to "external filesystem", so the ZopeDB doesn't get too large. Anybody has experience on that one? Is it possible to use the external filesystem and still prevent anonymous access? Any help would be appreciated! Gregor
On Thursday 04 November 2004 08:31 am, Gregor Melhorn wrote:
I'm developing a community site in zope. I don't use CMF or Plone, since I wouldn't be using much of the functionality anyway and therefore would only slow down the site with it. All user data is stored in MySQL. exUserFolder is used for authentication.
Registered users should be able to upload photos to my site. These photos may be viewed by other registered users, but no anonymous users (no anonymous access to photos allowed).
Is there any "best practice" on how to give each user a personal gallery?
Creating a single folder for every user,
I'd recommend that as the simplest, most obvious solution. And as it's best practice to have your access scripts filter by meta-type anyway, there's no particular reason not to let this folder hold other data as well as images. You might find my VarImage product useful for the actual images: http://sourceforge.net/projects/narya-project (package "VarImage") Release 2.4 does referrer blocking and some other useful tricks, as well as its primary function, which is rendering thumbnails and other special effects. It's quite trivial to script a photogallery with it, as I've done on my own sites. Your permissions requirement is straightforward Zope permissions code, though, no special behavior or objects are required -- just regular Zope images and folders will do that. Cheers, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com
I put some 'full-size' pictures on the web myself recently, varying in size from 1 to 2Mb! So maybe a Product is a good idea if you want to auto-resize to some reasonable maximum. Some other thoughts: My helpers tell me it is a lot easier to back up a file system with a lot of small files than a bloated ZODB. So put the images in the filesystem rather than the ZODB or MySQL database. It is surprisingly easy to write an Extension to stow files in the file system, like this: from os import remove def putDocument(filename, content): file = '/path/to/your/storage/place/'+filename output = open(file, 'w') output.write(content) output.close() def getDocument(filename): file = '/path/to/your/storage/place/'+filename input = open(file, 'r') content = input.read() input.close() return content def deleteDocument(filename): file = '/path/to/your/storage/place/'+filename remove(file) I just base a filename on a MySQL auto_increment field, and fetch like this: for result in context.getDocumentSQL(): (type, encoding) = context.getMimeType(result.Filename) theFilename = 'DA%s' % context.REQUEST.SerialNo context.REQUEST.RESPONSE.setHeader('Content-Type', type) return context.getDocument(theFilename) and getMimeType is another Extension: import mimetypes def getMimeType(filename): return mimetypes.guess_type(filename) So this is generic, handling jpg, pdf, etc. Typically, images are downloaded after the page, and I doubt whether you want to trigger login to fetch an image - so don't put the image link in a page if the user is not logged in, and put some code in the fetch script to send a simple placeholder image if the user is not logged in. Cliff Gregor Melhorn wrote:
Hello Zope users!
Maybe you can help me with the following scenario:
I'm developing a community site in zope. I don't use CMF or Plone, since I wouldn't be using much of the functionality anyway and therefore would only slow down the site with it. All user data is stored in MySQL. exUserFolder is used for authentication.
Registered users should be able to upload photos to my site. These photos may be viewed by other registered users, but no anonymous users (no anonymous access to photos allowed).
Now, how do I do this best?
Is there any "best practice" on how to give each user a personal gallery?
Creating a single folder for every user, and putting images in there for every category? Or should I put all in one big folder, maybe assigning matching photos to users via a table in the database with user-filename columns?
There may be around 30 000 users and 200 000 photos. I thought of using the "Photo Folder" product, maybe setting its properties to "external filesystem", so the ZopeDB doesn't get too large. Anybody has experience on that one? Is it possible to use the external filesystem and still prevent anonymous access?
Any help would be appreciated!
Gregor
------------------------------------------------------------------------
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (4)
-
Ausum Studio -
Cliff Ford -
Gregor Melhorn -
Terry Hancock