17 |
17 |
18 from cubicweb import Binary, UnknownEid |
18 from cubicweb import Binary, UnknownEid |
19 from cubicweb.req import RequestSessionBase |
19 from cubicweb.req import RequestSessionBase |
20 from cubicweb.dbapi import ConnectionProperties |
20 from cubicweb.dbapi import ConnectionProperties |
21 from cubicweb.utils import make_uid |
21 from cubicweb.utils import make_uid |
22 from cubicweb.server.rqlrewrite import RQLRewriter |
22 from cubicweb.rqlrewrite import RQLRewriter |
23 |
23 |
24 ETYPE_PYOBJ_MAP[Binary] = 'Bytes' |
24 ETYPE_PYOBJ_MAP[Binary] = 'Bytes' |
25 |
25 |
26 def is_final(rqlst, variable, args): |
26 def is_final(rqlst, variable, args): |
27 # try to find if this is a final var or not |
27 # try to find if this is a final var or not |
205 def set_language(self, language): |
205 def set_language(self, language): |
206 """i18n configuration for translation""" |
206 """i18n configuration for translation""" |
207 vreg = self.vreg |
207 vreg = self.vreg |
208 language = language or self.user.property_value('ui.language') |
208 language = language or self.user.property_value('ui.language') |
209 try: |
209 try: |
210 self._ = self.__ = vreg.config.translations[language] |
210 gettext, pgettext = vreg.config.translations[language] |
|
211 self._ = self.__ = gettext |
|
212 self.pgettext = pgettext |
211 except KeyError: |
213 except KeyError: |
212 language = vreg.property_value('ui.language') |
214 language = vreg.property_value('ui.language') |
213 try: |
215 try: |
214 self._ = self.__ = vreg.config.translations[language] |
216 gettext, pgettext = vreg.config.translations[language] |
|
217 self._ = self.__ = gettext |
|
218 self.pgettext = pgettext |
215 except KeyError: |
219 except KeyError: |
216 self._ = self.__ = unicode |
220 self._ = self.__ = unicode |
|
221 self.pgettext = lambda x,y: y |
217 self.lang = language |
222 self.lang = language |
218 |
223 |
219 def change_property(self, prop, value): |
224 def change_property(self, prop, value): |
220 assert prop == 'lang' # this is the only one changeable property for now |
225 assert prop == 'lang' # this is the only one changeable property for now |
221 self.set_language(value) |
226 self.set_language(value) |
549 @property |
554 @property |
550 def rql_rewriter(self): |
555 def rql_rewriter(self): |
551 try: |
556 try: |
552 return self._threaddata._rewriter |
557 return self._threaddata._rewriter |
553 except AttributeError: |
558 except AttributeError: |
554 self._threaddata._rewriter = RQLRewriter(self.repo.querier, self) |
559 self._threaddata._rewriter = RQLRewriter(self) |
555 return self._threaddata._rewriter |
560 return self._threaddata._rewriter |
556 |
561 |
557 def build_description(self, rqlst, args, result): |
562 def build_description(self, rqlst, args, result): |
558 """build a description for a given result""" |
563 """build a description for a given result""" |
559 if len(rqlst.children) == 1 and len(rqlst.children[0].solutions) == 1: |
564 if len(rqlst.children) == 1 and len(rqlst.children[0].solutions) == 1: |