def bootstrap(zodb_root, app_root_id, request): """Setup Root Object and the ZODB Database structure""" if not app_root_id in zodb_root: # add root folders app_root = WebshopAPI() zodb_root[app_root_id] = app_root zodb_root[app_root_id]["categories"] = Folder() zodb_root[app_root_id]["item_groups"] = Folder() zodb_root[app_root_id]["items"] = Folder() zodb_root[app_root_id]["unit_of_measures"] = Folder() zodb_root[app_root_id]["vpe_types"] = Folder() # add repoze.catalog for indexing app_root["catalog"] = Catalog() app_root["catalog"]['parent_id'] = CatalogFieldIndex(get_parent_id) app_root["catalog"]['id'] = CatalogFieldIndex(get_id) app_root["catalog"]['__type__'] = CatalogFieldIndex(get__type__) app_root["catalog"]['group'] = CatalogFieldIndex(get_group) app_root["catalog"]['vpe_type_id'] = CatalogFieldIndex(get_vpe_type_id) app_root["catalog"]['unit_of_measure_id'] = \ CatalogFieldIndex(get_unit_of_measure_id) app_root["catalog"]['quality_id'] = CatalogFieldIndex(get_quality_id) app_root["catalog"]['vpe_default'] = CatalogFieldIndex(get_vpe_default) app_root["catalog"]['title_url_slugs'] = CatalogKeywordIndex( get_title_url_slugs) app_root["catalog"]['shop_id'] = CatalogKeywordIndex(get_shop_ids) app_root["document_map"] = DocumentMap() transaction.commit() return Root(request, zodb_root[app_root_id])
def __call__(self, context): catalog = Catalog() idindexer = NodeAttributeIndexer('id') catalog['id'] = CatalogFieldIndex(idindexer) searchable_blob = NodeAttributeIndexer('searchable_text') catalog['searchable_text'] = CatalogTextIndex(searchable_blob) notlegit = NodeAttributeIndexer('notlegit') catalog['notlegit'] = CatalogFieldIndex(notlegit) userindexer = NodeAttributeIndexer('username') catalog['username'] = CatalogTextIndex(userindexer) fullname = NodeAttributeIndexer('fullname') catalog['fullname'] = CatalogTextIndex(fullname) email = NodeAttributeIndexer('email') catalog['email'] = CatalogTextIndex(email) location = NodeAttributeIndexer('location') catalog['location'] = CatalogTextIndex(location) dni = NodeAttributeIndexer('dni') catalog['dni'] = CatalogTextIndex(dni) user_type = NodeAttributeIndexer('user_type') catalog['user_type'] = CatalogTextIndex(user_type) check_ubicacio = NodeAttributeIndexer('check_ubicacio') catalog['check_ubicacio'] = CatalogTextIndex(check_ubicacio) ubicacio = NodeAttributeIndexer('ubicacio') catalog['ubicacio'] = CatalogTextIndex(ubicacio) check_telefon = NodeAttributeIndexer('check_telefon') catalog['check_telefon'] = CatalogTextIndex(check_telefon) telefon = NodeAttributeIndexer('telefon') catalog['telefon'] = CatalogTextIndex(telefon) check_twitter_username = NodeAttributeIndexer('check_twitter_username') catalog['check_twitter_username'] = CatalogTextIndex( check_twitter_username) twitter_username = NodeAttributeIndexer('twitter_username') catalog['twitter_username'] = CatalogTextIndex(twitter_username) return catalog
def __call__(self, context): catalog = Catalog() path = NodeAttributeIndexer('path') catalog['path'] = CatalogFieldIndex(path) uuid = NodeAttributeIndexer('uuid') catalog['uuid'] = CatalogFieldIndex(uuid) return catalog
def test_it(self): from repoze.catalog.catalog import Catalog from repoze.catalog.indexes.field import CatalogFieldIndex from repoze.catalog.indexes.keyword import CatalogKeywordIndex from repoze.catalog.indexes.text import CatalogTextIndex catalog = Catalog() catalog['name'] = CatalogFieldIndex('name') catalog['title'] = CatalogFieldIndex('title') catalog['text'] = CatalogTextIndex('text') catalog['allowed'] = CatalogKeywordIndex('allowed') catalog.index_doc(1, Content('name1', 'title1', 'body one', ['a'])) catalog.index_doc(2, Content('name2', 'title2', 'body two', ['b'])) catalog.index_doc(3, Content('name3', 'title3', 'body three', ['c'])) catalog.index_doc(4, Content('name4', None, 'body four', ['a', 'b'])) catalog.index_doc( 5, Content('name5', 'title5', 'body five', ['a', 'b', 'c'])) catalog.index_doc(6, Content('name6', 'title6', 'body six', ['d'])) numdocs, result = catalog.query(self.query, sort_index='name', limit=5, names=dict(body='body')) self.assertEqual(numdocs, 2) self.assertEqual(list(result), [4, 5])
def __call__(self, context): catalog = Catalog() idindexer = NodeAttributeIndexer('id_menusoup') catalog['id_menusoup'] = CatalogTextIndex(idindexer) containerindexer = NodeAttributeIndexer('dades') catalog['dades'] = CatalogFieldIndex(containerindexer) return catalog
def __call__(self, context=None): catalog = Catalog() email_indexer = NodeAttributeIndexer('email') catalog[u'email'] = CatalogFieldIndex(email_indexer) uid_indexer = NodeAttributeIndexer('uid') catalog[u'uid'] = CatalogFieldIndex(uid_indexer) buyable_uid_indexer = NodeAttributeIndexer('buyable_uid') catalog[u'buyable_uid'] = CatalogFieldIndex(buyable_uid_indexer) order_uid_indexer = NodeAttributeIndexer('order_uid') catalog[u'order_uid'] = CatalogFieldIndex(order_uid_indexer) vendor_uid_indexer = NodeAttributeIndexer('vendor_uid') catalog[u'vendor_uid'] = CatalogFieldIndex(vendor_uid_indexer) creator_indexer = NodeAttributeIndexer('creator') catalog[u'creator'] = CatalogFieldIndex(creator_indexer) created_indexer = NodeAttributeIndexer('created') catalog[u'created'] = CatalogFieldIndex(created_indexer) exported_indexer = NodeAttributeIndexer('exported') catalog[u'exported'] = CatalogFieldIndex(exported_indexer) title_indexer = NodeAttributeIndexer('title') catalog[u'title'] = CatalogFieldIndex(title_indexer) state_indexer = NodeAttributeIndexer('state') catalog[u'state'] = CatalogFieldIndex(state_indexer) salaried_indexer = NodeAttributeIndexer('salaried') catalog[u'salaried'] = CatalogFieldIndex(salaried_indexer) search_attributes = ['email', 'title'] text_indexer = NodeTextIndexer(search_attributes) catalog[u'text'] = CatalogTextIndex(text_indexer) return catalog
def __call__(self, context): catalog = Catalog() groupindexer = NodeAttributeIndexer('id') catalog['id'] = CatalogFieldIndex(groupindexer) idsearchableindexer = NodeAttributeIndexer('searchable_id') catalog['searchable_id'] = CatalogTextIndex(idsearchableindexer) return catalog
def __call__(self, context): catalog = Catalog() idindexer = NodeAttributeIndexer('id_username') catalog['id_username'] = CatalogTextIndex(idindexer) portrait = NodeAttributeIndexer('portrait') catalog['portrait'] = CatalogFieldIndex(portrait) return catalog
def clear_catalog(self, catalog_id): try: catalog = getattr(self, catalog_id) doc_map = getattr(self, catalog_id + '_map') except: raise Exception("Catalog " + catalog_id + " doenst exist.") setattr(self, catalog_id, Catalog()) setattr(self, catalog_id + '_map', DocumentMap())
def __call__(self, context): catalog = Catalog() idindexer = NodeAttributeIndexer('id') catalog['id'] = CatalogFieldIndex(idindexer) hashindex = NodeAttributeIndexer('searches') catalog['searches'] = CatalogKeywordIndex(hashindex) return catalog
def __call__(self, context: typing.Union[Record, None] = None) -> Catalog: catalog = Catalog() catalog["uid"] = CatalogFieldIndex(NodeAttributeIndexer("uid")) catalog["group"] = CatalogFieldIndex(NodeAttributeIndexer("group")) catalog["created"] = CatalogFieldIndex(NodeAttributeIndexer("created")) catalog["owner"] = CatalogFieldIndex(NodeAttributeIndexer("owner")) catalog["queryparams"] = CatalogFieldIndex( NodeAttributeIndexer("queryparams")) return catalog
def __call__(self, context): catalog = Catalog() idindexer = NodeAttributeIndexer('id') catalog['id'] = CatalogFieldIndex(idindexer) userindexer = NodeAttributeIndexer('username') catalog['username'] = CatalogTextIndex(userindexer) unit_organizational = NodeAttributeIndexer('unit_organizational') catalog['unit_organizational'] = CatalogTextIndex(unit_organizational) position = NodeAttributeIndexer('position') catalog['position'] = CatalogTextIndex(position) return catalog
def __init__(self, parent, indices=None): ZopeDict.__init__(self) self.__parent__ = parent parent[self.__name__] = self self._cat = Catalog() if indices is None: self._currentIndex = "" else: self._currentIndex = indices[0] for index in indices: self._cat[index] = CatalogFieldIndex(index)
def __call__(self, context): catalog = Catalog() channels_indexer = NodeAttributeIndexer("channels") catalog[u"channels"] = CatalogKeywordIndex(channels_indexer) date_indexer = NodeAttributeIndexer("date") catalog[u"date"] = CatalogFieldIndex(date_indexer) title_indexer = NodeAttributeIndexer("title") catalog[u"title"] = CatalogTextIndex(title_indexer) type_indexer = NodeAttributeIndexer("type") catalog[u"type"] = CatalogFieldIndex(type_indexer) return catalog
def bootstrap(zodb_root): if not 'projector' in zodb_root: # add site folder root = SiteFolder('Projector Site') zodb_root['projector'] = root # add catalog and document map catalog = Catalog() catalog['title'] = CatalogTextIndex('title') catalog['content'] = CatalogTextIndex('content') root.catalog = catalog document_map = DocumentMap() root.document_map = document_map return zodb_root['projector']
def __call__(self, context): if not isinstance(context, SoupAdapter): raise ValueError('Current context must be a SoupAdapter') pfg = aq_parent(context) catalog = Catalog() for field in pfg._getFieldObjects(): pfgindexadder = queryAdapter(field, IAddPfgIndex) if pfgindexadder is None: continue pfgindexadder(catalog) for field_id in auto_field_ids(): indexer = NodeAttributeIndexer(field_id) catalog[field_id] = CatalogFieldIndex(indexer) return catalog
def _get_model_root(cls): root = cls._get_connection().root if not hasattr(root, cls.Meta.table): model_root = BTrees.OOBTree.BTree() setattr(root, cls.Meta.table, model_root) model_root['objects'] = BTrees.OOBTree.BTree() model_root['catalog'] = Catalog() model_root['catalog_index'] = None model_root = getattr(root, cls.Meta.table) # Regenerate index fields? if 'catalog_index' not in model_root or model_root[ 'catalog_index'] != cls._get_index_fields(): catalog = Catalog() for field in cls._get_index_fields(): catalog[field] = CatalogFieldIndex(field) model_root['catalog'] = catalog model_root['catalog_index'] = cls._get_index_fields() cls.commit() cls.index() return model_root
def __call__(self, context=None): catalog = Catalog() r_uid_indexer = NodeAttributeIndexer(REMOTE_UID) catalog[unicode(REMOTE_UID)] = CatalogFieldIndex(r_uid_indexer) l_uid_indexer = NodeAttributeIndexer(LOCAL_UID) catalog[unicode(LOCAL_UID)] = CatalogFieldIndex(l_uid_indexer) r_path_indexer = NodeAttributeIndexer(REMOTE_PATH) catalog[unicode(REMOTE_PATH)] = CatalogFieldIndex(r_path_indexer) l_path_indexer = NodeAttributeIndexer(LOCAL_PATH) catalog[unicode(LOCAL_PATH)] = CatalogFieldIndex(l_path_indexer) return catalog
def __call__(self, context): catalog = Catalog() text_indexer = NodeTextIndexer(["name", "surname", "email"]) catalog[u"text"] = CatalogTextIndex(text_indexer) email_indexer = NodeAttributeIndexer("email") catalog[u"email"] = CatalogFieldIndex(email_indexer) name_indexer = NodeAttributeIndexer("name") catalog[u"name"] = CatalogFieldIndex(name_indexer) surname_indexer = NodeAttributeIndexer("surname") catalog[u"surname"] = CatalogFieldIndex(surname_indexer) channels_indexer = NodeAttributeIndexer("channels") catalog[u"channels"] = CatalogKeywordIndex(channels_indexer) date_indexer = NodeAttributeIndexer("date") catalog[u"date"] = CatalogFieldIndex(date_indexer) newspaper_indexer = NodeAttributeIndexer("newspaper") catalog[u"newspaper"] = CatalogFieldIndex(newspaper_indexer) return catalog
def __call__(self, context): catalog = Catalog() idindexer = NodeAttributeIndexer('id') catalog['id'] = CatalogFieldIndex(idindexer) userindexer = NodeAttributeIndexer('username') catalog['username'] = CatalogTextIndex(userindexer) fullname = NodeAttributeIndexer('fullname') catalog['fullname'] = CatalogTextIndex(fullname) email = NodeAttributeIndexer('email') catalog['email'] = CatalogTextIndex(email) wop_platforms = NodeAttributeIndexer('wop_platforms') catalog['wop_platforms'] = CatalogTextIndex(wop_platforms) wop_programs = NodeAttributeIndexer('wop_programs') catalog['wop_programs'] = CatalogTextIndex(wop_programs) wop_partners = NodeAttributeIndexer('wop_partners') catalog['wop_partners'] = CatalogTextIndex(wop_partners) country = NodeAttributeIndexer('country') catalog['country'] = CatalogTextIndex(country) position = NodeAttributeIndexer('position') catalog['position'] = CatalogTextIndex(position) type_of_organization = NodeAttributeIndexer('type_of_organization') catalog['type_of_organization'] = CatalogTextIndex(type_of_organization) common_working_areas = NodeAttributeIndexer('common_working_areas') catalog['common_working_areas'] = CatalogTextIndex(common_working_areas) donors = NodeAttributeIndexer('donors') catalog['donors'] = CatalogTextIndex(donors) other_info = NodeAttributeIndexer('other_info') catalog['other_info'] = CatalogTextIndex(other_info) return catalog
def __call__(self, context): catalog = Catalog() idindexer = NodeAttributeIndexer('id') catalog['id'] = CatalogFieldIndex(idindexer) searchable_blob = NodeAttributeIndexer('searchable_text') catalog['searchable_text'] = CatalogTextIndex(searchable_blob) notlegit = NodeAttributeIndexer('notlegit') catalog['notlegit'] = CatalogFieldIndex(notlegit) userindexer = NodeAttributeIndexer('username') catalog['username'] = CatalogTextIndex(userindexer) fullname = NodeAttributeIndexer('fullname') catalog['fullname'] = CatalogTextIndex(fullname) email = NodeAttributeIndexer('email') catalog['email'] = CatalogTextIndex(email) location = NodeAttributeIndexer('location') catalog['location'] = CatalogTextIndex(location) home_page = NodeAttributeIndexer('home_page') catalog['home_page'] = CatalogTextIndex(home_page) return catalog
def __call__(self, context=None): catalog = Catalog() # uid of context rule refers to context_uid_indexer = NodeAttributeIndexer('context_uid') catalog[u'context_uid'] = CatalogFieldIndex(context_uid_indexer) # rule category category_indexer = NodeAttributeIndexer('category') catalog[u'category'] = CatalogFieldIndex(category_indexer) # rule valid from date valid_from_indexer = NodeAttributeIndexer('valid_from') catalog[u'valid_from'] = CatalogFieldIndex(valid_from_indexer) # rule valid to date valid_to_indexer = NodeAttributeIndexer('valid_to') catalog[u'valid_to'] = CatalogFieldIndex(valid_to_indexer) # user this rule applies user_indexer = NodeAttributeIndexer('user') catalog[u'user'] = CatalogFieldIndex(user_indexer) # group this rule applies group_indexer = NodeAttributeIndexer('group') catalog[u'group'] = CatalogFieldIndex(group_indexer) return catalog
def __call__(self, context=None): catalog = Catalog() uid_indexer = NodeAttributeIndexer('uid') catalog[u'uid'] = CatalogFieldIndex(uid_indexer) email_indexer = NodeAttributeIndexer('personal_data.email') catalog[u'personal_data.email'] = CatalogFieldIndex(email_indexer) ordernumber_indexer = NodeAttributeIndexer('ordernumber') catalog[u'ordernumber'] = CatalogFieldIndex(ordernumber_indexer) booking_uids_indexer = NodeAttributeIndexer('booking_uids') catalog[u'booking_uids'] = CatalogKeywordIndex(booking_uids_indexer) vendor_uids_indexer = NodeAttributeIndexer('vendor_uids') buyable_uids_indexer = NodeAttributeIndexer('buyable_uids') catalog[u'buyable_uids'] = CatalogKeywordIndex(buyable_uids_indexer) catalog[u'vendor_uids'] = CatalogKeywordIndex(vendor_uids_indexer) creator_indexer = NodeAttributeIndexer('creator') catalog[u'creator'] = CatalogFieldIndex(creator_indexer) created_indexer = NodeAttributeIndexer('created') catalog[u'created'] = CatalogFieldIndex(created_indexer) firstname_indexer = NodeAttributeIndexer('personal_data.firstname') catalog[u'personal_data.firstname'] = \ CatalogFieldIndex(firstname_indexer) lastname_indexer = NodeAttributeIndexer('personal_data.lastname') catalog[u'personal_data.lastname'] = \ CatalogFieldIndex(lastname_indexer) city_indexer = NodeAttributeIndexer('billing_address.city') catalog[u'billing_address.city'] = CatalogFieldIndex(city_indexer) search_attributes = [ 'personal_data.lastname', 'personal_data.firstname', 'personal_data.email', 'billing_address.city', 'ordernumber' ] text_indexer = NodeTextIndexer(search_attributes) catalog[u'text'] = CatalogTextIndex(text_indexer) # state on order only used for sorting in orders table state_indexer = NodeAttributeIndexer('state') catalog[u'state'] = CatalogFieldIndex(state_indexer) # salaried on order only used for sorting in orders table salaried_indexer = NodeAttributeIndexer('salaried') catalog[u'salaried'] = CatalogFieldIndex(salaried_indexer) return catalog
def __call__(self, context=None): catalog = Catalog() uid_indexer = NodeAttributeIndexer('uid') catalog[u'uid'] = CatalogFieldIndex(uid_indexer) email_indexer = NodeAttributeIndexer('personal_data.email') catalog[u'email'] = CatalogFieldIndex(email_indexer) cid_indexer = NodeAttributeIndexer('cid') catalog[u'cid'] = CatalogFieldIndex(cid_indexer) firstname_indexer = ContactAttributeIndexer('personal_data.firstname') catalog[u'firstname'] = CatalogFieldIndex(firstname_indexer) lastname_indexer = ContactAttributeIndexer('personal_data.lastname') catalog[u'lastname'] = CatalogFieldIndex(lastname_indexer) zip_indexer = ContactAttributeIndexer('billing_address.zip') catalog[u'zip'] = CatalogFieldIndex(zip_indexer) street_indexer = ContactAttributeIndexer('billing_address.street') catalog[u'street'] = CatalogFieldIndex(street_indexer) search_attributes = ['personal_data.email', 'personal_data.firstname', 'personal_data.lastname' ] text_indexer = NodeTextIndexer(search_attributes) catalog[u'text'] = CatalogTextIndex(text_indexer) return catalog
def __init__(self): self._init() self.node_catalog = Catalog() self.edge_catalog = Catalog()
def __init__(self, data=None, **kwargs): self.catalog = Catalog() self.document_map = DocumentMap() populate_catalog(self.catalog) self.__site_settings__ = OOBTree() super(Root, self).__init__(data=data, **kwargs)
def CatalogFactory(): catalog = Catalog() catalog['text'] = CatalogTextIndex(get_text) catalog['page'] = CatalogFieldIndex(get_page) return catalog
def add_catalog(self, catalog_id): setattr(self, catalog_id, Catalog()) setattr(self, catalog_id + '_map', DocumentMap()) self.catalogs.append(catalog_id) return getattr(self, catalog_id)
def _get_catalog(cls): model_root = cls._get_model_root() if 'catalog' not in model_root: model_root['catalog'] = Catalog() return model_root['catalog']
def __init__(self, data=None, **kwargs): self.catalog = Catalog() self.catalog.__parent__ = self #To make traversal work self.catalog.document_map = DocumentMap() super(SiteRoot, self).__init__(data=data, **kwargs) update_indexes(self.catalog)