19 import omniORB.CORBA
as CORBA
87 self.
_nameServer =
"corbaloc::" + name_server +
"/NameService"
92 print(
"CorbaNaming: Failed to narrow the root naming context.")
94 except CORBA.ORB.InvalidName:
95 print(
"Service required is invalid [does not exist].")
130 self.
_nameServer =
"corbaloc::" + name_server +
"/NameService"
132 self.
_rootContext = obj._narrow(CosNaming.NamingContext)
185 def bind(self, name_list, obj, force=None):
191 except CosNaming.NamingContext.NotFound:
196 except CosNaming.NamingContext.CannotProceed
as err:
201 except CosNaming.NamingContext.AlreadyBound:
230 self.
bind(self.
toName(string_name), obj, force)
269 length = len(name_list)
271 for i
in range(length):
274 cxt.bind(self.
subName(name_list, i, i), obj)
275 except CosNaming.NamingContext.AlreadyBound:
276 cxt.rebind(self.
subName(name_list, i, i), obj)
282 raise CosNaming.NamingContext.CannotProceed(cxt, self.
subName(name_list, i))
310 def rebind(self, name_list, obj, force=True):
317 except CosNaming.NamingContext.NotFound:
323 except CosNaming.NamingContext.CannotProceed
as err:
386 length = len(name_list)
387 for i
in range(length):
389 context.rebind(self.
subName(name_list, i, i), obj)
394 context = context.bind_new_context(self.
subName(name_list, i, i))
395 except CosNaming.NamingContext.AlreadyBound:
396 obj_ = context.resolve(self.
subName(name_list, i, i))
397 context = obj_._narrow(CosNaming.NamingContext)
399 raise CosNaming.NamingContext.CannotProceed(context, self.
subName(name_list, i))
428 if isinstance(name, str):
431 self.
bind(name, name_cxt, force)
482 if isinstance(name, str):
485 self.
rebind(name, name_cxt, force)
539 if isinstance(name, str):
547 except CosNaming.NamingContext.NotFound
as ex:
579 if isinstance(name, str):
637 if isinstance(name, str):
644 except CosNaming.NamingContext.NotFound:
649 except CosNaming.NamingContext.CannotProceed
as err:
717 for i
in range(len(bl)):
718 if bl[i].binding_type == CosNaming.ncontext:
719 obj = context.resolve(bl[i].binding_name)
720 next_context = obj._narrow(CosNaming.NamingContext)
723 context.unbind(bl[i].binding_name)
724 next_context.destroy()
725 elif bl[i].binding_type == CosNaming.nobject:
726 context.unbind(bl[i].binding_name)
734 if not (CORBA.is_nil(bi)):
769 def list(self, name_cxt, how_many, rbl, rbi):
770 bl, bi = name_cxt.list(how_many)
799 if len(name_list) == 0:
800 raise CosNaming.NamingContext.InvalidName
827 raise CosNaming.NamingContext.InvalidName
833 nc_length = self.
split(string_name,
"/", name_comps)
834 if not (nc_length > 0):
835 raise CosNaming.NamingContext.InvalidName
837 name_list = [CosNaming.NameComponent(
"",
"")
for i
in range(nc_length)]
839 for i
in range(nc_length):
840 pos = string.rfind(name_comps[i][0:],
".")
842 name_list[i].id = name_comps[i]
843 name_list[i].kind =
""
845 name_list[i].id = name_comps[i][0:pos]
846 name_list[i].kind = name_comps[i][(pos+1):]
922 context.bind_context(name_list, obj)
924 except CosNaming.NamingContext.AlreadyBound:
925 obj = context.resolve(name_list)
927 return CORBA.Object._nil
952 if new_context
is None:
955 new_cxt = new_context
958 return obj._narrow(CosNaming.NamingContext)
1010 nc = obj._narrow(CosNaming.NamingContext)
1011 if CORBA.is_nil(nc):
1055 if end
is None or end < 0:
1056 end = len(name_list) - 1
1058 sub_len = end - (begin -1)
1063 for i
in range(sub_len):
1064 sub_name.append(name_list[begin + i])
1089 for i
in range(len(name_list)):
1090 for id_
in name_list[i].id:
1091 if id_ ==
"/" or id_ ==
"." or id_ ==
"\\":
1092 string_name[0] +=
"\\"
1093 string_name[0] += id_
1095 if name_list[i].id ==
"" or name_list[i].kind !=
"":
1096 string_name[0] +=
"."
1098 for kind_
in name_list[i].kind:
1099 if kind_ ==
"/" or kind_ ==
"." or kind_ ==
"\\":
1100 string_name[0] +=
"\\"
1101 string_name[0] += kind_
1103 string_name[0] +=
"/"
1126 for i
in range(len(name_list)):
1127 for id_
in name_list[i].id:
1128 if id_ ==
"/" or id_ ==
"." or id_ ==
"\\":
1131 if name_list[i].id ==
"" or name_list[i].kind ==
"":
1134 for kind_
in name_list[i].kind:
1135 if kind_ ==
"/" or kind_ ==
"." or kind_ ==
"\\":
1160 def split(self, input, delimiter, results):
1161 delim_size = len(delimiter)
1162 found_pos = begin_pos = pre_pos = substr_size = 0
1164 if input[0:delim_size] == delimiter:
1165 begin_pos = pre_pos = delim_size
1168 found_pos = string.find(input[begin_pos:],delimiter)
1171 results.append(input[pre_pos:])
1174 if found_pos > 0
and input[found_pos - 1] ==
"\\":
1175 begin_pos += found_pos + delim_size
1177 substr_size = found_pos + (begin_pos - pre_pos)
1179 results.append(input[pre_pos:(pre_pos+substr_size)])
1180 begin_pos += found_pos + delim_size