appobject.py
changeset 2847 c2ee28f4d4b1
parent 2833 9aa47a3c0dfe
child 2885 0f8084bf2a21
equal deleted inserted replaced
2846:e71d6a585b83 2847:c2ee28f4d4b1
   217     Moreover, the `__abstract__` attribute may be set to True to indicate
   217     Moreover, the `__abstract__` attribute may be set to True to indicate
   218     that a appobject is abstract and should not be registered.
   218     that a appobject is abstract and should not be registered.
   219 
   219 
   220     At selection time, the following attributes are set on the instance:
   220     At selection time, the following attributes are set on the instance:
   221 
   221 
   222     :cw_req:
   222     :_cw:
   223       current request
   223       current request
   224     :cw_extra_kwargs:
   224     :cw_extra_kwargs:
   225       other received arguments
   225       other received arguments
   226 
   226 
   227     only if rset is found in arguments (in which case rset/row/col will be
   227     only if rset is found in arguments (in which case rset/row/col will be
   258             registry.vreg.register_property(cls._cwpropkey(propid), **pdef)
   258             registry.vreg.register_property(cls._cwpropkey(propid), **pdef)
   259         return cls
   259         return cls
   260 
   260 
   261     def __init__(self, req, **extra):
   261     def __init__(self, req, **extra):
   262         super(AppObject, self).__init__()
   262         super(AppObject, self).__init__()
   263         self.cw_req = req
   263         self._cw = req
   264         try:
   264         try:
   265             self.cw_rset = extra.pop('rset')
   265             self.cw_rset = extra.pop('rset')
   266             self.cw_row = extra.pop('row', None)
   266             self.cw_row = extra.pop('row', None)
   267             self.cw_col = extra.pop('col', None)
   267             self.cw_col = extra.pop('col', None)
   268         except KeyError:
   268         except KeyError:
   311         if not isinstance(selector, tuple):
   311         if not isinstance(selector, tuple):
   312             selector = (selector,)
   312             selector = (selector,)
   313         return selector
   313         return selector
   314 
   314 
   315     @property
   315     @property
   316     @deprecated('[3.5] use cw_req.vreg')
   316     @deprecated('[3.5] use _cw.vreg')
   317     def vreg(self):
   317     def vreg(self):
   318         return self.cw_req.vreg
   318         return self._cw.vreg
   319 
   319 
   320     @property
   320     @property
   321     @deprecated('[3.5] use cw_req.vreg.schema')
   321     @deprecated('[3.5] use _cw.vreg.schema')
   322     def schema(self):
   322     def schema(self):
   323         return self.cw_req.vreg.schema
   323         return self._cw.vreg.schema
   324 
   324 
   325     @property
   325     @property
   326     @deprecated('[3.5] use cw_req.vreg.config')
   326     @deprecated('[3.5] use _cw.vreg.config')
   327     def config(self):
   327     def config(self):
   328         return self.cw_req.vreg.config
   328         return self._cw.vreg.config
   329 
   329 
   330     @property
   330     @property
   331     @deprecated('use self.cw_req')
   331     @deprecated('use self._cw')
   332     def req(self):
   332     def req(self):
   333         return self.cw_req
   333         return self._cw
   334 
   334 
   335     @property
   335     @property
   336     @deprecated('use self.cw_rset')
   336     @deprecated('use self.cw_rset')
   337     def rset(self):
   337     def rset(self):
   338         return self.cw_rset
   338         return self.cw_rset
   350     @property
   350     @property
   351     @deprecated('use self.cw_extra_kwargs')
   351     @deprecated('use self.cw_extra_kwargs')
   352     def extra_kwargs(self):
   352     def extra_kwargs(self):
   353         return self.cw_extra_kwargs
   353         return self.cw_extra_kwargs
   354 
   354 
   355     @deprecated('[3.5] use cw_req.view')
   355     @deprecated('[3.5] use _cw.view')
   356     def view(self, *args, **kwargs):
   356     def view(self, *args, **kwargs):
   357         return self.cw_req.view(*args, **kwargs)
   357         return self._cw.view(*args, **kwargs)
   358 
   358 
   359     @deprecated('[3.5] use cw_req.varmaker')
   359     @deprecated('[3.5] use _cw.varmaker')
   360     def initialize_varmaker(self):
   360     def initialize_varmaker(self):
   361         self.varmaker = self.cw_req.varmaker
   361         self.varmaker = self._cw.varmaker
   362 
   362 
   363     @deprecated('[3.5] use cw_req.get_cache')
   363     @deprecated('[3.5] use _cw.get_cache')
   364     def get_cache(self, cachename):
   364     def get_cache(self, cachename):
   365         return self.cw_req.get_cache(cachename)
   365         return self._cw.get_cache(cachename)
   366 
   366 
   367     @deprecated('[3.5] use cw_req.build_url')
   367     @deprecated('[3.5] use _cw.build_url')
   368     def build_url(self, *args, **kwargs):
   368     def build_url(self, *args, **kwargs):
   369         return self.cw_req.build_url(*args, **kwargs)
   369         return self._cw.build_url(*args, **kwargs)
   370 
   370 
   371     @deprecated('[3.5] use rset.limited_rql')
   371     @deprecated('[3.5] use rset.limited_rql')
   372     def limited_rql(self):
   372     def limited_rql(self):
   373         return self.rset.limited_rql()
   373         return self.rset.limited_rql()
   374 
   374 
   378 
   378 
   379     @deprecated('[3.5] use self.rset.get_entity(row,col) instead')
   379     @deprecated('[3.5] use self.rset.get_entity(row,col) instead')
   380     def entity(self, row, col=0):
   380     def entity(self, row, col=0):
   381         return self.rset.get_entity(row, col)
   381         return self.rset.get_entity(row, col)
   382 
   382 
   383     @deprecated('[3.5] use cw_req.user_rql_callback')
   383     @deprecated('[3.5] use _cw.user_rql_callback')
   384     def user_rql_callback(self, args, msg=None):
   384     def user_rql_callback(self, args, msg=None):
   385         return self.cw_req.user_rql_callback(args, msg)
   385         return self._cw.user_rql_callback(args, msg)
   386 
   386 
   387     @deprecated('[3.5] use cw_req.user_callback')
   387     @deprecated('[3.5] use _cw.user_callback')
   388     def user_callback(self, cb, args, msg=None, nonify=False):
   388     def user_callback(self, cb, args, msg=None, nonify=False):
   389         return self.cw_req.user_callback(cb, args, msg, nonify)
   389         return self._cw.user_callback(cb, args, msg, nonify)
   390 
   390 
   391     @deprecated('[3.5] use cw_req.format_date')
   391     @deprecated('[3.5] use _cw.format_date')
   392     def format_date(self, date, date_format=None, time=False):
   392     def format_date(self, date, date_format=None, time=False):
   393         return self.cw_req.format_date(date, date_format, time)
   393         return self._cw.format_date(date, date_format, time)
   394 
   394 
   395     @deprecated('[3.5] use cw_req.format_timoe')
   395     @deprecated('[3.5] use _cw.format_timoe')
   396     def format_time(self, time):
   396     def format_time(self, time):
   397         return self.cw_req.format_time(time)
   397         return self._cw.format_time(time)
   398 
   398 
   399     @deprecated('[3.5] use cw_req.format_float')
   399     @deprecated('[3.5] use _cw.format_float')
   400     def format_float(self, num):
   400     def format_float(self, num):
   401         return self.cw_req.format_float(num)
   401         return self._cw.format_float(num)
   402 
   402 
   403     @deprecated('[3.5] use cw_req.parse_datetime')
   403     @deprecated('[3.5] use _cw.parse_datetime')
   404     def parse_datetime(self, value, etype='Datetime'):
   404     def parse_datetime(self, value, etype='Datetime'):
   405         return self.cw_req.parse_datetime(value, etype)
   405         return self._cw.parse_datetime(value, etype)
   406 
   406 
   407     @deprecated('[3.5] use self.cw_propval')
   407     @deprecated('[3.5] use self.cw_propval')
   408     def propval(self, propid):
   408     def propval(self, propid):
   409         return self.cw_req.property_value(self._cwpropkey(propid))
   409         return self._cw.property_value(self._cwpropkey(propid))
   410 
   410 
   411 set_log_methods(AppObject, getLogger('cubicweb.appobject'))
   411 set_log_methods(AppObject, getLogger('cubicweb.appobject'))