comparison roundup/cgi/client.py @ 2557:ff02e9851592

translator object must be Roundup Translation Service... ...providing both TAL and gettext translation API; if no explicit translator given, get the service object from lookup function, not from the obsolescent global variable
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Sun, 11 Jul 2004 14:23:12 +0000
parents 091711fb2f8c
children 89c5e8564dad
comparison
equal deleted inserted replaced
2556:297dedb7226e 2557:ff02e9851592
1 # $Id: client.py,v 1.181 2004-07-02 05:22:09 richard Exp $ 1 # $Id: client.py,v 1.182 2004-07-11 14:23:12 a1s Exp $
2 2
3 """WWW request handler (also used in the stand-alone server). 3 """WWW request handler (also used in the stand-alone server).
4 """ 4 """
5 __docformat__ = 'restructuredtext' 5 __docformat__ = 'restructuredtext'
6 6
8 import binascii, Cookie, time, random, stat, rfc822 8 import binascii, Cookie, time, random, stat, rfc822
9 import codecs 9 import codecs
10 10
11 11
12 from roundup import roundupdb, date, hyperdb, password 12 from roundup import roundupdb, date, hyperdb, password
13 from roundup.cgi import templating, cgitb 13 from roundup.cgi import templating, cgitb, TranslationService
14 from roundup.cgi.actions import * 14 from roundup.cgi.actions import *
15 from roundup.cgi.exceptions import * 15 from roundup.cgi.exceptions import *
16 from roundup.cgi.form_parser import FormParser 16 from roundup.cgi.form_parser import FormParser
17 from roundup.mailer import Mailer, MessageSendError 17 from roundup.mailer import Mailer, MessageSendError
18 18
58 - "form" is the cgi form, an instance of FieldStorage from the standard 58 - "form" is the cgi form, an instance of FieldStorage from the standard
59 cgi module 59 cgi module
60 - "additional_headers" is a dictionary of additional HTTP headers that 60 - "additional_headers" is a dictionary of additional HTTP headers that
61 should be sent to the client 61 should be sent to the client
62 - "response_code" is the HTTP response code to send to the client 62 - "response_code" is the HTTP response code to send to the client
63 - "translator" is TranslationService instance
63 64
64 During the processing of a request, the following attributes are used: 65 During the processing of a request, the following attributes are used:
65 66
66 - "error_message" holds a list of error messages 67 - "error_message" holds a list of error messages
67 - "ok_message" holds a list of OK messages 68 - "ok_message" holds a list of OK messages
154 155
155 def setTranslator(self, translator=None): 156 def setTranslator(self, translator=None):
156 """Replace the translation engine 157 """Replace the translation engine
157 158
158 'translator' 159 'translator'
159 is i18n module or one of gettext translation classes. 160 is TranslationService instance.
160 It must have attributes 'gettext' and 'ngettext', 161 It must define methods 'translate' (TAL-compatible i18n),
161 serving as translation functions. 162 'gettext' and 'ngettext' (gettext-compatible i18n).
162 163
163 If omitted, use templating.translationService. 164 If omitted, create default TranslationService.
164 """ 165 """
165 if translator is None: 166 if translator is None:
166 translator = templating.translationService 167 translator = TranslationService.get_translation()
167 self.translator = translator 168 self.translator = translator
168 self._ = self.gettext = translator.gettext 169 self._ = self.gettext = translator.gettext
169 self.ngettext = translator.ngettext 170 self.ngettext = translator.ngettext
170 171
171 def main(self): 172 def main(self):

Roundup Issue Tracker: http://roundup-tracker.org/