263 self._execute = repo.querier.execute |
263 self._execute = repo.querier.execute |
264 # shared data, used to communicate extra information between the client |
264 # shared data, used to communicate extra information between the client |
265 # and the rql server |
265 # and the rql server |
266 self.data = {} |
266 self.data = {} |
267 # i18n initialization |
267 # i18n initialization |
268 self.set_language(cnxprops.lang) |
268 self.set_language(user.prefered_language()) |
269 # internals |
269 # internals |
270 self._tx_data = {} |
270 self._tx_data = {} |
271 self.__threaddata = threading.local() |
271 self.__threaddata = threading.local() |
272 self._threads_in_transaction = set() |
272 self._threads_in_transaction = set() |
273 self._closed = False |
273 self._closed = False |
460 if not rollback_on_failure: |
460 if not rollback_on_failure: |
461 raise |
461 raise |
462 source.warning("trying to reconnect") |
462 source.warning("trying to reconnect") |
463 self.cnxset.reconnect(source) |
463 self.cnxset.reconnect(source) |
464 return source.doexec(self, sql, args, rollback=rollback_on_failure) |
464 return source.doexec(self, sql, args, rollback=rollback_on_failure) |
465 |
|
466 def set_language(self, language): |
|
467 """i18n configuration for translation""" |
|
468 language = language or self.user.property_value('ui.language') |
|
469 try: |
|
470 gettext, pgettext = self.vreg.config.translations[language] |
|
471 self._ = self.__ = gettext |
|
472 self.pgettext = pgettext |
|
473 except KeyError: |
|
474 language = self.vreg.property_value('ui.language') |
|
475 try: |
|
476 gettext, pgettext = self.vreg.config.translations[language] |
|
477 self._ = self.__ = gettext |
|
478 self.pgettext = pgettext |
|
479 except KeyError: |
|
480 self._ = self.__ = unicode |
|
481 self.pgettext = lambda x, y: y |
|
482 self.lang = language |
|
483 |
|
484 def change_property(self, prop, value): |
|
485 assert prop == 'lang' # this is the only one changeable property for now |
|
486 self.set_language(value) |
|
487 |
465 |
488 def deleted_in_transaction(self, eid): |
466 def deleted_in_transaction(self, eid): |
489 """return True if the entity of the given eid is being deleted in the |
467 """return True if the entity of the given eid is being deleted in the |
490 current transaction |
468 current transaction |
491 """ |
469 """ |