merge stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 10 Sep 2009 15:16:44 +0200
branchstable
changeset 3169 3a1cf3598726
parent 3166 2413e5291e8d (current diff)
parent 3168 1ecd1b6d6f1b (diff)
child 3170 ba43e084e884
merge
--- a/skeleton/migration/postcreate.py	Thu Sep 10 14:17:39 2009 +0200
+++ b/skeleton/migration/postcreate.py	Thu Sep 10 15:16:44 2009 +0200
@@ -1,4 +1,4 @@
-# postcreate script. You could setup a workflow here for example
+# postcreate script. You could setup site properties or a workflow here for example
 """
 
 :organization: Logilab
@@ -7,3 +7,6 @@
 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
 """
 
+# Example of site property change
+#set_property('ui.site-title', "<sitename>")
+
--- a/web/test/unittest_urlrewrite.py	Thu Sep 10 14:17:39 2009 +0200
+++ b/web/test/unittest_urlrewrite.py	Thu Sep 10 15:16:44 2009 +0200
@@ -106,6 +106,73 @@
         self.assertEquals(len(rset), 1)
         self.assertEquals(rset[0][0], self.p1.eid)
 
+    def test_inheritance_precedence(self):
+        RQL1 = 'Any C WHERE C is CWEType'
+        RQL2 = 'Any C WHERE C is CWUser'
+
+        class BaseRewriter(SchemaBasedRewriter):
+            rules = [
+               (rgx('/collector(.*)'),
+                rgx_action(rql=RQL1,
+                    form=dict(vid='baseindex')),
+                ),
+                ]
+        class Rewriter(BaseRewriter):
+            rules = [
+               (rgx('/collector/something(/?)'),
+                rgx_action(rql=RQL2,
+                    form=dict(vid='index')),
+                ),
+                ]
+
+        rewriter = Rewriter()
+        req = self.request()
+        pmid, rset = rewriter.rewrite(req, '/collector')
+        self.assertEquals(rset.rql, RQL1)
+        self.assertEquals(req.form, {'vid' : "baseindex"})
+        pmid, rset = rewriter.rewrite(req, '/collector/something')
+        self.assertEquals(rset.rql, RQL2)
+        self.assertEquals(req.form, {'vid' : "index"})
+        pmid, rset = rewriter.rewrite(req, '/collector/something/')
+        self.assertEquals(req.form, {'vid' : "index"})
+        self.assertEquals(rset.rql, RQL2)
+        pmid, rset = rewriter.rewrite(req, '/collector/somethingelse/')
+        self.assertEquals(rset.rql, RQL1)
+        self.assertEquals(req.form, {'vid' : "baseindex"})
+
+    def test_inheritance_precedence_same_rgx(self):
+        RQL1 = 'Any C WHERE C is CWEType'
+        RQL2 = 'Any C WHERE C is CWUser'
+
+        class BaseRewriter(SchemaBasedRewriter):
+            rules = [
+               (rgx('/collector(.*)'),
+                rgx_action(rql=RQL1,
+                    form=dict(vid='baseindex')),
+                ),
+                ]
+        class Rewriter(BaseRewriter):
+            rules = [
+               (rgx('/collector(.*)'),
+                rgx_action(rql=RQL2,
+                    form=dict(vid='index')),
+                ),
+                ]
+
+        rewriter = Rewriter()
+        req = self.request()
+        pmid, rset = rewriter.rewrite(req, '/collector')
+        self.assertEquals(rset.rql, RQL2)
+        self.assertEquals(req.form, {'vid' : "index"})
+        pmid, rset = rewriter.rewrite(req, '/collector/something')
+        self.assertEquals(rset.rql, RQL2)
+        self.assertEquals(req.form, {'vid' : "index"})
+        pmid, rset = rewriter.rewrite(req, '/collector/something/')
+        self.assertEquals(req.form, {'vid' : "index"})
+        self.assertEquals(rset.rql, RQL2)
+        pmid, rset = rewriter.rewrite(req, '/collector/somethingelse/')
+        self.assertEquals(rset.rql, RQL2)
+        self.assertEquals(req.form, {'vid' : "index"})
 
 
 if __name__ == '__main__':