ptoal
unread,Oct 7, 2011, 10:09:51 AM10/7/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-filer
Stefan,
I've been digging through the filer code, trying to grok it, and adapt
it to my needs. The current need is to support the PDF filetype with
an added Field (extracted_text), as well as custom thumbnail
generation. Also, I may with to have this file type represented in
django-cms via a plugin, so I can see a need for some hooks there.
What I'm thinking is using a method similar to the "plugin pool" that
django-cms uses. So, say, I would have an app called, say, django-
filer-pdf. That app would have a file hierarchy that looked something
like this:
├── __init__.py
├── admin
├── filer_plugin.py **
├── models.py
├── tests
├── urls.py
└── views.py
Upon initialization, filer would call a method like
filer.PluginPool.discover_plugin() which would call
load('filer_plugin'), scanning for all apps that had a filer_plugin
module, and automatically registering those types with filer. This is
exactly how plugins are installed in django-cms.
The benefit of this approach is that you don't need to manually
configure anything in settings, other than putting the appname in
INSTALLED_APPS. It just gets automagically detected and loaded.
This approach currently relies on the model having the
matches_file_type method, and only having one plugin match each file
type. That's not to say this problem couldn't be solved with the pool
approach. I just haven't come up with the right answer yet. :) I
think that there might be cases where you really _would_ want two apps
to be able to handle the same file type. For example, maybe I want to
have a "Photo JPG" type, that tracks EXIF information, etc, but I also
want a generic "Image" type that can be used for generic jpg's that
don't have EXIF data. Is this a use-case that filer should
incorporate?
Thoughts / Comments?