81 else: |
81 else: |
82 key = None |
82 key = None |
83 try: |
83 try: |
84 return self._rsetactions[key] |
84 return self._rsetactions[key] |
85 except KeyError: |
85 except KeyError: |
86 actions = self.vreg.possible_vobjects('actions', self.req, |
86 actions = self.vreg['actions'].possible_vobjects( |
87 rset=self, **kwargs) |
87 self.req, rset=self, **kwargs) |
88 self._rsetactions[key] = actions |
88 self._rsetactions[key] = actions |
89 return actions |
89 return actions |
90 |
90 |
91 def __len__(self): |
91 def __len__(self): |
92 """returns the result set's size""" |
92 """returns the result set's size""" |
368 assert eid is not None |
368 assert eid is not None |
369 # return cached entity if exists. This also avoids potential recursion |
369 # return cached entity if exists. This also avoids potential recursion |
370 # XXX should we consider updating a cached entity with possible |
370 # XXX should we consider updating a cached entity with possible |
371 # new attributes found in this resultset ? |
371 # new attributes found in this resultset ? |
372 try: |
372 try: |
373 return req.entity_cache(eid) |
373 entity = req.entity_cache(eid) |
|
374 if entity.rset is None: |
|
375 # entity has no rset set, this means entity has been cached by |
|
376 # the repository (req is a repository session) which had no rset |
|
377 # info. Add id. |
|
378 entity.rset = self |
|
379 entity.row = row |
|
380 entity.col = col |
|
381 return entity |
374 except KeyError: |
382 except KeyError: |
375 pass |
383 pass |
376 # build entity instance |
384 # build entity instance |
377 etype = self.description[row][col] |
385 etype = self.description[row][col] |
378 entity = self.vreg.etype_class(etype)(req, self, row, col) |
386 entity = self.vreg['etypes'].etype_class(etype)(req, rset=self, |
|
387 row=row, col=col) |
379 entity.set_eid(eid) |
388 entity.set_eid(eid) |
380 # cache entity |
389 # cache entity |
381 req.set_entity_cache(entity) |
390 req.set_entity_cache(entity) |
382 eschema = entity.e_schema |
391 eschema = entity.e_schema |
383 # try to complete the entity if there are some additional columns |
392 # try to complete the entity if there are some additional columns |