comparison roundup/cgi/client.py @ 8189:04c10e2189a5

chore(ruff): whatespace fixes/silence linting I silenced a list of tuple definitions because I wanted the columns to align.
author John Rouillard <rouilj@ieee.org>
date Wed, 11 Dec 2024 13:13:55 -0500
parents 5c506c778893
children b4d7f9358ba6
comparison
equal deleted inserted replaced
8188:e5362f8e1808 8189:04c10e2189a5
1025 def clean_up(self): 1025 def clean_up(self):
1026 """Remove expired sessions and One Time Keys. 1026 """Remove expired sessions and One Time Keys.
1027 1027
1028 Do it only once an hour. 1028 Do it only once an hour.
1029 """ 1029 """
1030 hour = 60*60 1030 hour = 60 * 60
1031 now = time.time() 1031 now = time.time()
1032 1032
1033 # XXX: hack - use OTK table to store last_clean time information 1033 # XXX: hack - use OTK table to store last_clean time information
1034 # 'last_clean' string is used instead of otk key 1034 # 'last_clean' string is used instead of otk key
1035 otks = self.db.getOTKManager() 1035 otks = self.db.getOTKManager()
2174 # try plain class.view 2174 # try plain class.view
2175 tplname = '%s.%s' % (name, view) 2175 tplname = '%s.%s' % (name, view)
2176 else: 2176 else:
2177 # try path/class.view 2177 # try path/class.view
2178 tplname = '%s/%s.%s' % ( 2178 tplname = '%s/%s.%s' % (
2179 view[:slash_loc], name, view[slash_loc+1:]) 2179 view[:slash_loc], name, view[slash_loc + 1:])
2180 2180
2181 if loader.check(tplname): 2181 if loader.check(tplname):
2182 return tplname 2182 return tplname
2183 2183
2184 # rendering class/context with generic template for this view. 2184 # rendering class/context with generic template for this view.
2187 raise templating.NoTemplate('Template "%s" doesn\'t exist' % name) 2187 raise templating.NoTemplate('Template "%s" doesn\'t exist' % name)
2188 2188
2189 if slash_loc == -1: 2189 if slash_loc == -1:
2190 generic = '_generic.%s' % view 2190 generic = '_generic.%s' % view
2191 else: 2191 else:
2192 generic = '%s/_generic.%s' % (view[:slash_loc], view[slash_loc+1:]) 2192 generic = '%s/_generic.%s' % (view[:slash_loc], view[slash_loc + 1:])
2193 if loader.check(generic): 2193 if loader.check(generic):
2194 return generic 2194 return generic
2195 2195
2196 raise templating.NoTemplate( 2196 raise templating.NoTemplate(
2197 'No template file exists for templating ' 2197 'No template file exists for templating '
2221 if self.env.get('CGI_SHOW_TIMING', ''): 2221 if self.env.get('CGI_SHOW_TIMING', ''):
2222 if self.env['CGI_SHOW_TIMING'].upper() == 'COMMENT': 2222 if self.env['CGI_SHOW_TIMING'].upper() == 'COMMENT':
2223 timings = {'starttag': '<!-- ', 'endtag': ' -->'} 2223 timings = {'starttag': '<!-- ', 'endtag': ' -->'}
2224 else: 2224 else:
2225 timings = {'starttag': '<p>', 'endtag': '</p>'} 2225 timings = {'starttag': '<p>', 'endtag': '</p>'}
2226 timings['seconds'] = time.time()-self.start 2226 timings['seconds'] = time.time() - self.start
2227 s = self._( 2227 s = self._(
2228 '%(starttag)sTime elapsed: %(seconds)fs%(endtag)s\n' 2228 '%(starttag)sTime elapsed: %(seconds)fs%(endtag)s\n'
2229 ) % timings 2229 ) % timings
2230 if hasattr(self.db, 'stats'): 2230 if hasattr(self.db, 'stats'):
2231 timings.update(self.db.stats) 2231 timings.update(self.db.stats)
2303 # report original error 2303 # report original error
2304 return str(SeriousError(error)) 2304 return str(SeriousError(error))
2305 2305
2306 # these are the actions that are available 2306 # these are the actions that are available
2307 actions = ( 2307 actions = (
2308 ('edit', actions.EditItemAction), 2308 ('edit', actions.EditItemAction), # noqa: E241
2309 ('editcsv', actions.EditCSVAction), 2309 ('editcsv', actions.EditCSVAction), # noqa: E241
2310 ('new', actions.NewItemAction), 2310 ('new', actions.NewItemAction), # noqa: E241
2311 ('register', actions.RegisterAction), 2311 ('register', actions.RegisterAction), # noqa: E241
2312 ('confrego', actions.ConfRegoAction), 2312 ('confrego', actions.ConfRegoAction), # noqa: E241
2313 ('passrst', actions.PassResetAction), 2313 ('passrst', actions.PassResetAction), # noqa: E241
2314 ('login', actions.LoginAction), 2314 ('login', actions.LoginAction), # noqa: E241
2315 ('logout', actions.LogoutAction), 2315 ('logout', actions.LogoutAction), # noqa: E241
2316 ('search', actions.SearchAction), 2316 ('search', actions.SearchAction), # noqa: E241
2317 ('restore', actions.RestoreAction), 2317 ('restore', actions.RestoreAction), # noqa: E241
2318 ('retire', actions.RetireAction), 2318 ('retire', actions.RetireAction), # noqa: E241
2319 ('show', actions.ShowAction), 2319 ('show', actions.ShowAction), # noqa: E241
2320 ('export_csv', actions.ExportCSVAction), 2320 ('export_csv', actions.ExportCSVAction), # noqa: E241
2321 ('export_csv_id', actions.ExportCSVWithIdAction), 2321 ('export_csv_id', actions.ExportCSVWithIdAction), # noqa: E241
2322 ) 2322 )
2323 2323
2324 def handle_action(self): 2324 def handle_action(self):
2325 """ Determine whether there should be an Action called. 2325 """ Determine whether there should be an Action called.
2326 2326
2911 2911
2912 self.headers_done = 1 2912 self.headers_done = 1
2913 if self.debug: 2913 if self.debug:
2914 self.headers_sent = headers 2914 self.headers_sent = headers
2915 2915
2916 def add_cookie(self, name, value, expire=86400*365, path=None): 2916 def add_cookie(self, name, value, expire=86400 * 365, path=None):
2917 """Set a cookie value to be sent in HTTP headers 2917 """Set a cookie value to be sent in HTTP headers
2918 2918
2919 Parameters: 2919 Parameters:
2920 name: 2920 name:
2921 cookie name 2921 cookie name

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