fix case insensitive selector for entity creation stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 21 Sep 2009 18:02:21 +0200
branchstable
changeset 3346 b1fd9d4ef579
parent 3345 10ad3869fc92
child 3347 428f95118556
fix case insensitive selector for entity creation
selectors.py
web/views/editforms.py
--- a/selectors.py	Mon Sep 21 18:00:28 2009 +0200
+++ b/selectors.py	Mon Sep 21 18:02:21 2009 +0200
@@ -611,14 +611,14 @@
                 etype = req.form['etype']
             except KeyError:
                 return 0
-        else:
-            # only check this is a known type if etype comes from req.form,
-            # else we want the error to propagate
-            try:
-                etype = cls.vreg.case_insensitive_etypes[etype.lower()]
-                req.form['etype'] = etype
-            except KeyError:
-                return 0
+            else:
+                # only check this is a known type if etype comes from req.form,
+                # else we want the error to propagate
+                try:
+                    etype = cls.vreg.case_insensitive_etypes[etype.lower()]
+                    req.form['etype'] = etype
+                except KeyError:
+                    return 0
         return self.score_class(cls.vreg['etypes'].etype_class(etype), req)
 
 
--- a/web/views/editforms.py	Mon Sep 21 18:00:28 2009 +0200
+++ b/web/views/editforms.py	Mon Sep 21 18:02:21 2009 +0200
@@ -326,11 +326,9 @@
 
     def call(self, **kwargs):
         """creation view for an entity"""
+        # at this point we know etype is a valid entity type, thanks to our
+        # selector
         etype = kwargs.pop('etype', self.req.form.get('etype'))
-        try:
-            etype = self.vreg.case_insensitive_etypes[etype.lower()]
-        except KeyError:
-            raise RequestError(self.req._('no such entity type %s') % etype)
         entity = self.vreg['etypes'].etype_class(etype)(self.req)
         self.initialize_varmaker()
         entity.eid = self.varmaker.next()