def remove(self, remote): store = Store.of(self._local) if store is None: raise NoStoreError("Can't perform operation without a store") where = (self._relation1.get_where_for_remote(self._local) & self._relation2.get_where_for_remote(remote)) store.find(self._link_cls, where).remove()
def remove(self, remote): store = Store.of(self._local) if store is None: raise NoStoreError("Can't perform operation without a store") # Don't use remote here, as it might be security proxied or something. remote = get_obj_info(remote).get_obj() where = (self._relation1.get_where_for_remote(self._local) & self._relation2.get_where_for_remote(remote)) store.find(self._link_cls, where).remove()
def clear(self, *args, **kwargs): set_kwargs = {} for remote_column in self._relation.remote_key: set_kwargs[remote_column.name] = None store = Store.of(self._local) if store is None: raise NoStoreError("Can't perform operation without a store") where = self._relation.get_where_for_remote(self._local) store.find(self._target_cls, where, *args, **kwargs).set(**set_kwargs)
def find(self, *args, **kwargs): store = Store.of(self._local) if store is None: raise NoStoreError("Can't perform operation without a store") where = self._get_where_clause() result = store.find(self._target_cls, where, *args, **kwargs) if self._order_by is not None: result.order_by(*self._order_by) return result
def __init__(self, instance, fieldName): self.instance = instance self.fieldName = unicode(instance.__storm_table__) + u"." + fieldName self.store = Store.of(instance) if self.store is None: raise NoStoreError("Store is needed to initialize a ForeignHelper") self.supplement = self.store.find( ForeignSupplement, And((ForeignSupplement.LocalID == self.instance.ID), (ForeignSupplement.FieldName == self.fieldName))).any()
def find(self, *args, **kwargs): store = Store.of(self._local) if store is None: raise NoStoreError("Can't perform operation without a store") where = (self._relation1.get_where_for_remote(self._local) & self._relation2.get_where_for_join()) result = store.find(self._target_cls, where, *args, **kwargs) if self._order_by is not None: result.order_by(self._order_by) return result
def clear(self, *args, **kwargs): store = Store.of(self._local) if store is None: raise NoStoreError("Can't perform operation without a store") where = self._relation1.get_where_for_remote(self._local) if args or kwargs: filter = get_where_for_args(args, kwargs, self._target_cls) join = self._relation2.get_where_for_join() table = get_cls_info(self._target_cls).table where &= Exists(Select(SQLRaw("*"), join & filter, tables=table)) store.find(self._link_cls, where).remove()
def _forceStore(self, exceptionMessage=None): store = Store.of(self) if store is None: raise NoStoreError(exceptionMessage if exceptionMessage is not None else u"A store is needed to do that.") return store
def _get_store(self): store = Store.of(self) if store is None: raise NoStoreError('Operation not possible without a store.') return store