@@ -40,22 +40,22 @@ def initialiseSecurity(security):
4040def clean_message (message , mc = re .compile (CLEAN_MESSAGE_RE , re .I )):
4141 return mc .sub (clean_message_callback , message )
4242def clean_message_callback (match , ok = {'a' :1 ,'i' :1 ,'b' :1 ,'br' :1 }):
43- ''' Strip all non <a>,<i>,<b> and <br> tags from a string
44- '''
43+ """ Strip all non <a>,<i>,<b> and <br> tags from a string
44+ """
4545 if ok .has_key (match .group (3 ).lower ()):
4646 return match .group (1 )
4747 return '<%s>' % match .group (2 )
4848
4949
50- error_message = "" ''' <html><head><title>An error has occurred</title></head>
50+ error_message = """ <html><head><title>An error has occurred</title></head>
5151<body><h1>An error has occurred</h1>
5252<p>A problem was encountered processing your request.
5353The tracker maintainers have been notified of the problem.</p>
54- </body></html>'''
54+ </body></html>"""
5555
5656
5757class LiberalCookie (SimpleCookie ):
58- ''' Python's SimpleCookie throws an exception if the cookie uses invalid
58+ """ Python's SimpleCookie throws an exception if the cookie uses invalid
5959 syntax. Other applications on the same server may have done precisely
6060 this, preventing roundup from working through no fault of roundup.
6161 Numerous other python apps have run into the same problem:
@@ -66,7 +66,7 @@ class LiberalCookie(SimpleCookie):
6666 This particular implementation comes from trac's solution to the
6767 problem. Unfortunately it requires some hackery in SimpleCookie's
6868 internals to provide a more liberal __set method.
69- '''
69+ """
7070 def load (self , rawdata , ignore_parse_errors = True ):
7171 if ignore_parse_errors :
7272 self .bad_cookies = []
@@ -88,7 +88,7 @@ def _loose_set(self, key, real_value, coded_value):
8888
8989
9090class Session :
91- '''
91+ """
9292 Needs DB to be already opened by client
9393
9494 Session attributes at instantiation:
@@ -110,7 +110,7 @@ class Session:
110110 # refresh session expiration time, setting persistent
111111 # cookie if needed to last for 'expire' seconds
112112
113- '''
113+ """
114114
115115 def __init__ (self , client ):
116116 self ._data = {}
@@ -133,7 +133,7 @@ def __init__(self, client):
133133 self ._data = self .session_db .getall (self ._sid )
134134
135135 def _gen_sid (self ):
136- ''' generate a unique session key '''
136+ """ generate a unique session key """
137137 while 1 :
138138 s = '%s%s' % (time .time (), random .random ())
139139 s = binascii .b2a_base64 (s ).strip ()
@@ -149,7 +149,7 @@ def _gen_sid(self):
149149 return s
150150
151151 def clean_up (self ):
152- ''' Remove expired sessions'''
152+ """ Remove expired sessions"""
153153 self .session_db .clean ()
154154
155155 def destroy (self ):
@@ -177,14 +177,14 @@ def set(self, **kwargs):
177177 self .client .db .commit ()
178178
179179 def update (self , set_cookie = False , expire = None ):
180- ''' update timestamp in db to avoid expiration
180+ """ update timestamp in db to avoid expiration
181181
182182 if 'set_cookie' is True, set cookie with 'expire' seconds lifetime
183183 if 'expire' is None - session will be closed with the browser
184184
185185 XXX the session can be purged within a week even if a cookie
186186 lifetime is longer
187- '''
187+ """
188188 self .session_db .updateTimestamp (self ._sid )
189189 self .client .db .commit ()
190190
@@ -194,7 +194,7 @@ def update(self, set_cookie=False, expire=None):
194194
195195
196196class Client :
197- ''' Instantiate to handle one CGI request.
197+ """ Instantiate to handle one CGI request.
198198
199199 See inner_main for request processing.
200200
@@ -234,7 +234,7 @@ class Client:
234234 Note that in various places throughout this code, special form
235235 variables of the form :<name> are used. The colon (":") part may
236236 actually be one of either ":" or "@".
237- '''
237+ """
238238
239239 # charset used for data storage and form templates
240240 # Note: must be in lower case for comparisons!
@@ -351,16 +351,16 @@ def setTranslator(self, translator=None):
351351 self .ngettext = translator .ngettext
352352
353353 def main (self ):
354- ''' Wrap the real main in a try/finally so we always close off the db.
355- '''
354+ """ Wrap the real main in a try/finally so we always close off the db.
355+ """
356356 try :
357357 self .inner_main ()
358358 finally :
359359 if hasattr (self , 'db' ):
360360 self .db .close ()
361-
361+
362362 def inner_main (self ):
363- ''' Process a request.
363+ """ Process a request.
364364
365365 The most common requests are handled like so:
366366
@@ -390,7 +390,7 @@ def inner_main(self):
390390 doesn't have permission
391391 - NotFound (raised wherever it needs to be)
392392 percolates up to the CGI interface that called the client
393- '''
393+ """
394394 self .ok_message = []
395395 self .error_message = []
396396 try :
@@ -795,8 +795,8 @@ def determine_context(self, dre=re.compile(r'([^\d]+)0*(\d+)')):
795795 self .template = template_override
796796
797797 def serve_file (self , designator , dre = re .compile (r'([^\d]+)(\d+)' )):
798- ''' Serve the file from the content property of the designated item.
799- '''
798+ """ Serve the file from the content property of the designated item.
799+ """
800800 m = dre .match (str (designator ))
801801 if not m :
802802 raise NotFound , str (designator )
@@ -844,8 +844,8 @@ def serve_file(self, designator, dre=re.compile(r'([^\d]+)(\d+)')):
844844 self ._serve_file (lmt , mime_type , content , filename )
845845
846846 def serve_static_file (self , file ):
847- ''' Serve up the file named from the templates dir
848- '''
847+ """ Serve up the file named from the templates dir
848+ """
849849 # figure the filename - try STATIC_FILES, then TEMPLATES dir
850850 for dir_option in ('STATIC_FILES' , 'TEMPLATES' ):
851851 prefix = self .instance .config [dir_option ]
@@ -875,8 +875,8 @@ def serve_static_file(self, file):
875875 self ._serve_file (lmt , mime_type , '' , filename )
876876
877877 def _serve_file (self , lmt , mime_type , content = None , filename = None ):
878- ''' guts of serve_file() and serve_static_file()
879- '''
878+ """ guts of serve_file() and serve_static_file()
879+ """
880880
881881 # spit out headers
882882 self .additional_headers ['Content-Type' ] = mime_type
@@ -903,8 +903,8 @@ def _serve_file(self, lmt, mime_type, content=None, filename=None):
903903 self .write (content )
904904
905905 def renderContext (self ):
906- ''' Return a PageTemplate for the named page
907- '''
906+ """ Return a PageTemplate for the named page
907+ """
908908 name = self .classname
909909 extension = self .template
910910
@@ -983,7 +983,7 @@ def renderContext(self):
983983 ('export_csv' , ExportCSVAction ),
984984 )
985985 def handle_action (self ):
986- ''' Determine whether there should be an Action called.
986+ """ Determine whether there should be an Action called.
987987
988988 The action is defined by the form variable :action which
989989 identifies the method on this object to call. The actions
@@ -994,7 +994,7 @@ def handle_action(self):
994994
995995 We explicitly catch Reject and ValueError exceptions and
996996 present their messages to the user.
997- '''
997+ """
998998 if self .form .has_key (':action' ):
999999 action = self .form [':action' ].value .lower ()
10001000 elif self .form .has_key ('@action' ):
@@ -1252,7 +1252,7 @@ def handle_range_header(self, length, etag):
12521252 return (first , last - first + 1 )
12531253
12541254 def write_file (self , filename ):
1255- ''' Send the contents of 'filename' to the user.'''
1255+ """ Send the contents of 'filename' to the user."""
12561256
12571257 # Determine the length of the file.
12581258 stat_info = os .stat (filename )
@@ -1306,13 +1306,13 @@ def write_file(self, filename):
13061306 self .write (content )
13071307
13081308 def setHeader (self , header , value ):
1309- ''' Override a header to be returned to the user's browser.
1310- '''
1309+ """ Override a header to be returned to the user's browser.
1310+ """
13111311 self .additional_headers [header ] = value
13121312
13131313 def header (self , headers = None , response = None ):
1314- ''' Put up the appropriate header.
1315- '''
1314+ """ Put up the appropriate header.
1315+ """
13161316 if headers is None :
13171317 headers = {'Content-Type' :'text/html; charset=utf-8' }
13181318 if response is None :
@@ -1375,24 +1375,24 @@ def set_cookie(self, user, expire=None):
13751375 self .session_api .update (set_cookie = True , expire = expire )
13761376
13771377 def make_user_anonymous (self ):
1378- ''' Make us anonymous
1378+ """ Make us anonymous
13791379
13801380 This method used to handle non-existence of the 'anonymous'
13811381 user, but that user is mandatory now.
1382- '''
1382+ """
13831383 self .userid = self .db .user .lookup ('anonymous' )
13841384 self .user = 'anonymous'
13851385
13861386 def standard_message (self , to , subject , body , author = None ):
1387- ''' Send a standard email message from Roundup.
1387+ """ Send a standard email message from Roundup.
13881388
13891389 "to" - recipients list
13901390 "subject" - Subject
13911391 "body" - Message
13921392 "author" - (name, address) tuple or None for admin email
13931393
13941394 Arguments are passed to the Mailer.standard_message code.
1395- '''
1395+ """
13961396 try :
13971397 self .mailer .standard_message (to , subject , body , author )
13981398 except MessageSendError , e :
0 commit comments