On Mon, Nov 24, 2008 at 5:17 AM, Lawrence Oluyede <[EMAIL PROTECTED]> wrote:
>
> I have a route made like this:
>
>
> map.resource('customer', 'customers', controller='customers',
> name_prefix='', path_prefix='')
> map.resource('instrument', 'basket', controller='basket',
> parent_resource=dict(
> member_name='customer', collection_name='customers'))
>
> This allows me to match URL like: /customers/foobar/basket/FOOBAR
>
> But if a point happens in the id it does not match anymore:
>
> 2008-11-24 14:10:48,649 DEBUG [routes.middleware] Matched GET
> /customers/acme/basket/FO.O.BAR
> 2008-11-24 14:10:48,649 DEBUG [routes.middleware] Route path:
> 'customers/:customer_id/basket/:(id).:(format)', defaults: {'action':
> u'show', 'controller': u'basket', 'id': None}
> 2008-11-24 14:10:48,649 DEBUG [routes.middleware] Match dict:
> {'action': u'show', 'controller': u'basket', 'customer_id': u'acme',
> 'id': u'CDX', 'format': u'O.BAR'}
>
> I thought it was a problem of id matching in routes (I'm using 1.7.3)
> so I tried to upload to 1.10.1 but the problem still presents itself.
>
> Is there a way to avoid this? I think I can do it with some kind of
> trick with a greedy regular expression but I cannot pass
> "requirements" to map.resource
map.resource treats anything with a dot as a format suffix. That way
if the controller supports multiple output formats, you can append
something like .xml or .json to choose an alternate format. I guess
this is an Atom compatibility feature. Looking at the code, it
doesn't appear this can be suppressed. As a workaround, you can
recombine the ID in your action:
def show(self, id, format=""):
id = id + format
--
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
-~----------~----~----~----~------~----~------~--~---