# HG changeset patch # User Sylvain Thénault # Date 1260357741 -3600 # Node ID ead446e70c282daea47f5e55e871eaef1d939bef # Parent e19e586cc74e45dde931adaa3ef284d462b1c260 some api update diff -r e19e586cc74e -r ead446e70c28 devtools/fill.py --- a/devtools/fill.py Wed Dec 09 12:20:05 2009 +0100 +++ b/devtools/fill.py Wed Dec 09 12:22:21 2009 +0100 @@ -112,7 +112,7 @@ attrlength = get_max_length(self.e_schema, attrname) num_len = numlen(index) if num_len >= attrlength: - ascii = self.e_schema.rproperty(attrname, 'internationalizable') + ascii = self.e_schema.rdef(attrname).internationalizable return ('&'+decompose_b26(index, ascii))[:attrlength] # always use plain text when no format is specified attrprefix = attrname[:max(attrlength-num_len-1, 0)] diff -r e19e586cc74e -r ead446e70c28 hooks/test/unittest_hooks.py --- a/hooks/test/unittest_hooks.py Wed Dec 09 12:20:05 2009 +0100 +++ b/hooks/test/unittest_hooks.py Wed Dec 09 12:22:21 2009 +0100 @@ -434,17 +434,17 @@ sqlcursor = self.session.pool['system'] try: self.execute('SET X indexed FALSE WHERE X relation_type R, R name "name"') - self.failUnless(self.schema['name'].rproperty('Workflow', 'String', 'indexed')) + self.failUnless(self.schema['name'].rdef('Workflow', 'String').indexed) self.failUnless(self.index_exists('Workflow', 'name')) self.commit() - self.failIf(self.schema['name'].rproperty('Workflow', 'String', 'indexed')) + self.failIf(self.schema['name'].rdef('Workflow', 'String').indexed) self.failIf(self.index_exists('Workflow', 'name')) finally: self.execute('SET X indexed TRUE WHERE X relation_type R, R name "name"') - self.failIf(self.schema['name'].rproperty('Workflow', 'String', 'indexed')) + self.failIf(self.schema['name'].rproperty('Workflow', 'String').indexed) self.failIf(self.index_exists('Workflow', 'name')) self.commit() - self.failUnless(self.schema['name'].rproperty('Workflow', 'String', 'indexed')) + self.failUnless(self.schema['name'].rdef('Workflow', 'String').indexed) self.failUnless(self.index_exists('Workflow', 'name')) def test_unique_change(self): diff -r e19e586cc74e -r ead446e70c28 web/facet.py --- a/web/facet.py Wed Dec 09 12:20:05 2009 +0100 +++ b/web/facet.py Wed Dec 09 12:22:21 2009 +0100 @@ -109,8 +109,8 @@ if rel.optional in (opt, 'both'): # optional relation return ovar - if all(rschema.rproperty(s, o, 'cardinality')[cardidx] in '1+' - for s,o in rschema.iter_rdefs()): + if all(rdefs.cardinality[cardidx] in '1+' + for rdefs in rschema.rdefs.itervalues()): # mandatory relation without any restriction on the other variable for orel in ovar.stinfo['relations']: if rel is orel: diff -r e19e586cc74e -r ead446e70c28 web/test/unittest_views_searchrestriction.py --- a/web/test/unittest_views_searchrestriction.py Wed Dec 09 12:20:05 2009 +0100 +++ b/web/test/unittest_views_searchrestriction.py Wed Dec 09 12:22:21 2009 +0100 @@ -67,16 +67,16 @@ select = self.parse('DISTINCT Any V,TN,L ORDERBY TN,L WHERE T nom TN, V connait T, T is Personne, V is CWUser,' 'NOT V in_state VS, VS name "published", V login L') rschema = self.schema['connait'] - for s, o in rschema.iter_rdefs(): - rschema.set_rproperty(s, o, 'cardinality', '++') + for rdefs in rschema.rdefs.values(): + rdefs.cardinality = '++' try: self.assertEquals(self._generate(select, 'in_state', 'subject', 'name'), "DISTINCT Any A,B ORDERBY B WHERE V is CWUser, " "NOT V in_state VS, VS name 'published', " "V in_state A, A name B") finally: - for s, o in rschema.iter_rdefs(): - rschema.set_rproperty(s, o, 'cardinality', '**') + for rdefs in rschema.rdefs.values(): + rdefs.cardinality = '**' def test_nonregr3(self): #'DISTINCT Any X,TMP,N WHERE P name TMP, X version_of P, P is Project, X is Version, not X in_state S,S name "published", X num N ORDERBY TMP,N' diff -r e19e586cc74e -r ead446e70c28 web/uicfg.py --- a/web/uicfg.py Wed Dec 09 12:20:05 2009 +0100 +++ b/web/uicfg.py Wed Dec 09 12:22:21 2009 +0100 @@ -351,6 +351,7 @@ else: eid = None strict = False + cw = entity._cw for rschema, targetschemas, role in eschema.relation_definitions(True): # check category first, potentially lower cost than checking # permission which may imply rql queries @@ -360,13 +361,14 @@ continue rdef = rschema.role_rdef(eschema, tschema, role) if not ((not strict and rdef.has_local_role(permission)) or - rdef.has_perm(entity._cw, permission, fromeid=eid)): + rdef.has_perm(cw, permission, fromeid=eid)): continue _targetschemas.append(tschema) if not _targetschemas: continue targetschemas = _targetschemas if permission is not None: + rdef = eschema.rdef(rschema, targettype=targetschemas[0]) # tag allowing to hijack the permission machinery when # permission is not verifiable until the entity is actually # created... @@ -374,25 +376,25 @@ yield (rschema, targetschemas, role) continue if rschema.final: - if not eschema.rdef(rschema).has_perm(entity._cw, permission, fromeid=eid): + if not rdef.has_perm(cw, permission, fromeid=eid): continue elif role == 'subject': # on relation with cardinality 1 or ?, we need delete perm as well # if the relation is already set if (permission == 'add' - and rschema.cardinality(eschema, targetschemas[0], role) in '1?' + and rdef.role_cardinality(role) in '1?' and eid and entity.related(rschema.type, role) - and not rschema.has_perm(entity._cw, 'delete', fromeid=eid, - toeid=entity.related(rschema.type, role)[0][0])): + and not rdef.has_perm(cw, 'delete', fromeid=eid, + toeid=entity.related(rschema.type, role)[0][0])): continue elif role == 'object': # on relation with cardinality 1 or ?, we need delete perm as well # if the relation is already set if (permission == 'add' - and rschema.cardinality(targetschemas[0], eschema, role) in '1?' + and rdef.role_cardinality(role) in '1?' and eid and entity.related(rschema.type, role) - and not rschema.has_perm(entity._cw, 'delete', toeid=eid, - fromeid=entity.related(rschema.type, role)[0][0])): + and not rdef.has_perm(cw, 'delete', toeid=eid, + fromeid=entity.related(rschema.type, role)[0][0])): continue yield (rschema, targetschemas, role) diff -r e19e586cc74e -r ead446e70c28 web/views/basecontrollers.py --- a/web/views/basecontrollers.py Wed Dec 09 12:20:05 2009 +0100 +++ b/web/views/basecontrollers.py Wed Dec 09 12:22:21 2009 +0100 @@ -68,7 +68,7 @@ def publish(self, rset=None): """log in the instance""" - if self._cw.config['auth-mode'] == 'http': + if self._cw.vreg.config['auth-mode'] == 'http': # HTTP authentication raise ExplicitLogin() else: diff -r e19e586cc74e -r ead446e70c28 web/views/navigation.py --- a/web/views/navigation.py Wed Dec 09 12:20:05 2009 +0100 +++ b/web/views/navigation.py Wed Dec 09 12:22:21 2009 +0100 @@ -174,8 +174,8 @@ def paginate(view, show_all_option=True, w=None, page_size=None, rset=None): if rset is None: - rset = view.rset - limit_rset_using_paged_nav(view, view.req, rset, w or view.w, + rset = view.cw_rset + limit_rset_using_paged_nav(view, view._cw, rset, w or view.w, not view.need_navigation, show_all_option, page_size=page_size) View.paginate = paginate diff -r e19e586cc74e -r ead446e70c28 web/views/primary.py --- a/web/views/primary.py Wed Dec 09 12:20:05 2009 +0100 +++ b/web/views/primary.py Wed Dec 09 12:22:21 2009 +0100 @@ -255,8 +255,8 @@ # nb: rset retreived using entity.related with limit + 1 if any # because of that, we known that rset.printable_rql() will return # rql with no limit set anyway (since it's handled manually) - if 'dispctrl' in self.extra_kwargs: - limit = self.extra_kwargs['dispctrl'].get('limit') + if 'dispctrl' in self.cw_extra_kwargs: + limit = self.cw_extra_kwargs['dispctrl'].get('limit') else: limit = None if limit is None or self.cw_rset.rowcount <= limit: