Brendon Grunewald wrote:
I want to use Zope to offer registered visitors to my site a little free webspace on the site. Since I use hosting service that restricts and charges me for space, I would like to restrict the size that their zope folders can consume.
Hence: Is there any simple way of limiting the amount of space that a folder is allowed to consume including its subfolders? Alternatively, is there anyway of checking how much space a folder with subfolders consumes?
I set something up like this for myself at imeme.net (minus the file limits) its basically just a simple zodb based remote file storage for friends. basically to do it you can't let your visitors have access to your manage screens. example implementation. create a folder called filesystem stick all your adding and managing methods in filesystem add a size limit property to filesystem for each user create a folder under filesystem. that folder should probably have a property called current_size basically you're going to have forms for people uploading a file. on the page where you would do the manage_addFile stuff you're going to implement the logic. check size of the file with _.len(file) on the form submit page and add to current_size see if its above the limit. if it is don't add tell the user why. if it isn't add it update the current_size on the directory. voila. here's some sample code which does the basics of getting file info without the management logic to get you started. it pretty prints a table of file info. <table align="center" border="1"> <tr><th colspan="4"><dtml-var id> Directory Contents</th></tr> <tr><td>File Name</td><td>Type</td><td>Size</td><td>TimeStamp</td></tr> <dtml-in "objectItems(['File', 'Image'])"> <dtml-with sequence-item> <dtml-call "REQUEST.set('DirectorySize', DirectorySize+size)"> <tr> <td><a href="<dtml-var sequence-key>"><dtml-var sequence-key></a></td> <td><dtml-var content_type></td> <td><dtml-var size></td> <td><dtml-var bobobase_modification_time></td> </tr> </dtml-with> </dtml-in> <dtml-call "REQUEST.set('DirectorySize', DirectorySize/1000)"> <tr><td colspan="4">Total Directory Size: <dtml-var DirectorySize>K</td></tr> </table>
Regards, Brendon ------------------ 70South: the No.1 source for Antarcticles. For the latest news and views on Antarctica visit : http://www.70south.com
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )