def _bind(self, name, obj): """ Binds a name to an object in this context. """ # Get the actual state to bind from the naming manager. state = naming_manager.get_state_to_bind(obj, name, self) # If the object is actually an abstract file then we don't have to # do anything. if isinstance(state, File): if not state.exists: state.create_file() filename = name # Otherwise we are binding an arbitrary Python object, so find a # serializer for it. else: for serializer in self._get_object_serializers(): if serializer.can_save(obj): path = serializer.save(join(self.path, name), obj) filename = os.path.basename(path) break else: raise ValueError('cannot serialize object %s' % name) # Update the name to filename map. self._name_to_filename_map[name] = filename # Update the cache. self._cache[name] = obj return state
def _bind(self, name, obj): """ Binds a name to an object in this context. """ state = naming_manager.get_state_to_bind(obj, name, self) self._bindings[name] = state return
def _bind(self, name, obj): """ Binds a name to an object in this context. """ state = naming_manager.get_state_to_bind(obj, name, self) self.namespace[name] = state # Trait event notification. # An "added" event is fired by the bind method of the base calss (which calls # this one), so we don't need to do the changed here (which would be the wrong # thing anyway) -- LGV # # self.trait_property_changed('context_changed', None, None) return
def _bind(self, name, obj): """ Binds a name to an object in this context. """ state = naming_manager.get_state_to_bind(obj, name,self) self.namespace[name] = state # Trait event notification. # An "added" event is fired by the bind method of the base calss (which calls # this one), so we don't need to do the changed here (which would be the wrong # thing anyway) -- LGV # # self.trait_property_changed('context_changed', None, None) return