The PySite project needs a decent UI to manage the pages and to up-/download files. The current milestone of PySite envisions that UI to use the metaphor of a file manager, for which elFinder seems a good implementation. Its current version is 2.0RC1, but unfortunately they provide the server component only in PHP. There are 2 third-party implementations in Python, but these are coupled with Django:
- This is a straightforward but incomplete implementation.
- This seems to be a complete implementation which is almost a direct translation of elRite’s PHP version to Python.
The server side, as shown in the PHP version, has two main components: a connector and one or more volumes. The connector is the interface between the client and the volumes, and the latter are responsible to handle certain storages, e.g. local filesystem, a database, FTP etc.
Both above mentioned implementations use Django models as volumes, and yawd additionally provides a driver for the local filesystem. And, of course, their connector is tied to Django’s request/response machinery.
So, this is my attempt to implement the elFinder API 2.0 in Python, with which I pursue the following goals:
- Be framework-agnostic. The “connector” is decoupled from a framework’s request/response machinery. Volume drivers may or may not be decoupled; for my use-case I only need the local filesystem, and eventually a database (a document oriented one, or SQLAlchemy)
- Clean up the code. Although I borrow much from yawd and the PHP version, in my personal opinion the code is a mess; apart from connector/volume there is no clear separation of concerns: high- and low-level functionality, access control, image and archive processing etc., all of this is stuffed inside the same instance. And some literal translations of PHP idioms are awkward in Python, and in at least one case introduces a serious bug.
- Provide automatic tests!
Don’t get me wrong — their code works. At least the PHP implementation which I had set up as a reference. But to tweak the Python code I had to gain some understanding of the inner workings, which turned out to be hard. And due to missing tests, I could not be sure that I had not introduced bugs myself.