WebFaction
Community site: login faq

I'm trying to use the ExtFile/ExtImage v2.0.2 (http://www.zope.org/Members/MacGregor/ExtFile) product in Zope v2.12.11 in order to allow me to store static files outside of Zope and access them through 'static urls' rather than through Zope itself. (Zope becomes bloated storing all files as binary within its own database and I need to find a way to serve / access files statically and reduce Zope's size which is now causing problems...)

I've run into a problem that I suspect is to do with Apache Virtual Hosting but I don't know what that is or how to locate and edit it... I don't really know what I'm looking for?

Here's the story so far...


I've successfully installed the ExtFile/ExtImage product (after having to edit its ExtFile.py and ExtImage.py files to update the location of a library it was failing to locate which must have moved since the product was written!)

changed :

   from webdav.WriteLockInterface import WriteLockInterface

to read :

   from webdav.interfaces import IWriteLock as WriteLockInterface

but this only sets zope up to store any ExtFile / ExtImage items outside the zope database in a static folder within the instance. Files are still served through Zope and I'd like to extend ExtFile / ExtImage to serve them statically via Apache following these instructions - http://zope.org/Members/shh/ExtFile/UsingStaticURLs - which states the following :

"... All we need to do is set the EXTFILE_STATIC_PATH environment variable in the <environment> section of etc/zope.conf"

I eventually located the zope.conf file (which has been moved in this version of zope since my last dabble with Zope's config settings to ../zinstance/parts/instance/etc/zope.conf) and updated the <environment> section using the vi editor to read

<environment>
EXTFILE_STATIC_PATH /static
... etc. etc.
</environment>

and restarted zope.

All seems to have gone to plan, only I'm unable to reach the ExtFile items via this new static url - zope just says 'resource not found'. I can see in the 'properties' view of the item that the 'file url' property is now attempting to reference the /static/ folder but I'm guessing that I also need to update the Apache Virtual Host to handle these redirects.

The instructions on - http://zope.org/Members/shh/ExtFile/UsingStaticURLs - showed an example vhost entry but I have no idea what this is or where to find it to update it?

<VirtualHost 10.0.0.1>
    RewriteEngine on
    RewriteRule ^/static/(.*)  /path/to/instance/static/reposit/$1 [L]
    RewriteRule ^/(.*)         http://localhost:8080/ ... [P,L]
  </VirtualHost>

If anyone else has tried to setup and us static urls for ExtFile items I'd greatly appreciate being pointed in the right direction please - or anyone else who knows what this Virtual Host is?

Many thanks in advance for any pointers... Ian.

asked 09 Jan '11, 10:50

urbanian
837
accept rate: 0%

Oh dear... there's a bigger problem than I realised...

I thought I'd successfully installed ExtFile but it doesn't work! I'm guessing that ExtFile is somehow failing to correctly code the files or is missing off some vital header/meta information or something. In other words, when I actually go to a file (an mp3 for example) I get the quicktime question mark rather than the play bar that I would usually see.

Here's an example : http://zopec.ianlivingstone.me.uk/esea_v1/test-extfiles/play-mp3

If anyone know's what's going wrong here please do let me know... Thanks, Ian.

(09 Jan '11, 11:11) urbanian

I was mistaken - the file is only broken when viewed via zope... I downloaded (via ftp) the physical file from the folder that ExtFile placed it in (with the Zope directory) to double check it and it's fine on my local machine. If I can work out how to create this symlink to the zope folder containing the files in a static app I think it might work! I'm a little confused as to which way the symlink should go though as seanf seems to suggest it goes from the static app to zope but arronh suggests it goes the opposite way (below). I'll give it try and let you know how it goes.

(10 Jan '11, 04:30) urbanian

I'd be very surprised if a 10-year old product like ExtFile will work with Zope 2.12. Zope has changed a lot since 2001 - props to you if you managed to get it working :)

If you want to serve static files from the filesystem, then I recommend that you create a static-only app in our control panel, and then add that app to your site an whatever URL path you need (eg /static). Doing so will create the virtual host configuration you described.

If by some miracle ExtFile is working and you're able to upload items, then you can create a static-only symlink app pointing to the directory where the files are stored, and add that app to you site.

More info is available here: Serving Static Media

Hope that helps!

permanent link

answered 09 Jan '11, 11:13

seanf
12.2k31836
accept rate: 37%

I use the static-only app approach you've mentioned to serve static content (CSS files or site images being uploaded by me personally) but the problem is that I have a CMS that's been written in Zope that allows users to upload files for display on their own profile page (jpg + mp3 files). In the current CMS, Zope can only place files into Zope itself. I was hoping that ExtFile would take uploads, place them outside of Zope's database and allow links to them from outside of Zope. I don't know how to achieve that and found ExtFile whilst hunting for a solution...

(09 Jan '11, 14:07) urbanian

Actually if it's possible for an External Method to take a file as an argument and save it to a pre-determind folder outside of Zope (as ExtFile is doing but without any of the Zope object side of things) I could presumably then link to that folder as you mentioned...

"you can create a static-only symlink app pointing to the directory where the files are stored"

I could keep track of filenames in a database record associated with each user. Problem is I haven't got a clue how to do that or where to start?

(09 Jan '11, 14:14) urbanian

Are the static files being stored in a subdirectory in your Zope directory?

If so, create a symbolic link in your Zope directory that points to your static media directory. So, if you media is being stored in ~/webapps/zope/media, replace the media directory with a symbolic link named media that points to ~/webapps/static. Then, the files will be uploaded to the static directory.

If that's not how your application stores files, then this method won't work.

(09 Jan '11, 14:39) aaronh ♦♦

Are you sure that you even have the problem that you're describing? From what I can tell, you're using Plone 4, and according to the Plone 4 release notes, files and images are stored on the FS by default via plone.app.blob; see Massively improved handling of large files & media

(09 Jan '11, 14:59) seanf

I haven't actually used Plone before. I briefly looked over it in around 2005 and found it far easier to simply create bespoke sites in my own ZPTs, Python scripts and Z SQL Methods. I hadn't considered that Plone would have moved on so much or that that I'd find myself left behind to such a degree. Once you find yourself familiar with something it seems very daunting to go back to the beginning I guess... perhaps I'm well overdue starting from scratch and should embrace Plone. I'll certainly go and investigate it now - thanks for the pointer, much appreciated.

(10 Jan '11, 03:29) urbanian
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×224
×18
×8
×2

question asked: 09 Jan '11, 10:50

question was seen: 4,043 times

last updated: 10 Jan '11, 04:30

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM