a generic

How Contexts Work

I'm really dragging on the context system right now-- perhaps it's past time to document it, that usually clears things up. Click through for a rambling first attempt at this.

So, the basic berylium contexts exist -- these are all the editorial contexts plus a basic set of public contexts.

What is needed is an easy way for editors/admins to determine the look of all public areas of the site. By easy, I mean EASY-- change just the CSS or change the whole template, folder by folder. Fields are inherited from parent folders and the on-disk contexts until a full context is put together.

In addition, it should be possible for admins to maintain a local set of hardcoded editorial and public templates as well, so that a completely custom site may be created and upgraded without mucking with the distributed default contexts.

So for a public template, we search the database for matching contexts up through folders until everything but pre-and-postprocess have been found. Then we look for a any missing fields in files/sitename/contexts(/folderflavor). Then we look for any missing fields in code/contexts(/folderflavor). In each of those locations we look for a match on class and role, class and lower roles, generic and role, and generic and lower roles. Good lord, that is a LOT of searching, isn't it!

A member (public) in a nested folder three deep costs the following:

DYNAMIC CONTEXTS: (6 queries)
/2/3/class-member
/2/class-member
/class-member
/2/3/class-anonymous
/2/class-anonymous
/class-anonymous

SITE FILESYSTEM: (4 hits)
sitename/contexts/folderflavor/class-member
sitename/contexts/folderflavor/class-anonymous
sitename/contexts/class-member
sitename/contexts/class-anonymous

CODE FILESYSTEM: (5 hits)
contexts/folderflavor/class-member
contexts/folderflavor/class-anonymous
contexts/class-member
contexts/class-anonymous
contexts/generic-anonymous

TOTAL 6 queries, 5 filesystem hits

----------------------------

The practical maximum context expense is an admin:

DYNAMIC CONTEXTS (none)

SITE FILESYSTEM: (10 hits)
sitename/contexts/folderflavor/class-admin
sitename/contexts/folderflavor/class-editor
sitename/contexts/folderflavor/class-writer
sitename/contexts/folderflavor/class-member
sitename/contexts/folderflavor/class-anonymous
sitename/contexts/class-admin
sitename/contexts/class-editor
sitename/contexts/class-writer
sitename/contexts/class-member
sitename/contexts/class-anonymous

CODE FILESYSTEM: (11 hits)
contexts/folderflavor/class-admin
contexts/folderflavor/class-editor
contexts/folderflavor/class-writer
contexts/folderflavor/class-member
contexts/folderflavor/class-anonymous
contexts/class-admin
contexts/class-editor
contexts/class-writer
contexts/class-member
contexts/class-anonymous
contexts/generic-anonymous

TOTAL 0 queries, 21 filesystem hits

By Chris Snyder on July 11, 2002 at 5:27pm

jump to top