> > But: without the implicit calling (or any other simple
> > variant) we'll get lots of complaints and questions like
>
> > "I used url_for["google"] and no url gets created, I get a
> > error message XYZ in my templates" because the people forget
> > to add the ()...
>
> It will return a function object, which will raise an error down the road or 
> put
> an invalid URL in the hyperlink.
>
> I don't think it's possible to have optional ().
> The .__getitem__ must return a function in order for (**params) to work.

It can return an object (a class instance) that has __str__ and
__call__ ... so url_for["google"] should give back the __str__ and
url_for["google"](params) will give back the __call__(params).

PS.
was it allowed for __str__ to return unicode strings?

> It can't tell whether () follow the expression or should follow it --
> it's perfectly
> correct to hold a function object in a variable and call it later.
>
> Ben Bangert wrote:
> > > - url_for can raise KeyError for an unknown named route
> > That definitely makes it easier to troubleshoot as well, plus people
>
> can use .keys() to see all their named routes, which will help out
> when using map.resource and anything else that someone comes up with
> that dynamically creates routes.
>
> I wasn't planning to support the other dict methods, but maybe we could.
> If we just say that url_for.routes is a dict of routes by name (as I
> was planning
> to implement), that would do the same.  Otherwise if we offered .items(), what
> would the values be?
>
> --
> Mike Orr <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-devel" 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-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to