Two updates to the previous post:
Update 1: Routes fork on bitbucket
See http://bitbucket.org/asplake/routes/. I’ve sent a pull request with my changes (the prettyprinter included), but no response yet and I’m delighted to say that Ben has now incorporated them in the base Routes repo so expect to see them soon in Routes 1.12.
Update 2: Tidier collection() usage
The end-state of the last post
with mapper.collection(
'releases',
'release',
member_options={
'requirements': {'id': 'd+'}}) as c:
c.member.link(rel='notes', name='release_notes')
can be written as
with mapper.collection(
'releases',
'release',
requirements={'id': 'd+'}) as c:
c.member.link(rel='notes', name='release_notes')
Losing the with syntax, a vanilla collection resource with integer id’s looks like this:
mapper.collection(
'releases',
'release',
requirements={'id': 'd+'})
This applies requirements to the collection-level routes as well as the member-level routes but the overhead (unquantified) must be very small and I prefer this tidier form. It would be easy enough though to provide a member_requirements argument if the performance difference proves to be significant.
Tags: pylons
[...] Incline Mike Burrows (asplake) moving on up « Prettyprinter for Pylons routes DRY up your routes - UPDATES [...]