Exemplo n.º 1
0
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])
Exemplo n.º 2
0
    def init_catalog(self):
        '''
        Create a repoze.catalog instance and specify
        indices of intereset
        '''        
        catalog = RCatalog()
        catalog.document_map = DocumentMap()                
        # set up indexes
        catalog['title'] = CatalogTextIndex('_get_title')
        catalog['titleSorter'] = CatalogFieldIndex('_get_sorter')
        catalog['collection'] = CatalogKeywordIndex('_get_collection')
        # Descriptions are converted to TEXT for indexing
        catalog['description'] = CatalogTextIndex('_get_description')
        catalog['startDate'] = CatalogFieldIndex('_get_startDate')
        catalog['endDate'] = CatalogFieldIndex('_get_endDate')
        catalog['modificationDate'] = CatalogFieldIndex('_get_modificationDate')
        catalog['fid'] = CatalogTextIndex('_get_fid')
        catalog['keywords'] = CatalogKeywordIndex('_get_keywordsList')
        catalog['category'] = CatalogKeywordIndex('_get_categoryList')
        # I define as Text because I would permit searched for part of names
        catalog['rolesVals'] = CatalogTextIndex('_get_roles')
        catalog['persons'] = CatalogTextIndex('_get_persons')

        # ICTP SPECIFIC: index a deadline date if found. Just COMMENT this line if not interested
        catalog['deadlineDate'] = CatalogFieldIndex('_get_deadlineDate')


        self.db.root()[self.catalogName] = catalog
        self.catalog = self.db.root()[self.catalogName] 
        # commit the indexes
        transaction.commit()
Exemplo n.º 3
0
 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())
Exemplo n.º 4
0
    def __init__(self):
        super(PeopleDirectory, self).__init__()
        self['categories'] = Folder()  # {id: PeopleCategory}
        self.catalog = CachingCatalog()
        self.catalog.document_map = DocumentMap()
        self.update_indexes()

        # Set up a default configuration
        self['all'] = section = PeopleSection('All')
        section['all'] = report = PeopleReport('All')
        report.columns = ('name', 'organization', 'location', 'email')
        self.order = ['all']
Exemplo n.º 5
0
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']
Exemplo n.º 6
0
    def __init__(self):
        super(Site, self).__init__()
        self.catalog = CachingCatalog()
        self.update_indexes()
        self.catalog.document_map = DocumentMap()

        profiles = create_content(IProfiles)
        self['profiles'] = profiles
        communities = create_content(ICommunities)
        self['communities'] = communities
        people = create_content(IPeopleDirectory)
        self['people'] = people
        self.users = KARLUsers(self)
        self.tags = Tags(self)
        self.sessions = SessionDataManager(3600, 5)
        self.filestore = PersistentMapping()
        self.list_aliases = OOBTree()
Exemplo n.º 7
0
Arquivo: site.py Projeto: lslaz1/karl
    def __init__(self):
        super(Site, self).__init__()
        self.catalog = CachingCatalog()
        self.update_indexes()
        self.catalog.document_map = DocumentMap()

        profiles = create_content(IProfiles)
        self['profiles'] = profiles
        communities = create_content(ICommunities)
        self['communities'] = communities
        people = create_content(IPeopleDirectory)
        self['people'] = people
        self.users = KARLUsers(self)
        self.tags = Tags(self)
        self.sessions = SessionDataManager(3600, 5)
        self.filestore = PersistentMapping()
        self.list_aliases = OOBTree()
        self.settings = OOBTree(self._default_settings)
        self.access_requests = OOBTree()
        self.failed_login_attempts = OOBTree()
        self.email_templates = OOBTree()
        self.denial_tracker = OOBTree()
        self['email_images'] = EmailFolder()
        self['invitations'] = create_content(IInvitationsFolder)
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 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)