dbapi.py
changeset 3293 69c0ba095536
parent 3163 edfe43ceaa35
parent 3275 5247789df541
child 3647 2941f4a0aab9
equal deleted inserted replaced
3230:1d25e928c299 3293:69c0ba095536
   213             self.lang = vreg.property_value('ui.language')
   213             self.lang = vreg.property_value('ui.language')
   214         except: # property may not be registered
   214         except: # property may not be registered
   215             self.lang = 'en'
   215             self.lang = 'en'
   216         # use req.__ to translate a message without registering it to the catalog
   216         # use req.__ to translate a message without registering it to the catalog
   217         try:
   217         try:
   218             self._ = self.__ = self.translations[self.lang]
   218             gettext, pgettext = self.translations[self.lang]
       
   219             self._ = self.__ = gettext
       
   220             self.pgettext = pgettext
   219         except KeyError:
   221         except KeyError:
   220             # this occurs usually during test execution
   222             # this occurs usually during test execution
   221             self._ = self.__ = unicode
   223             self._ = self.__ = unicode
       
   224             self.pgettext = lambda x,y: y
   222         self.debug('request default language: %s', self.lang)
   225         self.debug('request default language: %s', self.lang)
   223 
   226 
   224     def decorate_rset(self, rset):
   227     def decorate_rset(self, rset):
   225         rset.vreg = self.vreg
   228         rset.vreg = self.vreg
   226         rset.req = self
   229         rset.req = self
   359 
   362 
   360 
   363 
   361 # connection object ###########################################################
   364 # connection object ###########################################################
   362 
   365 
   363 class Connection(object):
   366 class Connection(object):
   364     """DB-API 2.0 compatible Connection object for CubicWebt
   367     """DB-API 2.0 compatible Connection object for CubicWeb
   365     """
   368     """
   366     # make exceptions available through the connection object
   369     # make exceptions available through the connection object
   367     ProgrammingError = ProgrammingError
   370     ProgrammingError = ProgrammingError
   368 
   371 
   369     def __init__(self, repo, cnxid, cnxprops=None):
   372     def __init__(self, repo, cnxid, cnxprops=None):