Hi Mike,

Thanks for checking this out;  I went to get some code snippets from
my mako templates to post here, and spotted the problem!  Entirely my
fault, I had used ${url(my-page)} instead of ${url(my_page)}, but
because url generates a sensible looking url if it can't find a
mapping, I didn't spot it.  Sorry to have wasted your time!

All the best,

Richard

On Apr 25, 5:39 pm, Mike Orr <[email protected]> wrote:
> On Sat, Apr 25, 2009 at 3:37 AM, Richard Jones
>
>
>
>
>
> <[email protected]> wrote:
>
> > Hi Folks,
>
> > I'm having some problems with my pylons routing table, and it seems to
> > be behaving inconsistently.  Probably, I am not using it correctly.  I
> > have the following mappings set up:
>
> > map.connect('home','/home', controller='home', action='index')
> > map.connect('my_page', '/my-page', controller='page', action='index')
> > map.connect('object', '/object/{object_id}', controller='obj_manager',
> > action='view_object')
> > map.connect('user_profile', '/profile', controller='user_profile',
> > action='index')
>
> > When I am at localhost:5000/home, all the links render appropriately
> > using ${url('my_page')} (for example) in a mako template.  But if I
> > visit a url to view an object in the system, like:
>
> > localhost:5000/object/809061dd-2946-4a7d-a505-475196dce5ee
>
> > then the link to 'my_page' and 'user_profile' direct, incorrectly, to
>
> > localhost:5000/object/my-page
> > localhost:5000/object/profile
>
> > but the 'home' link directs correctly to
>
> > localhost:5000/home
>
> > I can't see any difference in the way that these links are declared;
> > any one know what's going on?
>
> The syntax looks right, and when I tested it, it works.  So I suspect
> there's something wrong with your url() calls, or another route that's
> unexpectedly matching.
> It looks like some of the calls are producing relative URLs, but I
> don't see why.
>
>  Which version of Routes are you using, and do you have any options
> set (like minimize)?  Perhaps you could show us all your url() calls
> and the HTML they generate.
>
> I tested with the following template (/tmpapp/templates/object.html):
>
> <ul>
> <li<a href="${url('home')}">Home</a></li>
> <li<a href="${url('my_page')}">My page</a></li>
> <li<a href="${url('profile')}">Profile</a></li>
> </ul>
>
> and the following controller:
>
> class ObjManagerController(BaseController):
>
>     def index(self):
>         # Return a rendered template
>         #   return render('/template.mako')
>         # or, Return a response
>         return 'Hello World'
>
>     def view_object(self, object_id):
>         return render("/object.html")
>
> And going to URLhttp://localhost:5000/object/123
>
> --
> Mike Orr <[email protected]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to