Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: third_party/twisted_8_1/twisted/web/woven/simpleguard.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/twisted_8_1/twisted/web/woven/simpleguard.py
diff --git a/third_party/twisted_8_1/twisted/web/woven/simpleguard.py b/third_party/twisted_8_1/twisted/web/woven/simpleguard.py
deleted file mode 100644
index 65c1ad4f9ca4a8bf10054b6135bf09319cf5cab0..0000000000000000000000000000000000000000
--- a/third_party/twisted_8_1/twisted/web/woven/simpleguard.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-#
-
-"""
-A simple guard framework for implementing web sites that only need
-'Anonymous' vs 'Logged on' distinction, but nothing more.
-
-If you need
- - multiple levels of access, or
- - multiple-interface applications, or
- - anything else more complex than 'Logged on' and 'Not logged on'
-
-you need to use twisted.web.woven.guard directly.
-"""
-
-from twisted.cred import portal, checkers as checkerslib
-from twisted.web import resource, util
-from twisted.web.woven import guard
-from zope.interface import implements
-
-
-class Authenticated:
-
- def __init__(self, name=None):
- self.name = name
-
- def __nonzero__(self):
- return bool(self.name)
-
-
-class MarkAuthenticatedResource:
-
- implements(resource.IResource)
-
- isLeaf = False
-
- def __init__(self, resource, name):
- self.authenticated = Authenticated(name)
- self.resource = resource
-
- def render(self, request):
- request.setComponent(Authenticated, self.authenticated)
- return self.resource.render(request)
-
- def getChildWithDefault(self, path, request):
- request.setComponent(Authenticated, self.authenticated)
- return self.resource.getChildWithDefault(path, request)
-
-
-class MarkingRealm:
-
- implements(portal.IRealm)
-
- def __init__(self, resource, nonauthenticated=None):
- self.resource = resource
- self.nonauthenticated = (nonauthenticated or
- MarkAuthenticatedResource(resource, None))
-
- def requestAvatar(self, avatarId, mind, *interfaces):
- if resource.IResource not in interfaces:
- raise NotImplementedError("no interface")
- if avatarId:
- return (resource.IResource,
- MarkAuthenticatedResource(self.resource, avatarId),
- lambda:None)
- else:
- return resource.IResource, self.nonauthenticated, lambda:None
-
-
-def parentRedirect(_):
- return util.ParentRedirect()
-
-def guardResource(resource, checkers, callback=parentRedirect, errback=None,
- nonauthenticated=None):
- myPortal = portal.Portal(MarkingRealm(resource, nonauthenticated))
- for checker in checkers+[checkerslib.AllowAnonymousAccess()]:
- myPortal.registerChecker(checker)
- un = guard.UsernamePasswordWrapper(myPortal,
- callback=callback, errback=errback)
- return guard.SessionWrapper(un)
« no previous file with comments | « third_party/twisted_8_1/twisted/web/woven/page.py ('k') | third_party/twisted_8_1/twisted/web/woven/tapestry.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698