On Jun 20, 9:23 am, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Jorge Vargas wrote: > > take a look atcherrypy.request, in it you have a lot of convenience > > methods that will help you work this out like browser_url, > > request.path,etc. > > I already had a look there but found nothing really convenient. > > Looking at request.params does not help distinguishing between 'page' > and 'page/0' in my example. > > Even evaluating request.path does not help much if I do not want to > require knowledge of the absolute path of the controller (I want my > method to be independent of that). Think of another example like this: > > @expose() > def buffalo(type='buffalo', subtype='buffalo'): > ... > > Looking at request.path gives me something like > 'myapp/buffallo/cow/buffallo/buffallo/buffallo'. > It is impossible to deduce the relative path to the controller from that > which could be '' or '../' or '../../' depending on whether my method > belongs to the cow controller or to a subcontroller with the name > 'bufallo'. A constructed example, but I was looking for a simple > solution for the general case. > > Am I missing an important method or property?
CherryPy 2 doesn't have any single method to do what you want, but CherryPy 3 does via cherrypy.url(..., relative=True) [1]. That method will create one URL relative to another URL (the current URL, by default). Since the mapping from URL's to controllers is not 1:1 (and sometimes is not even decidable, and certainly not in the opposite direction), it would be MUCH harder to write a general solution for creating a new URL relative to a *controller*. Stick with URL's and stay sane. ;) Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] [1] http://www.cherrypy.org/browser/trunk/cherrypy/__init__.py#L487 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

