Hi Tim,
Tim Hicks wrote:
Tom Lazar wrote:
What I'm trying to do now is make it so that methods on my weblog object
will return lists of IWeblogEntry-ish objects that know what sort of URL
they should have. That way, I can call IWeblog.getLazyEntries(), which
does a catalog search for appropriate IWeblogEntry objects, and then
call absolute_url (or getURL) on each of the returned objects and have
it return a blog-archive-ish URL rather than where it really lives.
IMHO this is not a good approach as it blurs the boundary between
content and representation. why should a (weblog entry) object 'know'
what its display url is? what if you change the mapping? you would have
to change your code...
I take your point. In response to your "why should a (weblog entry)
object 'know' what its display url is?", I'd say "because people expect
it to". That is, 'absolute_url' is the recognised way of retrieving an
object's url. In essence, my question to you might be "why should a
developer have to use a special API to get the appropriate url of an
object when there is a perfectly good, and widely-known, zope API method
already?".
Please. Do *not* try to re-define the meaning of absolute_url. It has a
very specific purpose and meaning, and changing it would likely cause
(a) confusion and (b) subtle breakage. I know it sounds "neat" that the
pseuo-url is returned from "the" URL function, but it's not a good idea.
Leave it alone. Please.
From your objection above, it sounds like you would favour declaring a
view for IWeblogEntry objects (and their catalog brains) that provides,
say, a getArchiveURL method. That's what Martijn (Pieters) was suggesting.
+1
Taking the approach that I have pursued at
<http://dev.plone.org/collective/browser/Quills/branches/maurits-traversal/traversalfaker.py>,
I can have code that looks like::
<div tal:repeat="entry weblog/getLazyEntries">
<a tal:attributes="href entry/getURL"
tal:content="entry/Title">title</a>
</div>
This compares to what I envisage the view approach looking like::
<div tal:repeat="brain weblog/getLazyEntries">
<a tal:define="weblogentryview brain/@@weblogentryview"
tal:attributes="href weblogentryview/getArchiveURL"
tal:content="brain/Title">title</a>
</div>
Maybe the latter is better simply because it is less "magic" and I'm
over-estimating the down-side of not using the standard API.
+100
I guarantee you that there will be times when you'll need the "real" URL
as well, and if absolute_url() doesn't return it, you have no way of
getting to it.
Also see my sig.
Martin
--
Acquisition is a jealous mistress
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers