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

Side by Side Diff: third_party/twisted_8_1/twisted/web/woven/page.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # -*- test-case-name: twisted.web.test.test_woven -*-
2 #
3 # page.py
4
5 __version__ = "$Revision: 1.23 $"[11:-2]
6
7 from twisted.python import reflect
8 from twisted.web import resource
9 from twisted.web.woven import model, view, controller, interfaces, template
10
11 class Page(model.MethodModel, controller.Controller, view.View):
12 """
13 @cvar appRoot: Set this to True if you want me to call
14 request.rememberRootURL() in my getChild, so you can later use
15 request.getRootURL() to get the URL to this "application"'s root
16 resource. (You don't have to worry if there will be multiple
17 instances of this Page involved in a single request; I'll only
18 call it for the upper-most instance).
19 """
20
21 appRoot = False
22
23 def __init__(self, *args, **kwargs):
24 templateFile = kwargs.setdefault('templateFile', None)
25 inputhandlers = kwargs.setdefault('inputhandlers', None)
26 controllers = kwargs.setdefault('controllers', None)
27 templateDirectory = kwargs.setdefault('templateDirectory', None)
28 template = kwargs.setdefault('template', None)
29
30 del kwargs['templateFile']
31 del kwargs['inputhandlers']
32 del kwargs['controllers']
33 del kwargs['templateDirectory']
34 del kwargs['template']
35
36 model.Model.__init__(self, *args, **kwargs)
37 if len(args):
38 self.model = args[0]
39 else:
40 self.model = self
41
42 controller.Controller.__init__(self, self.model,
43 inputhandlers=inputhandlers,
44 controllers=controllers)
45 self.view = self
46 view.View.__init__(self, self.model, controller=self,
47 templateFile=templateFile,
48 templateDirectory = templateDirectory,
49 template = template)
50 self.controller = self
51 self.controllerRendered = 0
52
53 def getChild(self, name, request):
54 # Don't call the rememberURL if we already did once; That way
55 # we can support an idiom of setting appName as a class
56 # attribue *even if* the same class is used more than once in
57 # a hierarchy of Pages.
58 if self.appRoot and not request.getRootURL():
59 request.rememberRootURL()
60 return controller.Controller.getChild(self, name, request)
61
62
63 def renderView(self, request):
64 return view.View.render(self, request,
65 doneCallback=self.gatheredControllers)
66
67 class LivePage(model.MethodModel, controller.LiveController, view.LiveView):
68
69 appRoot = False
70
71 def __init__(self, m=None, templateFile=None, inputhandlers=None,
72 templateDirectory=None, controllers=None, *args, **kwargs):
73 template = kwargs.setdefault('template', None)
74 del kwargs['template']
75
76 model.Model.__init__(self, *args, **kwargs)
77 if m is None:
78 self.model = self
79 else:
80 self.model = m
81
82 controller.LiveController.__init__(self, self.model,
83 inputhandlers=inputhandlers,
84 controllers=controllers)
85 self.view = self
86 view.View.__init__(self, self.model, controller=self,
87 templateFile=templateFile,
88 templateDirectory=templateDirectory,
89 template=template)
90 self.controller = self
91 self.controllerRendered = 0
92
93
94 def getChild(self, name, request):
95 # Don't call the rememberPath if we already did once; That way
96 # we can support an idiom of setting appName as a class
97 # attribue *even if* the same class is used more than once in
98 # a hierarchy of Pages.
99 if self.appRoot and not request.getRootURL():
100 request.rememberRootURL()
101 return controller.Controller.getChild(self, name, request)
102
103 def renderView(self, request):
104 return view.View.render(self, request,
105 doneCallback=self.gatheredControllers)
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/web/woven/model.py ('k') | third_party/twisted_8_1/twisted/web/woven/simpleguard.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698