On Tue, Nov 24, 2009 at 1:35 AM, Mike Burrows (asplake) <[email protected]> wrote: >> >> Maybe. The action name implies the nature of the ID. And you have to >> validate/convert the ID anyway, so 'id' is not necessarily the same as >> 'acct' or 'name'. Action methods by definition take routing variables >> as-is, so ``.get_byacct(self, id)`` is not necessarily bad. You >> should arguably have a separate set of business methods in the model >> that take the real identifiers, to separate the business logic from >> the HTTP UI (which is what the actions are). >> >> -- >> Mike Orr <[email protected]> > > That's all fine until you want to nest resources, and then you're > forced to rename at least one of the id's (conventionally the parent's > - at least in Rails) anyway. Why not use meaningful names > throughout? As the author of described_routes I'm interested in > machine readable representations of resource structure so I care more > than most about consistency, but what argument is there in favour of > "id" other than it requires no thought on the part of the developer?
By described_routes I guess you mean this: http://github.com/asplake/described_routes/tree It looks like a pretty printer for route definitions. Does it use a standard Rails route map, or its own route objects? Does it create a functional route map, or just its output formats? It says "framework neutral", but then there must be some framework-specific code to convert it to a native route map, no? Pylons does not have a routemap pretty printer. That might be worth adding. Pylons does not handle nested resources very well anyway, so this wouldn't be the only problem. But I don't think that having-to-rename-variables applies. The only problem with combining routes from multiple sources is if there's a collision in the route paths or route names, or if a route is over-general and swallows URLs intended for a later route. But if you're combining nested resources, the nested one would normally go under a unique URL prefix. If you tried to overlay two sets of routes at the same URL position, you might run into collisions, but I doubt many people do that. As for unique route names, that's just something you have to have in order to generate them by name. ``map.extend()`` has an argument to insert a set of routes under a URL prefix. Perhaps it needs a name prefix argument too. The 'id' convention is based on the traditional generic route "/{controller}/{action}/{id}" and ``map.resource()``. I thought both of these were borrowed from Rails. I normally do use specific variable names. But that's impossible when you want to have a generic route that serves a variety of different purposes. You can't have two routes whose paths differ only by a variable name, because the variable name does not appear in the incoming URL, so there's no way for Routes to determine which route is wanted (and it would select the first matching route anyway). -- 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.
