1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
"""
Ice module
"""
import sys, exceptions, string, imp
import IcePy
#
# Add some symbols to the Ice module.
#
ObjectPrx = IcePy.ObjectPrx
identityToString = IcePy.identityToString
stringToIdentity = IcePy.stringToIdentity
loadSlice = IcePy.loadSlice
#
# Core Ice types.
#
class Object(object):
def ice_isA(self, id, current=None):
return id in self.ice_ids()
def ice_ping(self, current=None):
pass
def ice_ids(self, current=None):
return [ self.ice_id() ]
def ice_id(self, current=None):
return '::Ice::Object'
#
# Do not define these here. They will be invoked if defined by a subclass.
#
#def ice_preMarshal(self):
# pass
#
#def ice_postUnmarshal(self):
# pass
class LocalObject(object):
pass
#
# Exceptions.
#
class Exception(exceptions.Exception):
def __str__(self):
return self.__class__.__name__
class LocalException(Exception):
def __init__(self, args=''):
self.args = args
class UserException(Exception):
pass
#
# Utilities.
#
def openModule(name):
if sys.modules.has_key(name):
result = sys.modules[name]
else:
result = createModule(name)
return result
def createModule(name):
l = string.split(name, ".")
curr = ''
mod = None
for s in l:
curr = curr + s
if sys.modules.has_key(curr):
mod = sys.modules[curr]
else:
nmod = imp.new_module(curr)
if mod:
setattr(mod, s, nmod)
sys.modules[curr] = nmod
mod = nmod
curr = curr + "."
return mod
def createTempClass():
class __temp: pass
return __temp
#
# Forward declarations.
#
IcePy.declareClass('::Ice::Object')
IcePy.declareProxy('::Ice::Object')
#
# Import Ice types.
#
import BuiltinSequences_ice
import CommunicatorImpl
import Current_ice
import Identity_ice
import LocalException_ice
import ObjectAdapterImpl
import ObjectFactory_ice
import PropertiesImpl
import ServantLocator_ice
import Router_ice
import Locator_ice
import Logger_ice
import ApplicationImpl
#
# Define Ice::Object and Ice::ObjectPrx.
#
IcePy.defineClass('::Ice::Object', Object, False, '', (), ())
IcePy.defineProxy('::Ice::Object', ObjectPrx)
Object._op_ice_isA = IcePy.Operation('ice_isA', OperationMode.Nonmutating, (IcePy.T_STRING,), (), IcePy.T_BOOL, ())
Object._op_ice_ping = IcePy.Operation('ice_ping', OperationMode.Nonmutating, (), (), None, ())
Object._op_ice_ids = IcePy.Operation('ice_ids', OperationMode.Nonmutating, (), (), '::Ice::StringSeq', ())
Object._op_ice_id = IcePy.Operation('ice_id', OperationMode.Nonmutating, (), (), IcePy.T_STRING, ())
#
# Annotate Ice::Identity.
#
def Identity__str__(self):
return IcePy.identityToString(self)
Identity.__str__ = Identity__str__
del Identity__str__
def Identity__hash__(self):
return 5 * hash(self.category) + hash(self.name)
Identity.__hash__ = Identity__hash__
del Identity__hash__
def Identity__lt__(self, other):
if self.category < other.category:
return True
elif self.category == other.category:
return self.name < other.name
return False
Identity.__lt__ = Identity__lt__
del Identity__lt__
def Identity__le__(self, other):
return self.__lt__(other) or self.__eq__(other)
Identity.__le__ = Identity__le__
del Identity__le__
def Identity__eq__(self, other):
return self.category == other.category and self.name == other.name
Identity.__eq__ = Identity__eq__
del Identity__eq__
def Identity__ne__(self, other):
return not self.__eq__(other)
Identity.__ne__ = Identity__ne__
del Identity__ne__
def Identity__gt__(self, other):
if self.category > other.category:
return True
elif self.category == other.category:
return self.name > other.name
return False
Identity.__gt__ = Identity__gt__
del Identity__gt__
def Identity__ge__(self, other):
return self.__gt__(other) or self.__eq__(other)
Identity.__ge__ = Identity__ge__
del Identity__ge__
#
# Proxy comparison functions.
#
def proxyIdentityEqual(lhs, rhs):
if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)):
raise ValueError('argument is not a proxy')
if not lhs and not rhs:
return True
elif not lhs and rhs:
return False
elif lhs and not rhs:
return False
else:
return lhs.ice_getIdentity() == rhs.ice_getIdentity()
def proxyIdentityAndFacetEqual(lhs, rhs):
if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)):
raise ValueError('argument is not a proxy')
if not lhs and not rhs:
return True
elif not lhs and rhs:
return False
elif lhs and not rhs:
return False
else:
return lhs.ice_getIdentity() == rhs.ice_getIdentity() and lhs.ice_getFacet() == rhs.ice_getFacet()
|