Filer extension via "pools"

43 views
Skip to first unread message

ptoal

unread,
Oct 7, 2011, 10:09:51 AM10/7/11
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?

Stefan Foulis

unread,
Oct 20, 2021, 8:46:48 AM10/20/21
to django...@googlegroups.com
Hi Patrick

Sorry for the late reply. Unfortunately I'm not using django-filer myself anymore these days because my employer doesn't need it.
So I'm really not up-to-date on things and not following the mailing list.
I do have a faint memory of a project many years ago where I (think I) took this extension approach:
Create a new model with the new fields and a OneToOne relationship to the File model. But I'm hazy on other integration parts, like having it show up in django admin or deal with the special file type at upload time. I suppose for the pdf file "extracted text" you could have some background task (e.g celery) look for files of type pdf that don't have the attached model yet and extract the text and save it.

I hope this helps a little bit.

Cheers
Stefan

Ben Stähli

unread,
Oct 21, 2021, 3:03:52 AM10/21/21
to django-filer
Hi Ptoal

looks like this mailing list is somewhat abaondoned. development on filer is going on though, if you join the django-cms slack channels, you'll find quite some stuff, also plans to implement cases as yours more easily...with json fields, without new models (maybe)...etc.

cheers
ben

Reply all
Reply to author
Forward
0 new messages