[Grok-dev] sprint mini-report 2
Brandon Craig Rhodes
brandon at rhodesmill.org
Thu May 1 19:44:40 EDT 2008
Martijn Faassen <faassen at startifact.com> writes:
> * A spin-off discussion from the megrok.rdb discussion resulted in
> our inventing a grok.traversable directive and we now have a team
> that works on its implementation.
Their time might be better spent on turning megrok.trails into
something worthy of a first release. In general, RDB applications
should seek to have simple, orthogonal URLs like:
/app/person/brandon_rhodes
/app/person/martijn_faasen
/app/account/br38
/app/account/expiretest
/app/account/faasen
Because, in general, one courts disaster by trying to think of
relational objects as being "beneath" each other, as a traversable()
directive would (if I understand the concept correctly) encourage:
/app/person/brandon_rhodes/accounts/br38
/app/person/brandon_rhodes/accounts/expiretest
/app/person/martijn_faasen/accounts/faasen
Among many other problems (for example, uniqueness; in general,
allowing traversal of attributes in an ORM will give you many URLs for
a single object), URLs that traverse from one object to another
destroy the properties of identity and uniqueness that RDBs are famous
for. For example, moving the "expiretest" account to someone else in
the above example will result in its URL changing (!), which is a deep
violation of the idea that a URL should be a permanent name for
something.
I will gently suggest that ideas like "traversable()" are the result
of long experince with the ZODB ruining people's minds. :-) How? By
convincing them that a URL should not be a unique name for something,
but rather should simply be an impermanent description of how to find
something at this moment. When people use the ZODB too much, they get
used to the idea that moving an object from one folder to another
should change its name - they get used, in other words, to separating
the URL from an object's identity.
In every Grok application that I have written so far atop RDBs, it
simply turns out to be a small disaster (and, yes, I've tried it!) to
put objects "under" other objects. That's why I wrote megrok.trails;
I realized that things only becomes simple when the URLs for one kind
of object are orthogonal from the URLs for all others:
class MyTrails(trails.TrailHead):
grok.context(MyApp)
trails = [
Trail('/person/:shortname', Person),
Trail('/account/:username', Account),
]
--
Brandon Craig Rhodes brandon at rhodesmill.org http://rhodesmill.org/brandon
More information about the Grok-dev
mailing list