18 import omniORB.CORBA
as CORBA
88 self.
_nameServer =
"corbaloc::" + name_server +
"/NameService"
93 print(
"CorbaNaming: Failed to narrow the root naming context.")
95 except CORBA.ORB.InvalidName:
97 print(
"Service required is invalid [does not exist].")
132 self.
_nameServer =
"corbaloc::" + name_server +
"/NameService"
134 self.
_rootContext = obj._narrow(CosNaming.NamingContext)
213 def bind(self, name_list, obj, force=None):
219 except CosNaming.NamingContext.NotFound:
224 except CosNaming.NamingContext.CannotProceed
as err:
229 except CosNaming.NamingContext.AlreadyBound:
258 self.
bind(self.
toName(string_name), obj, force)
297 length = len(name_list)
299 for i
in range(length):
302 cxt.bind(self.
subName(name_list, i, i), obj)
303 except CosNaming.NamingContext.AlreadyBound:
304 cxt.rebind(self.
subName(name_list, i, i), obj)
310 raise CosNaming.NamingContext.CannotProceed(cxt, self.
subName(name_list, i))
338 def rebind(self, name_list, obj, force=True):
345 except CosNaming.NamingContext.NotFound:
352 except CosNaming.NamingContext.CannotProceed
as err:
416 length = len(name_list)
417 for i
in range(length):
419 context.rebind(self.
subName(name_list, i, i), obj)
424 context = context.bind_new_context(self.
subName(name_list, i, i))
425 except CosNaming.NamingContext.AlreadyBound:
426 obj_ = context.resolve(self.
subName(name_list, i, i))
427 context = obj_._narrow(CosNaming.NamingContext)
429 raise CosNaming.NamingContext.CannotProceed(context, self.
subName(name_list, i))
458 if isinstance(name, str):
461 self.
bind(name, name_cxt, force)
512 if isinstance(name, str):
515 self.
rebind(name, name_cxt, force)
569 if isinstance(name, str):
577 except CosNaming.NamingContext.NotFound
as ex:
610 if isinstance(name, str):
672 if isinstance(name, str):
679 except CosNaming.NamingContext.NotFound:
685 except CosNaming.NamingContext.CannotProceed
as err:
754 for i
in range(len(bl)):
755 if bl[i].binding_type == CosNaming.ncontext:
756 obj = context.resolve(bl[i].binding_name)
757 next_context = obj._narrow(CosNaming.NamingContext)
760 context.unbind(bl[i].binding_name)
761 next_context.destroy()
762 elif bl[i].binding_type == CosNaming.nobject:
763 context.unbind(bl[i].binding_name)
771 if not (CORBA.is_nil(bi)):
806 def list(self, name_cxt, how_many, rbl, rbi):
807 bl, bi = name_cxt.list(how_many)
836 if len(name_list) == 0:
837 raise CosNaming.NamingContext.InvalidName
843 return string_name[0]
864 raise CosNaming.NamingContext.InvalidName
870 nc_length = self.
split(string_name,
"/", name_comps)
872 if not (nc_length > 0):
873 raise CosNaming.NamingContext.InvalidName
875 name_list = [CosNaming.NameComponent(
"",
"")
for i
in range(nc_length)]
877 for i
in range(nc_length):
878 pos = string.rfind(name_comps[i][0:],
".")
880 name_list[i].id = name_comps[i]
881 name_list[i].kind =
""
883 name_list[i].id = name_comps[i][0:pos]
884 name_list[i].kind = name_comps[i][(pos+1):]
960 context.bind_context(name_list, obj)
962 except CosNaming.NamingContext.AlreadyBound:
963 obj = context.resolve(name_list)
965 return CORBA.Object._nil
990 if new_context
is None:
993 new_cxt = new_context
996 return obj._narrow(CosNaming.NamingContext)
1048 nc = obj._narrow(CosNaming.NamingContext)
1049 if CORBA.is_nil(nc):
1093 if end
is None or end < 0:
1094 end = len(name_list) - 1
1096 sub_len = end - (begin -1)
1101 for i
in range(sub_len):
1102 sub_name.append(name_list[begin + i])
1127 for i
in range(len(name_list)):
1128 for id_
in name_list[i].id:
1129 if id_ ==
"/" or id_ ==
"." or id_ ==
"\\":
1130 string_name[0] +=
"\\"
1131 string_name[0] += id_
1133 if name_list[i].id ==
"" or name_list[i].kind !=
"":
1134 string_name[0] +=
"."
1136 for kind_
in name_list[i].kind:
1137 if kind_ ==
"/" or kind_ ==
"." or kind_ ==
"\\":
1138 string_name[0] +=
"\\"
1139 string_name[0] += kind_
1141 string_name[0] +=
"/"
1164 for i
in range(len(name_list)):
1165 for id_
in name_list[i].id:
1166 if id_ ==
"/" or id_ ==
"." or id_ ==
"\\":
1169 if name_list[i].id ==
"" or name_list[i].kind ==
"":
1172 for kind_
in name_list[i].kind:
1173 if kind_ ==
"/" or kind_ ==
"." or kind_ ==
"\\":
1198 def split(self, input, delimiter, results):
1199 delim_size = len(delimiter)
1205 if input[0:delim_size] == delimiter:
1206 begin_pos = delim_size
1207 pre_pos = delim_size
1210 found_pos = string.find(input[begin_pos:],delimiter)
1212 results.append(input[pre_pos:])
1215 if found_pos > 0
and input[found_pos + begin_pos - 1] ==
"\\":
1216 begin_pos += found_pos + delim_size
1218 substr_size = found_pos + (begin_pos - pre_pos)
1220 results.append(input[pre_pos:(pre_pos+substr_size)])
1221 begin_pos += found_pos + delim_size
1239 if sys.version_info[0:3] >= (2, 4, 0):
1240 print(traceback.format_exc())
1242 _exc_list = traceback.format_exception(*sys.exc_info())
1243 _exc_str =
"".join(_exc_list)