Hey, so to follow up ... I wrote my own that seems to do the trick, my little project here is called Tycho, so the Tycho.globals.Config contains the stuff mentioned in my previous email:
############# ContextProcessors.py ############# # all Tycho context processors: import Tycho.globals.Config import types, copy def config(request): # convert Config and it's subclasses to nested dicts: configs_dict = { } filternames = (dir(__builtins__), '__module__', '__file__') def isconfig(e): if isinstance(e, types.IntType) or \ isinstance(e, types.LongType) or \ isinstance(e, types.FloatType) or \ isinstance(e, types.StringType): return True return False def convert(e): edict = { } for n in filter( lambda x: x not in filternames, dir(e) ): if isinstance(getattr(e, n), types.ClassType): edict[n] = convert( getattr(e, n) ) elif isconfig(getattr(e, n)) and \ n not in filternames: edict[n] = copy.copy(getattr(e, n)) return edict return convert(Tycho.globals.Config) if __name__ == '__main__': # simple dispatch: print str( config(None) ) ############################################### ... seems to do the trick. -John On Thu, Oct 15, 2009 at 8:55 PM, jc <glib...@gmail.com> wrote: > > Hey Django users, > > So I've got a python file in my django app that I'm using to store some > configs in (to be global across several django apps), it's basically looks > something like this: > > [ -- Contents of Config.py -- ] > VERSION = '0.1' > MEDIA_PREFIX = '/usr/local/dev-www/m/' > [ .. etc ...] > > class u: > "place to put user/login-specific configurations" > MAX_LENGTH = 64 > PASS_MIN_LENGTH = 10 > > [ ... and some other classes with the same sort of thing too ...] > > Within views themselves, these are easy to access, e.g., > Configs.u.MAX_LENGTH, but I'd like be able to easily pass EVERYTHING here to > templates. > > So I'm wondering ... is there some easy/prescribed way (perhaps provided by > django itsself) to be able to turn this into a set of nested dictionaries for > use by a context processor? So for example, I'd like to effectively end up > with: > > render_to_response('stuff.html', > { > 'config' : { > 'VERSION' : '0.1' > 'MEDIA_PREFIX' : '/usr/local/dev-www/m/' > # ... etc ... > > } > }) > > Thanks! > -John --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---