Will's blog

purpose: Will Kahn-Greene's blog of Miro, PyBlosxom, Python, GNU/Linux, random content, PyBlosxom, Miro, and other projects mixed in there ad hoc, half-baked, and with a twist of lemon

[ home | blog home | recent activity ]

Tue, 08 Apr 2003

pyinclude plugin (showing off variables-with-arguments)

I checked in some changes I made last night which affect how variables get expanded and what kinds of things we can do with metadata variables. Now, we can expand the following variable things:

$foo This is a regular variable with nothing fancy that we could handle before.
$foo::bar This is variable bar in the scoping foo. Variables can now be grouped in categories. Categories can be functionally oriented (utils, calendar, date, file, communication, ...) or plugin oriented (pycalendar, pyarchives, ...) or whatever.
$foo::bar("arg1", "arg2", "arg3") This is variable bar in the scoping foo... but it's actually a function call passing in three arguments all of type string. The arguments are evaluated as Python code, can be of any type, and any quantity. We only pass in the arguments if the value of the variable (in this case $foo::bar) is a function. This allows plugins to take in configuration information from other places other than config.py. For instance, this is really useful for a fileinclude kind of plugin where you might want to include different files at different points in your templates.... More about that later.

So now the following examples are all valid variables:

In typical fashion (and at Wari's behest), I wrote a quick plugin which uses this. It allows you to include files in your head and foot templates. I use this to include my .project file so people can see it on my web-site as well as finger me on my server and I only have to update it in one place.

Code is here.

Comments:

Post a new comment:

Three things:

  1. New comments get placed in a "draft" status and will NOT show up on the site until I explicitly approve it. Sometimes that happens within 24 hours.
  2. I reserve the right to reject/remove inappropriate comments.
  3. Sometimes I'll reply to a comment directly in email--so make sure your email address is correct.

If you can't for some reason post a comment, send me an email: willg at bluesock dot org.

Your name:


Your e-mail address (this doesn't get displayed to anyone--sometimes I'll reply directly to you):


URL of your website (optional):


Comment:


Yes, I am a human!


pyblosxom::1.5-dev git-master

Copyright 1996 to 2012, Will Guaraldi Kahn-Greene, under the Creative Commons BY-SA 3.0 license

Creative Commons License
Will's Blog by William Kahn-Greene is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.