[R] use req.entity_from_eid
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 04 Aug 2009 17:11:50 +0200
changeset 2680 66472d85d548
parent 2679 3fa8c0cec760
child 2681 eda37d59f6d4
[R] use req.entity_from_eid
common/mixins.py
ext/rest.py
server/migractions.py
server/querier.py
server/schemahooks.py
server/session.py
web/controller.py
web/formfields.py
web/views/basecontrollers.py
web/views/editcontroller.py
web/views/workflow.py
web/widgets.py
--- a/common/mixins.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/common/mixins.py	Tue Aug 04 17:11:50 2009 +0200
@@ -155,7 +155,7 @@
 
     def root(self):
         """return the root object"""
-        return self.req.eid_rset(self.path()[0]).get_entity(0, 0)
+        return self.req.entity_from_eid(self.path()[0])
 
 
 class WorkflowableMixIn(object):
--- a/ext/rest.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/ext/rest.py	Tue Aug 04 17:11:50 2009 +0200
@@ -70,7 +70,7 @@
     # Base URL mainly used by inliner.pep_reference; so this is correct:
     context = inliner.document.settings.context
     try:
-        refedentity = context.req.eid_rset(eid_num).get_entity(0, 0)
+        refedentity = context.req.entity_from_eid(eid_num)
     except UnknownEid:
         ref = '#'
         rest += u' ' + context.req._('(UNEXISTANT EID)')
--- a/server/migractions.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/server/migractions.py	Tue Aug 04 17:11:50 2009 +0200
@@ -914,7 +914,7 @@
 
     def cmd_set_state(self, eid, statename, commit=False):
         self.session.set_pool() # ensure pool is set
-        entity = self.session.eid_rset(eid).get_entity(0, 0)
+        entity = self.session.entity_from_eid(eid)
         entity.change_state(entity.wf_state(statename).eid)
         if commit:
             self.commit()
--- a/server/querier.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/server/querier.py	Tue Aug 04 17:11:50 2009 +0200
@@ -506,7 +506,7 @@
             elif not isinstance(obj, (int, long)):
                 obj = obj.eid
             if repo.schema.rschema(rtype).inlined:
-                entity = session.eid_rset(subj).get_entity(0, 0)
+                entity = session.entity_from_eid(subj)
                 entity[rtype] = obj
                 repo.glob_update_entity(session, entity)
             else:
--- a/server/schemahooks.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/server/schemahooks.py	Tue Aug 04 17:11:50 2009 +0200
@@ -963,7 +963,7 @@
 def before_delete_constrained_by(session, fromeid, rtype, toeid):
     if not fromeid in session.transaction_data.get('pendingeids', ()):
         schema = session.schema
-        entity = session.eid_rset(toeid).get_entity(0, 0)
+        entity = session.entity_from_eid(toeid)
         subjtype, rtype, objtype = schema.schema_by_eid(fromeid)
         try:
             cstr = rtype.constraint_by_type(subjtype, objtype,
--- a/server/session.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/server/session.py	Tue Aug 04 17:11:50 2009 +0200
@@ -569,7 +569,7 @@
     @deprecated('use entity_from_eid(eid, etype=None)')
     def entity(self, eid):
         """return a result set for the given eid"""
-        return self.eid_rset(eid).get_entity(0, 0)
+        return self.entity_from_eid(eid)
 
 
 class ChildSession(Session):
--- a/web/controller.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/web/controller.py	Tue Aug 04 17:11:50 2009 +0200
@@ -124,7 +124,7 @@
         redirect_info = set()
         eidtypes = tuple(eidtypes)
         for eid, etype in eidtypes:
-            entity = self.req.eid_rset(eid, etype).get_entity(0, 0)
+            entity = self.req.entity_from_eid(eid, etype)
             path, params = entity.after_deletion_path()
             redirect_info.add( (path, tuple(params.iteritems())) )
             entity.delete()
--- a/web/formfields.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/web/formfields.py	Tue Aug 04 17:11:50 2009 +0200
@@ -452,7 +452,7 @@
         # first see if its specified by __linkto form parameters
         linkedto = entity.linked_to(self.name, self.role)
         if linkedto:
-            entities = (req.eid_rset(eid).get_entity(0, 0) for eid in linkedto)
+            entities = (req.entity_from_eid(eid) for eid in linkedto)
             return [(entity.view('combobox'), entity.eid) for entity in entities]
         # it isn't, check if the entity provides a method to get correct values
         res = []
--- a/web/views/basecontrollers.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/web/views/basecontrollers.py	Tue Aug 04 17:11:50 2009 +0200
@@ -398,7 +398,7 @@
     @jsonize
     def js_reledit_form(self, eid, rtype, role, default, lzone):
         """XXX we should get rid of this and use loadxhtml"""
-        entity = self.req.eid_rset(eid).get_entity(0, 0)
+        entity = self.req.entity_from_eid(eid)
         return entity.view('reledit', rtype=rtype, role=role,
                            default=default, landing_zone=lzone)
 
--- a/web/views/editcontroller.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/web/views/editcontroller.py	Tue Aug 04 17:11:50 2009 +0200
@@ -53,7 +53,7 @@
             for eid in req.edited_eids():
                 formparams = req.extract_entity_params(eid)
                 if methodname is not None:
-                    entity = req.eid_rset(eid).get_entity(0, 0)
+                    entity = req.entity_from_eid(eid)
                     method = getattr(entity, methodname)
                     method(formparams)
                 eid = self.edit_entity(formparams)
--- a/web/views/workflow.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/web/views/workflow.py	Tue Aug 04 17:11:50 2009 +0200
@@ -49,7 +49,7 @@
     def cell_call(self, row, col):
         entity = self.entity(row, col)
         state = entity.in_state[0]
-        transition = self.req.eid_rset(self.req.form['treid']).get_entity(0, 0)
+        transition = self.req.entity_from_eid(self.req.form['treid'])
         dest = transition.destination()
         _ = self.req._
         form = self.vreg.select('forms', 'changestate', self.req, rset=self.rset,
--- a/web/widgets.py	Tue Aug 04 17:02:18 2009 +0200
+++ b/web/widgets.py	Tue Aug 04 17:11:50 2009 +0200
@@ -617,7 +617,7 @@
         # first see if its specified by __linkto form parameters
         linkedto = entity.linked_to(self.name, self.role)
         if linkedto:
-            entities = (req.eid_rset(eid).get_entity(0, 0) for eid in linkedto)
+            entities = (req.entity_from_eid(eid) for eid in linkedto)
             return [(entity.view('combobox'), entity.eid) for entity in entities]
         # it isn't, check if the entity provides a method to get correct values
         if not self.required(entity):