--- a/view.py Fri Jul 24 12:08:17 2009 +0200
+++ b/view.py Fri Jul 24 12:09:04 2009 +0200
@@ -195,10 +195,27 @@
necessary for non linkable views, but a default implementation
is provided anyway.
"""
- try:
- return self.build_url(vid=self.id, rql=self.req.form['rql'])
- except KeyError:
- return self.build_url(vid=self.id)
+ rset = self.rset
+ if rset is None:
+ return self.build_url('view', vid=self.id)
+ coltypes = rset.column_types(0)
+ if len(coltypes) == 1:
+ etype = iter(coltypes).next()
+ if not self.schema.eschema(etype).is_final():
+ if len(rset) == 1:
+ entity = rset.get_entity(0, 0)
+ return entity.absolute_url(vid=self.id)
+ # don't want to generate /<etype> url if there is some restriction
+ # on something else than the entity type
+ restr = rset.syntax_tree().children[0].where
+ # XXX norestriction is not correct here. For instance, in cases like
+ # "Any P,N WHERE P is Project, P name N" norestriction should equal
+ # True
+ norestriction = (isinstance(restr, nodes.Relation) and
+ restr.is_types_restriction())
+ if norestriction:
+ return self.build_url(etype.lower(), vid=self.id)
+ return self.build_url('view', rql=rset.printable_rql(), vid=self.id)
def set_request_content_type(self):
"""set the content type returned by this view"""
@@ -313,10 +330,6 @@
category = 'startupview'
- def url(self):
- """return the url associated with this view. We can omit rql here"""
- return self.build_url('view', vid=self.id)
-
def html_headers(self):
"""return a list of html headers (eg something to be inserted between
<head> and </head> of the returned page
@@ -354,14 +367,6 @@
for i in xrange(len(rset)):
self.wview(self.id, rset, row=i, **kwargs)
- def url(self):
- """return the url associated with this view. We can omit rql if we are
- on a result set on which we do not apply.
- """
- if self.rset is None:
- return self.build_url(vid=self.id)
- return super(EntityStartupView, self).url()
-
class AnyRsetView(View):
"""base class for views applying on any non empty result sets"""
--- a/web/views/baseviews.py Fri Jul 24 12:08:17 2009 +0200
+++ b/web/views/baseviews.py Fri Jul 24 12:09:04 2009 +0200
@@ -258,28 +258,6 @@
self.wview(self.item_vid, self.rset, row=row, col=col, vid=vid, **kwargs)
self.w(u'</li>\n')
- def url(self):
- """overrides url method so that by default, the view list is called
- with sorted entities
- """
- coltypes = self.rset.column_types(0)
- # don't want to generate the rql if there is some restriction on
- # something else than the entity type
- if len(coltypes) == 1:
- # XXX norestriction is not correct here. For instance, in cases like
- # Any P,N WHERE P is Project, P name N
- # norestriction should equal True
- restr = self.rset.syntax_tree().children[0].where
- norestriction = (isinstance(restr, nodes.Relation) and
- restr.is_types_restriction())
- if norestriction:
- etype = iter(coltypes).next()
- return self.build_url(etype.lower(), vid=self.id)
- if len(self.rset) == 1:
- entity = self.rset.get_entity(0, 0)
- return self.build_url(entity.rest_path(), vid=self.id)
- return self.build_url(rql=self.rset.printable_rql(), vid=self.id)
-
class ListItemView(EntityView):
id = 'listitem'