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

Side by Side Diff: third_party/twisted_8_1/twisted/spread/refpath.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 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4
5 __version__ = "$Revision: 1.17 $"[11:-2]
6
7 """
8 Path-based references for PB, and other reference-based protocols.
9
10 Maintainer: U{Glyph Lefkowitz<mailto:glyph@twistedmatrix.com>}
11
12 Future Plans: None at this point besides a final overview and finalization
13 pass.
14 """
15
16
17 from twisted.python import log
18
19 from flavors import Referenceable, Viewable
20 from copy import copy
21 import os
22
23
24
25 ### "Server"-side objects
26
27 class PathReferenceContext:
28 def __init__(self, path, root):
29 self.metadata = {}
30 self.path = path
31 self.root = root
32
33 def __setitem__(self, key, item):
34 self.metadata[key] = item
35
36 def __getitem__(self, key):
37 return self.metadata[key]
38
39 def getObject(self):
40 o = self.root
41 for p in self.path:
42 o = o.getChild(p, self)
43 return o
44
45 class PathReference:
46 def __init__(self):
47 self.children = {}
48 def getChild(self, child, ctx):
49 return self.children[child]
50
51 class PathReferenceDirectory(Referenceable):
52 def __init__(self, root, prefix="remote"):
53 self.root = root
54 self.prefix = prefix
55 def remote_callPath(self, path, name, *args, **kw):
56 ctx = PathReferenceContext(path, self)
57 obj = ctx.getObject()
58 return apply(getattr(obj, "%s_%s" % (self.prefix, name)), args, kw)
59
60 class PathReferenceContextDirectory(Referenceable):
61 def __init__(self, root, prefix="remote"):
62 self.root = root
63 self.prefix = prefix
64 def remote_callPath(self, path, name, *args, **kw):
65 ctx = PathReferenceContext(path, self)
66 obj = ctx.getObject()
67 return apply(getattr(obj, "%s_%s" % (self.prefix, name)),
68 (ctx,)+args, kw)
69
70 class PathViewDirectory(Viewable):
71 def __init__(self, root, prefix="view"):
72 self.root = root
73 self.prefix = prefix
74 def view_callPath(self, perspective, path, name, *args, **kw):
75 ctx = PathReferenceContext(path, self)
76 obj = ctx.getObject()
77 return apply(getattr(obj, "%s_%s" % (self.prefix, name)),
78 (perspective,)+args, kw)
79
80 class PathViewContextDirectory(Viewable):
81 def __init__(self, root, prefix="view"):
82 self.root = root
83 self.prefix = prefix
84 def view_callPath(self, perspective, path, name, *args, **kw):
85 ctx = PathReferenceContext(path, self)
86 obj = ctx.getObject()
87 return apply(getattr(obj, "%s_%s" % (self.prefix, name)),
88 (perspective,ctx)+args, kw)
89
90 ### "Client"-side objects
91
92 class RemotePathReference:
93 def __init__(self, ref, path):
94 self.ref = ref
95 self.path = path
96
97 def callRemote(self, name, *args, **kw):
98 apply(self.ref.callRemote,
99 ("callPath", self.path, name)+args, kw)
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/spread/publish.py ('k') | third_party/twisted_8_1/twisted/spread/ui/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698