requestcontext

Can I access virtual directory name in global.asax.cs ?

The property HttpContext.Current.Request.ApplicationPath represents the virtual directory in IIS or WebDev.WebServer. HttpContext.Current.Request.ApplicationPath evaluates to "/virtualdirectory" This can be used in conjunction with VirtualPathUtility to make a path root relative : VirtualPathUtility.ToAbsolute("~/images/cat.jpg", ...

Why on earth do I have to pass RequestContext in all of my responses?

I want to highlight the current page in the navigation menu. Obviously I need to give the menu links a class like 'active' when you are on their page. This is a classic problem and I've seen many solutions proposed. My problem is I hate all of them and consider none of them to be very DRY. For example: @register.simple_tag def active(re...

turbogears request/user object in templates and request context

Hi all, I am currently making the switch from Django to Turbogears 2.1 and am running into some problems that I could not find the answers to in the Turbogears docs. If tg developers read this, let me tell you that one of the best features Django has over TG is its documentation! 1) How do I access the request (user?) object within a m...

Is there a way to get direct_to_template to pass RequestContext in django?

I have found myself writing the same view over and over. It is basically this: def home_index(request): return render_to_response('home/index.html', RequestContext(request)) To keep with the dry principal, I would like to utilize a generic view. I have seen direct_to_template, but it passes an empty context. So how can I use a g...