On 12/02/2006, at 2:40 PM, Jim Gallacher wrote:

Graham Dumpleton wrote:

<snip>
Thus we come to my actual idea that I want some feedback on.
The idea is to provide a new directive in mod_python that allows you to mark an arbitrary point in the directory hierarchy as a context point or base directory
from which files can then be addressed using relative paths.

<snip>

That all said, specific feedback I am interested in is:
1. Is this a good idea and something worthwhile putting in mod_python?

I like it.

2. If it is, what are better names for the directives? Ie., instead of PythonSetDirectory
and PythonAddDirectory.

Perhaps they should be more strongly associated with the module import idea, such PythonSetModuleDirectory and PythonAddModuleDirectory?

3. Again if it is, what is a better name for "req.get_directories()"?

get_directories could have several meanings in the context of a request. Would req.get_module_directories() be a better alternative? Does that capture the concept that you are trying to achieve?

Except that it isn't really specific to just module importing. I gave the example of using it to work out a relative URL to a base URL. You might also use it to
work out a base directory for where to load a non module file such as a
ConfigParser compatible config file.

My other option was:

  PythonSetBaseDirectory
  PythonAddBaseDirectory

  req.get_base_directories()

or:

  PythonBaseDirectory
  PythonSetDirectory

  req.get_directories()

or:

  PythonSetContext
  PythonAddContent

  req.get_contexts()

4. Lastly, if you think the idea is good, but how it is done is not, how do you think it should be done and how do you think the Python*Handler in FIles
directive should be solved, if at all?

I'll need to read your proposal a more few times before commenting further.

My one minor quibble is the special meaning given to the '~' character. My brain automatically reads this as $HOME. I suspect that other people casually looking at an apache config file may do the same, which could lead to some confusion.

Yeah, I know and I was going to put on my list of questions as to an alternative
to using "~/". The other option was whether to use something like:

  PythonHandler ${__handler_root__}/handlers/mymodule.py

  PythonHandler ${myapproot}/handlers/mymodule.py

If you start going down arbitrary variable replacement though, do you start
to allow variable references anywhere and allow stuff like:

  <Files *.html>
  PythonHandler ${myapproot}/handlers/mymodule.py::${__phase__}_html
  </Files>

  PythonOption myapp.variant production

PythonHandler ${myapproot}/handlers/${myapp.variant}/mymodule.py::$ {__phase__}_html

Ie., introduce other magic variables which refer to other attributes associated with the request, such as the phase, or even the value of variables specified
using PythonOption.

Also, what variable interpolation scheme do you use, something like above which would need a special parser, or something like builtin system used with
mod operator for strings.

PythonHandler %(myapproot)s/handlers/%(myapp.variant)s/ mymodule.py::%(__phase__)s_html

Need to see what conventions other parts of Apache use as should be the same
if one went this far.

Graham

Reply via email to