def _do_traverse(self, path): objs, unresolved_path = self.traverse_full(path) if not objs or unresolved_path: self.write('No such object: %s\n' % path) return if not IContainer.providedBy(objs[-1]): self.write('Cannot cd to a non-container\n') return # Fixes #41. if os.path.isabs(path): objs.insert(0, db.deref(self.obj_path[0])) # Handle '//foo/bar//fee' path_components = path.split('/') path_components[1:] = [ comp for comp in path_components[1:] if comp != '' ] oms_root = self.obj_path[0] if path_components[0] == '': del self.obj_path[:] del self.path[:] for obj, name in zip(objs, path_components): ref = db.ref(obj) if name == '.' or (ref == oms_root and oms_root in self.obj_path): continue self.obj_path.append(ref) self.path.append(name)
def _do_traverse(self, path): objs, unresolved_path = self.traverse_full(path) if not objs or unresolved_path: self.write('No such object: %s\n' % path) return if not IContainer.providedBy(objs[-1]): self.write('Cannot cd to a non-container\n') return # Fixes #41. if os.path.isabs(path): objs.insert(0, db.deref(self.obj_path[0])) # Handle '//foo/bar//fee' path_components = path.split('/') path_components[1:] = [comp for comp in path_components[1:] if comp != ''] oms_root = self.obj_path[0] if path_components[0] == '': del self.obj_path[:] del self.path[:] for obj, name in zip(objs, path_components): ref = db.ref(obj) if name == '.' or (ref == oms_root and oms_root in self.obj_path): continue self.obj_path.append(ref) self.path.append(name)
def ensure_fixed_up(self, name, op): from opennode.oms.zodb.db import ref, deref if not forbidden_outside_transaction(self, name): return if isInIOThread(): msg = ("Cannot %s '%s' attribute from persistent proxy object '%s' " "while in the main thread" % (op, name, self)) if get_config().getboolean('debug', 'print_exceptions'): log.msg(msg, system='zodb') import traceback traceback.print_stack() raise Exception(msg) oid = ref(object.__getattribute__(self, "_obj")) if oid is not None: new_obj = deref(oid) object.__setattr__(self, "_obj", new_obj) object.__setattr__(self, "_fixed_up", True)