Traversal over a filesystem

64 views
Skip to first unread message

Mike Orr

unread,
Aug 23, 2015, 10:24:52 AM8/23/15
to pylons-...@googlegroups.com
Has anyone used traversal over a filesystem for non-static content?
I'm thinking of putting my HTML content in files to get Git versioning
and text-editor friendliness, so that each file would represent a URL
but not be served as-is (you'd still put a site template around it and
plug in metadata). Interspersed there would be true static files
(e.g., images), although I'd like to have dynamic thumbnails. This
suggests a traversal structure with objects for directories and
different file types, like Kotti but with the nodes in the filesystem
rather than in a database. (Without through-the-web editing.)

My primary issue is how to structure the files. In the past I've used
email-message format, with the metadata in headers and the HTML body
in the content, and a script that applies a template to generate a
static HTML page. That's OK for editing, although if you view the raw
file in a browser it formats all the metadata into a paragraph.
Another approach I'm considering is to put the metadata in a TOML file
per directory. That would allow for expansion and automatically parse
data types, and be more human-readable than JSON, but it would
separate the metadata from the content. Has anyone done anything
similar?

Also, have people used the Python thumbnail-management libraries? Is
there a lightweight one you'd recommend? My past practice is to
pregenerate the thumbnails as static files next to the originals, but
I want to get away from that.

--
Mike Orr <slugg...@gmail.com>

Paul Everitt

unread,
Aug 23, 2015, 10:34:58 AM8/23/15
to pylons-...@googlegroups.com
Chris Rossi has a fantastic set of ideas in a package for this:


- Directory tree is resource graph
- Serialized as YAML
- Git commit transactions as pyramid_tm transactions

In fact, his set of ideas for git integration (underneath in AcidFS) are really intriguing.

—Paul

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Mike Orr

unread,
Aug 24, 2015, 12:34:47 AM8/24/15
to pylons-...@googlegroups.com
Good to know but that's a different use case. Mine is read-only to the
application so it doesn't need transactions. I've got an idea outlined
in my head, I'll post more if it succeeds. Esstentially, in the
resource tree directories will be folder objects with their path. HTML
files will have an object with their path, content, and metadata.
Asset files (determined by their filename extension) will have an
object with their path. An HTML view will use a renderer, a folder
view will implcitly attach index.html, and an asset view will use
FileResponse. I haven't decided how to integrate thumbnails yet.

I expect there will need to be properties for specialized
resource/view types in certain sections, but I haven't decided whether
to hande that in getitem or file metadata.

I also haven't decided how to handle thumbnails. There might be both
thumbnail-needed and non-thumbnail-needed images scattered throughout
the filesystem. It's a tradeoff whether to consolidate alll
thumbnail-needed images under one directory or to keep them in their
content sections.
--
Mike Orr <slugg...@gmail.com>

Jonathan Vanasco

unread,
Aug 24, 2015, 12:23:33 PM8/24/15
to pylons-discuss
if you pprint the json (json and simplejson both have "indent" arguments) it instantly becomes human readable.

Mike Orr

unread,
Mar 1, 2016, 1:08:04 AM3/1/16
to pylons-...@googlegroups.com
On Sun, Aug 23, 2015 at 7:24 AM, Mike Orr <slugg...@gmail.com> wrote:
> Has anyone used traversal over a filesystem for non-static content?
> I'm thinking of putting my HTML content in files to get Git versioning
> and text-editor friendliness, so that each file would represent a URL
> but not be served as-is (you'd still put a site template around it and
> plug in metadata). Interspersed there would be true static files
> (e.g., images), although I'd like to have dynamic thumbnails.

I've got basic traversal over a filesystem working. This demo serves a
static directory. Does anyone have any critiques of this approach? If
not, I'll write it up for the Pyramid Cookbook.

--
Mike Orr <slugg...@gmail.com>
traverse_filesystem_demo.py

Michael Merickel

unread,
Mar 1, 2016, 1:45:38 AM3/1/16
to Pylons
One of the original Pyramid demo projects is traversal over a filesystem.



--
Mike Orr <slugg...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.

Jens W. Klein

unread,
Mar 1, 2016, 4:32:46 AM3/1/16
to pylons-...@googlegroups.com
On 2015-08-23 16:24, Mike Orr wrote:
> Has anyone used traversal over a filesystem for non-static content?

One extension in our "node-family" - node.ext.directory[1] - can be used
for filesystem traversal in Pyramid - and we're doing so in a Pyramid
based framework written by us called Cone[2].
Here you have full CRUD access to the filesystem.

Node abstracts the underlying data as a tree with children and
attributes and so we have different node implementations for different
cases such as ldap[3], filesystem, zodb[4] and so on.

A node can be seen as a unified data access object and container. Data
access is always done with x.attrs[key] and childs are accessed by
x.[childname]. independent if its ldap, zodb, filesystem or a custom
sqlalchemy based node implemenation.

[1] https://github.com/bluedynamics/node.ext.directory
[2] https://github.com/bluedynamics/cone.app
[3] https://github.com/bluedynamics/node.ext.ldap
[4] https://github.com/bluedynamics/node.ext.zodb

hth Jens
--
Klein & Partner KG, member of BlueDynamics Alliance

Reply all
Reply to author
Forward
0 new messages