def setUp(self): self._dbconn = qvarn.DatabaseConnection() self._dbconn.set_sql(qvarn.SqliteAdapter()) vs = qvarn.VersionedStorage() vs.set_resource_type(self.resource_type) vs.start_version(u'first-version', None) vs.add_prototype(self.prototype) vs.add_prototype(qvarn.listener_prototype, auxtable=u'listener') vs.add_prototype(qvarn.notification_prototype, auxtable=u'notification') with self._dbconn.transaction() as t: vs.prepare_storage(t) self.ro = qvarn.ReadOnlyStorage() self.ro.set_item_prototype(self.resource_type, self.prototype) self.wo = qvarn.WriteOnlyStorage() self.wo.set_item_prototype(self.resource_type, self.prototype) self.listener = qvarn.ListenerResource() self.listener.set_top_resource_path(self.resource_type, self.resource_type) self.listener.prepare_resource(self._dbconn) self.resource = qvarn.ListResource() self.resource.set_path(self.resource_type) self.resource.set_item_type(self.resource_type) self.resource.set_item_prototype(self.prototype) self.resource.set_listener(self.listener) self.resource.prepare_resource(self._dbconn)
def _create_list_resource(self, listener): resource = qvarn.ListResource() resource.set_path(self._path) resource.set_item_type(self._type) resource.set_item_prototype(self._latest_version[u'prototype']) resource.set_listener(listener) resource.set_item_validator(self._latest_version.get(u'validator')) subpaths = self._latest_version.get(u'subpaths', []) files = self._latest_version.get(u'files', []) for subpath in subpaths: if subpath not in files: proto = subpaths[subpath][u'prototype'] resource.set_subitem_prototype(subpath, proto) return resource
def setUp(self): self._dbconn = qvarn.DatabaseConnection() self._dbconn.set_sql(qvarn.SqliteAdapter()) vs = qvarn.VersionedStorage() vs.set_resource_type(self.resource_type) vs.start_version(u'first-version') vs.add_prototype(self.prototype) with self._dbconn.transaction() as t: vs.prepare_storage(t) self.ro = qvarn.ReadOnlyStorage() self.ro.set_item_prototype(self.resource_type, self.prototype) self.wo = qvarn.WriteOnlyStorage() self.wo.set_item_prototype(self.resource_type, self.prototype) self.resource = qvarn.ListResource() self.resource.set_path(self.resource_type) self.resource.set_item_type(self.resource_type) self.resource.set_item_prototype(self.prototype) self.resource.set_listener(FakeListenerResource()) self.resource.prepare_resource(self._dbconn)