Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 2561:0dd3dca6bd01
always use translation service set in the tracker client instance;
add vim modeline
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Mon, 12 Jul 2004 09:18:08 +0000 |
| parents | cf52ad6788c8 |
| children | 1f4791438b65 |
comparison
equal
deleted
inserted
replaced
| 2560:d45f1669599c | 2561:0dd3dca6bd01 |
|---|---|
| 60 self.action = action | 60 self.action = action |
| 61 self.klass = klass | 61 self.klass = klass |
| 62 if translator: | 62 if translator: |
| 63 self._ = translator.gettext | 63 self._ = translator.gettext |
| 64 else: | 64 else: |
| 65 self._ = translationService.gettext | 65 self._ = TranslationService.get_translation().gettext |
| 66 def __str__(self): | 66 def __str__(self): |
| 67 return self._('You are not allowed to %(action)s ' | 67 return self._('You are not allowed to %(action)s ' |
| 68 'items of class %(class)s') % { | 68 'items of class %(class)s') % { |
| 69 'action': self.action, 'class': self.klass} | 69 'action': self.action, 'class': self.klass} |
| 70 | 70 |
| 404 def view_check(self): | 404 def view_check(self): |
| 405 ''' Raise the Unauthorised exception if the user's not permitted to | 405 ''' Raise the Unauthorised exception if the user's not permitted to |
| 406 view this class. | 406 view this class. |
| 407 ''' | 407 ''' |
| 408 if not self.is_view_ok(): | 408 if not self.is_view_ok(): |
| 409 raise Unauthorised("view", self._classname) | 409 raise Unauthorised("view", self._classname, |
| 410 translator=self._client.translator) | |
| 410 | 411 |
| 411 def edit_check(self): | 412 def edit_check(self): |
| 412 ''' Raise the Unauthorised exception if the user's not permitted to | 413 ''' Raise the Unauthorised exception if the user's not permitted to |
| 413 edit this class. | 414 edit this class. |
| 414 ''' | 415 ''' |
| 415 if not self.is_edit_ok(): | 416 if not self.is_edit_ok(): |
| 416 raise Unauthorised("edit", self._classname) | 417 raise Unauthorised("edit", self._classname, |
| 418 translator=self._client.translator) | |
| 417 | 419 |
| 418 def input_html4(**attrs): | 420 def input_html4(**attrs): |
| 419 """Generate an 'input' (html4) element with given attributes""" | 421 """Generate an 'input' (html4) element with given attributes""" |
| 420 return '<input %s>'%' '.join(['%s="%s"'%item for item in attrs.items()]) | 422 return '<input %s>'%' '.join(['%s="%s"'%item for item in attrs.items()]) |
| 421 | 423 |
| 439 | 441 |
| 440 def gettext(self, msgid): | 442 def gettext(self, msgid): |
| 441 """Return the localized translation of msgid""" | 443 """Return the localized translation of msgid""" |
| 442 if self._context is None: | 444 if self._context is None: |
| 443 self._context = context(self._client) | 445 self._context = context(self._client) |
| 444 return translationService.translate(domain="roundup", | 446 return self._client.translator.translate(domain="roundup", |
| 445 msgid=msgid, context=self._context) | 447 msgid=msgid, context=self._context) |
| 446 | 448 |
| 447 _ = gettext | 449 _ = gettext |
| 448 | 450 |
| 449 class HTMLClass(HTMLInputMixin, HTMLPermissions): | 451 class HTMLClass(HTMLInputMixin, HTMLPermissions): |
| 1353 def __init__(self, client, classname, nodeid, prop, name, value, | 1355 def __init__(self, client, classname, nodeid, prop, name, value, |
| 1354 anonymous=0, offset=None): | 1356 anonymous=0, offset=None): |
| 1355 HTMLProperty.__init__(self, client, classname, nodeid, prop, name, | 1357 HTMLProperty.__init__(self, client, classname, nodeid, prop, name, |
| 1356 value, anonymous=anonymous) | 1358 value, anonymous=anonymous) |
| 1357 if self._value: | 1359 if self._value: |
| 1358 self._value.setTranslator(translationService) | 1360 self._value.setTranslator(self._client.translator) |
| 1359 self._offset = offset | 1361 self._offset = offset |
| 1360 | 1362 |
| 1361 def plain(self): | 1363 def plain(self): |
| 1362 ''' Render a "plain" representation of the property | 1364 ''' Render a "plain" representation of the property |
| 1363 ''' | 1365 ''' |
| 1475 def __init__(self, client, classname, nodeid, prop, name, value, | 1477 def __init__(self, client, classname, nodeid, prop, name, value, |
| 1476 anonymous=0): | 1478 anonymous=0): |
| 1477 HTMLProperty.__init__(self, client, classname, nodeid, prop, | 1479 HTMLProperty.__init__(self, client, classname, nodeid, prop, |
| 1478 name, value, anonymous) | 1480 name, value, anonymous) |
| 1479 if self._value: | 1481 if self._value: |
| 1480 self._value.setTranslator(translationService) | 1482 self._value.setTranslator(self._client.translator) |
| 1481 | 1483 |
| 1482 def plain(self): | 1484 def plain(self): |
| 1483 ''' Render a "plain" representation of the property | 1485 ''' Render a "plain" representation of the property |
| 1484 ''' | 1486 ''' |
| 1485 self.view_check() | 1487 self.view_check() |
| 2251 | 2253 |
| 2252 def html_quote(self, html): | 2254 def html_quote(self, html): |
| 2253 '''HTML-quote the supplied text.''' | 2255 '''HTML-quote the supplied text.''' |
| 2254 return cgi.escape(url) | 2256 return cgi.escape(url) |
| 2255 | 2257 |
| 2258 # vim: set et sts=4 sw=4 : |
