horsemeat 2.24.1__tar.gz → 2.25.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {horsemeat-2.24.1 → horsemeat-2.25.1}/PKG-INFO +1 -1
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/version.py +1 -1
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/webapp/dispatcher.py +1 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/webapp/handler.py +38 -15
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/webapp/request.py +0 -2
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat.egg-info/PKG-INFO +1 -1
- {horsemeat-2.24.1 → horsemeat-2.25.1}/MANIFEST.in +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/README +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/__init__.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/configwrapper.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/model/__init__.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/model/newsmessage.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/model/session.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/model/user.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/pg.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/scripts/make-frippery-project +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/tests/__init__.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/tests/test_configwrapper.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/webapp/__init__.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/webapp/bogusrequest.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/webapp/framework_templates/__init__.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/webapp/frameworkhandlers.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/webapp/response.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat/webapp/scrubber.py +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat.egg-info/SOURCES.txt +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat.egg-info/dependency_links.txt +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat.egg-info/requires.txt +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/horsemeat.egg-info/top_level.txt +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/requirements.txt +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/setup.cfg +0 -0
- {horsemeat-2.24.1 → horsemeat-2.25.1}/setup.py +0 -0
@@ -285,37 +285,60 @@ class Handler(object):
|
|
285
285
|
|
286
286
|
pass
|
287
287
|
|
288
|
+
@property
|
289
|
+
def four_zero_four_template(self):
|
290
|
+
return 'framework_templates/404.html'
|
291
|
+
|
288
292
|
@staticmethod
|
289
293
|
@decorator.decorator
|
290
|
-
def
|
294
|
+
def require_is_superuser(handler_method, self, req):
|
291
295
|
|
292
296
|
"""
|
293
297
|
Add this to a handle method like this::
|
294
298
|
|
295
|
-
@Handler.
|
299
|
+
@Handler.require_is_superuser
|
296
300
|
def handle(self, req):
|
297
301
|
...
|
298
302
|
|
299
|
-
And then, if the request isn't from a signed-in
|
300
|
-
they'll get a JSON reply below.
|
303
|
+
And then, if the request isn't from a signed-in user that's got
|
301
304
|
|
302
|
-
|
303
|
-
|
305
|
+
is_superuser = true
|
306
|
+
|
307
|
+
they'll get a JSON reply that says nope.
|
308
|
+
|
309
|
+
If the request is from a signed-in user, then your handle
|
310
|
+
method runs like normal.
|
304
311
|
"""
|
305
312
|
|
306
|
-
if not req.user
|
313
|
+
if not req.user:
|
307
314
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
315
|
+
resp = self.Response.json(dict(
|
316
|
+
reply_timestamp=datetime.datetime.now(),
|
317
|
+
message="Sorry, you need to log in first!",
|
318
|
+
needs_to_log_in=True,
|
319
|
+
success=False))
|
320
|
+
|
321
|
+
resp.status = '401 UNAUTHORIZED'
|
322
|
+
|
323
|
+
return resp
|
324
|
+
|
325
|
+
elif not req.user.is_superuser:
|
326
|
+
|
327
|
+
resp = self.Response.json(dict(
|
328
|
+
reply_timestamp=datetime.datetime.now(),
|
329
|
+
message=f"Sorry, {req.user.display_name}, this is for is_superuser == true accounts only",
|
330
|
+
needs_to_log_in=False,
|
331
|
+
success=False))
|
332
|
+
|
333
|
+
resp.status = '401 UNAUTHORIZED'
|
334
|
+
|
335
|
+
return resp
|
312
336
|
|
313
337
|
else:
|
314
|
-
return handle_method(self, req)
|
315
338
|
|
316
|
-
|
317
|
-
|
318
|
-
|
339
|
+
log.debug("Returning...")
|
340
|
+
|
341
|
+
return handler_method(self, req)
|
319
342
|
|
320
343
|
@staticmethod
|
321
344
|
@decorator.decorator
|
@@ -479,13 +479,11 @@ class Request(collections.abc.MutableMapping):
|
|
479
479
|
def user(self):
|
480
480
|
|
481
481
|
"""
|
482
|
-
|
483
482
|
Is either None or is a bunch of data extracted from the
|
484
483
|
database.
|
485
484
|
|
486
485
|
When request.user is None, it means this is a user we don't
|
487
486
|
know.
|
488
|
-
|
489
487
|
"""
|
490
488
|
|
491
489
|
# First check if we already made one.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|