web/views/editforms.py
changeset 3085 b415bca9a9ed
parent 3072 6fb42c53f6df
parent 3078 186ccbe0ba3f
child 3369 7b88d12b4ee2
equal deleted inserted replaced
3083:3084bc9ccc64 3085:b415bca9a9ed
    18 from cubicweb.selectors import (match_kwargs, one_line_rset, non_final_entity,
    18 from cubicweb.selectors import (match_kwargs, one_line_rset, non_final_entity,
    19                                 specified_etype_implements, yes)
    19                                 specified_etype_implements, yes)
    20 from cubicweb.utils import make_uid
    20 from cubicweb.utils import make_uid
    21 from cubicweb.view import EntityView
    21 from cubicweb.view import EntityView
    22 from cubicweb.common import tags
    22 from cubicweb.common import tags
    23 from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param, uicfg
    23 from cubicweb.web import INTERNAL_FIELD_VALUE, RequestError, stdmsgs, eid_param
       
    24 from cubicweb.web import uicfg
    24 from cubicweb.web.form import FormViewMixIn, FieldNotFound
    25 from cubicweb.web.form import FormViewMixIn, FieldNotFound
    25 from cubicweb.web.formfields import guess_field
    26 from cubicweb.web.formfields import guess_field
    26 from cubicweb.web.formwidgets import Button, SubmitButton, ResetButton
    27 from cubicweb.web.formwidgets import Button, SubmitButton, ResetButton
    27 from cubicweb.web.views import forms
    28 from cubicweb.web.views import forms
    28 
    29 
   325 
   326 
   326     def call(self, **kwargs):
   327     def call(self, **kwargs):
   327         """creation view for an entity"""
   328         """creation view for an entity"""
   328         etype = kwargs.pop('etype', self.req.form.get('etype'))
   329         etype = kwargs.pop('etype', self.req.form.get('etype'))
   329         try:
   330         try:
   330             entity = self.vreg['etypes'].etype_class(etype)(self.req)
   331             etype = self.vreg.case_insensitive_etypes[etype.lower()]
   331         except:
   332         except KeyError:
   332             self.w(self.req._('no such entity type %s') % etype)
   333             raise RequestError(self.req._('no such entity type %s') % etype)
   333         else:
   334         entity = self.vreg['etypes'].etype_class(etype)(self.req)
   334             self.initialize_varmaker()
   335         self.initialize_varmaker()
   335             entity.eid = self.varmaker.next()
   336         entity.eid = self.varmaker.next()
   336             self.render_form(entity)
   337         self.render_form(entity)
   337 
   338 
   338     def form_title(self, entity):
   339     def form_title(self, entity):
   339         """the form view title"""
   340         """the form view title"""
   340         if '__linkto' in self.req.form:
   341         if '__linkto' in self.req.form:
   341             if isinstance(self.req.form['__linkto'], list):
   342             if isinstance(self.req.form['__linkto'], list):