"Jason R. Mastaler" <[EMAIL PROTECTED]> writes:

> So, a feature that expands every string variable in Defaults is
> something we could discuss

I looked at this briefly tonight.  There appears to be no sexy way to
do this that I can think of.  Mainly because Python doesn't like the
idea of vars() being monkeyed with.  According to the documentation[1]
for vars():

  vars([object]) 
      Without arguments, return a dictionary corresponding to the
      current local symbol table. With a module, class or class
      instance object as argument (or anything else that has a
      __dict__ attribute), returns a dictionary corresponding to the
      object's symbol table. The returned dictionary should not be
      modified: the effects on the corresponding symbol table are
      undefined.

Thus, even something like the following at the end of Defaults.py
blows up with a RuntimeError:

  for k,v in vars().iteritems():
      if isinstance(v, str):
          print '%s = %s' % (k,v)

You have to query vars().copy() instead before all is good.

However, I don't think we want to run os.path.expanduser() on _every_
string variable anyway, as there are many where this isn't
appropriate.

  ACTION_EXPIRED_DATED = 'confirm'
  DATED_TIMEOUT = '5d'
  FULLNAME = 'Jason R. Mastaler'
  etc..

So perhaps we have to just do the tilde expansion on a case by case
basis in Defaults.py? e.g,

  if not vars().has_key('TEMPLATE_DIR'):
      TEMPLATE_DIR = None
  else:
      TEMPLATE_DIR = os.path.expanduser(TEMPLATE_DIR)

Footnotes: 
[1]  http://www.python.org/doc/current/lib/built-in-funcs.html#built-in-funcs

_________________________________________________
tmda-workers mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-workers

Reply via email to