Google Groups Home
Help | Sign in
Adding request path to the stdvars
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Christoph Zwerschke  
View profile
 More options Apr 16 2007, 4:23 pm
From: Christoph Zwerschke <c...@online.de>
Date: Mon, 16 Apr 2007 22:23:55 +0200
Local: Mon, Apr 16 2007 4:23 pm
Subject: Adding request path to the stdvars
I wonder why the current request path is not available as a global
template variable (e.g. as tg.path = cherrypy.request.path). I think
that would be very handy for displaying navigation, breadcrumbs, menus
etc. in the template. And instead setting a flag in the controller it is
often easier to check the path directly.

Shall I submit this as a patch or am I missing something?

-- Chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alberto Valverde  
View profile
(1 user)  More options Apr 16 2007, 4:58 pm
From: Alberto Valverde <albe...@toscat.net>
Date: Mon, 16 Apr 2007 22:58:49 +0200
Local: Mon, Apr 16 2007 4:58 pm
Subject: Re: [tg-trunk] Adding request path to the stdvars

On Apr 16, 2007, at 10:23 PM, Christoph Zwerschke wrote:

> I wonder why the current request path is not available as a global
> template variable (e.g. as tg.path = cherrypy.request.path). I think
> that would be very handy for displaying navigation, breadcrumbs, menus
> etc. in the template. And instead setting a flag in the controller  
> it is
> often easier to check the path directly.

> Shall I submit this as a patch or am I missing something?

You can add whatever variables your app needs to the template  
namespae by appending a function to view.variable_providers

def my_vars(d):
        d['path'] = cherrypy.request.path

from turbogears import view
view.varibale_providers.append(my_vars)

Alberto


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christoph Zwerschke  
View profile
 More options Apr 16 2007, 5:48 pm
From: Christoph Zwerschke <c...@online.de>
Date: Mon, 16 Apr 2007 23:48:31 +0200
Local: Mon, Apr 16 2007 5:48 pm
Subject: Re: [tg-trunk] Re: Adding request path to the stdvars

Alberto Valverde wrote:
> You can add whatever variables your app needs to the template  
> namespae by appending a function to view.variable_providers

I know, but my thought was that the path is so universally important
that it should be really among the "standard" vars.

I don't think all users are aware that 1) the path is available via
charrypy.request.path and 2) you can supplement the standard vars. They
may think they have to pass the page manually or add special decorators:
http://www.mail-archive.com/turbogears@googlegroups.com/msg25527.html

So I think it makes sense to have the request path (and the template
path) available in the template by default already.

-- Chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Godoy  
View profile
 More options Apr 16 2007, 5:56 pm
From: Jorge Godoy <jgo...@gmail.com>
Date: Mon, 16 Apr 2007 18:56:59 -0300
Local: Mon, Apr 16 2007 5:56 pm
Subject: Re: [tg-trunk] Adding request path to the stdvars

Christoph Zwerschke <c...@online.de> writes:
> I wonder why the current request path is not available as a global
> template variable (e.g. as tg.path = cherrypy.request.path). I think
> that would be very handy for displaying navigation, breadcrumbs, menus
> etc. in the template. And instead setting a flag in the controller it is
> often easier to check the path directly.

> Shall I submit this as a patch or am I missing something?

+1 from me.

--
Jorge Godoy      <jgo...@gmail.com>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Godoy  
View profile
 More options Apr 16 2007, 5:57 pm
From: Jorge Godoy <jgo...@gmail.com>
Date: Mon, 16 Apr 2007 18:57:26 -0300
Local: Mon, Apr 16 2007 5:57 pm
Subject: Re: [tg-trunk] Re: Adding request path to the stdvars

Yes, but having it there by default is a big win... ;-)  

--
Jorge Godoy      <jgo...@gmail.com>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alberto Valverde  
View profile
 More options Apr 16 2007, 6:24 pm
From: Alberto Valverde <albe...@toscat.net>
Date: Tue, 17 Apr 2007 00:24:44 +0200
Local: Mon, Apr 16 2007 6:24 pm
Subject: Re: [tg-trunk] Re: Adding request path to the stdvars

On Apr 16, 2007, at 11:57 PM, Jorge Godoy wrote:

Sounds reasonable, mind anyone opening a "patched" ticket at the  
Trac? :)

Thanks,
Alberto


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Godoy  
View profile
 More options Apr 16 2007, 6:31 pm
From: Jorge Godoy <jgo...@gmail.com>
Date: Mon, 16 Apr 2007 19:31:56 -0300
Local: Mon, Apr 16 2007 6:31 pm
Subject: Re: [tg-trunk] Re: Adding request path to the stdvars

Alberto Valverde <albe...@toscat.net> writes:
> Sounds reasonable, mind anyone opening a "patched" ticket at the  
> Trac? :)

I've been thinking...  What about making tg.request (cherrypy.request)
available?  There we'd have all information from the request and we
could modify it there...  Of course, a complement of turbogears.request
would also be nice.

AND, since we're going towards WSGI, we can make that an entry_point or
a configuration parameter...  By default this would be cherrypy.request,
but it could be any request object.

What do you think?

--
Jorge Godoy      <jgo...@gmail.com>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alberto  
View profile
 More options Apr 17 2007, 3:19 am
From: Alberto <albe...@toscat.net>
Date: Tue, 17 Apr 2007 00:19:24 -0700
Local: Tues, Apr 17 2007 3:19 am
Subject: Re: Adding request path to the stdvars

On 17 abr, 00:31, Jorge Godoy <jgo...@gmail.com> wrote:

> Alberto Valverde <albe...@toscat.net> writes:
> > Sounds reasonable, mind anyone opening a "patched" ticket at the
> > Trac? :)

> I've been thinking...  What about making tg.request (cherrypy.request)
> available?  There we'd have all information from the request and we
> could modify it there...  Of course, a complement of turbogears.request
> would also be nice.

> AND, since we're going towards WSGI, we can make that an entry_point or
> a configuration parameter...  By default this would be cherrypy.request,
> but it could be any request object.

> What do you think?

Fine with me too, however, making it configurable via an entry point
seems an overkill to me and overlaps with what extensions provide.

Keep in mind extensions are also loaded via entrypoints and these have
the ability of adding new variables to the template namesace.

So, to sum up, I'm +1 on putting request on tg.request but -1 on
creating a new entry-point to configure which object is bound here.

Alberto


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christoph Zwerschke  
View profile
 More options Apr 17 2007, 4:29 am
From: Christoph Zwerschke <c...@online.de>
Date: Tue, 17 Apr 2007 10:29:40 +0200
Local: Tues, Apr 17 2007 4:29 am
Subject: Re: [tg-trunk] Re: Adding request path to the stdvars
I also thought about adding cherrypy.request to the standard vars
instead of request.path only, since it bundles a lot of stuff that may
be useful in the template. Maybe that's even a better alternative.

-- Chris


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge Vargas  
View profile
 More options Apr 17 2007, 9:01 am
From: "Jorge Vargas" <jorge.var...@gmail.com>
Date: Tue, 17 Apr 2007 09:01:04 -0400
Local: Tues, Apr 17 2007 9:01 am
Subject: Re: [tg-trunk] Re: Adding request path to the stdvars
On 4/17/07, Christoph Zwerschke <c...@online.de> wrote:

> I also thought about adding cherrypy.request to the standard vars
> instead of request.path only, since it bundles a lot of stuff that may
> be useful in the template. Maybe that's even a better alternative.

+1 just like plain old CP


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google