# HG changeset patch # User Sylvain Thénault # Date 1269452303 -3600 # Node ID 871269e5e02032b18b7c0e9d0c6a3591926d26de # Parent b04ec1b6f7dad5d8a79e785db739a63feefde04c [facet] allow to specify a target type on relation facets for case such as Keyword/CodeKeyword where we only targets Keyword diff -r b04ec1b6f7da -r 871269e5e020 web/facet.py --- a/web/facet.py Wed Mar 24 18:38:19 2010 +0100 +++ b/web/facet.py Wed Mar 24 18:38:23 2010 +0100 @@ -338,10 +338,11 @@ class RelationFacet(VocabularyFacet): __select__ = partial_relation_possible() & match_context_prop() - # class attributes to configure the rel ation facet + # class attributes to configure the relation facet rtype = None role = 'subject' target_attr = 'eid' + target_type = None # set this to a stored procedure name if you want to sort on the result of # this function's result instead of direct value sortfunc = None @@ -365,8 +366,11 @@ sort = self.sortasc try: mainvar = self.filtered_variable - insert_attr_select_relation(rqlst, mainvar, self.rtype, self.role, - self.target_attr, self.sortfunc, sort) + var = insert_attr_select_relation( + rqlst, mainvar, self.rtype, self.role, self.target_attr, + self.sortfunc, sort) + if self.target_type is not None: + rqlst.add_type_restriction(var, self.target_type) try: rset = self.rqlexec(rqlst.as_string(), self.cw_rset.args, self.cw_rset.cachekey) except: