On Tue, 2006-07-11 at 15:38 +0000, plungerman wrote: > greetings, > > i have been working on a template loader to retrieve templates from the > database. after integrating the loader to work with the django's > admin, i now serve up templates from both the file system and the > database, for both the public and admin sites. one problem, however, > is with templatetags that retrieve django template code from the > database. the root of the problem is that the templatetags use the > Context object rather than the RequestContext object, which contains > all of the information contained in the TEMPLATE_CONTEXT_PROCESSORS > tuple stored in the settings.py file. so, for example, the auth object > is unavailable to me, which means i cannot use a code block like: > > {% if not user.is_anonymous %} > logout > {% else %} > login > {% endif %}
I'm not quite sure I understand your problem. A Template object is passed a Context instance when it is rendered. This could be an instance of the Context class or an instance of a subclass of Context (e.g. RequestContext). That instance is passed around within the template whenever a context is required. So if your template is passed a RequestContext by whatever calls it at rendering time, you will have access to the user variable. Within templates, when template tags are called to be rendered, I am pretty sure we just pass in the same context instance (i.e. we don't create a new Context-specific class). So it sounds like your templates are not being called with a RequestContext instance in the first place. Are they? Note that if you are using something like render_to_response() to render the template, you will need to call it as render_to_response(template_name, data_dict, RequestContext(request)) in order to pass a RequestContext instance to the template ultimately, instead of just a Context. If the above scattershot approach to information dispersal hasn't answered your question somehow, perhaps you could clarify a bit more what you are actually seeing happen? Best wishes, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---