The docs say to
from webob import Request
and then one can do stuff like
Request.user_agent
which should return a string.
But hey, the request isn't initialized, so looking at the code of webobj:
def __get__(self, obj, type=None):
if obj is None:
return self
if self.key not in obj.environ:
if self.default_factory:
val = obj.environ[self.key] = self.default_factory()
return val
else:
return self.default
return obj.environ[self.key]
I get the "obj is None" version as the result of Request.user_agent - it is a
environ_getter object but no string.
Ok, I'm not doing this in the controller, I'm doing this in helpers.py in the
lib directory. What I need is a method to test for the user agent which is
available in all templates (just like stdvars.py used to do in TG1).
Is helpers.py loaded statically and not per request? If so, how can I have a
method in every template and where do I initialize it (BTW: the TG2 docs
don't talk about this at all, at least not that I could find it)
Any pointers as usual greatly appreciated.
Uwe
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---