Show
Ignore:
Timestamp:
10/18/09 21:40:10 (3 years ago)
Author:
mauro
Message:

* rebuild catalog action on biosqlroot's view and triggered by modify event
* choice seqrecord key field (fix #6)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • plone4bio.biosql/trunk/src/plone4bio/biosql/content/root.py

    r88 r112  
    1111from Products.CMFCore.permissions import View 
    1212from Products.CMFCore.interfaces import IFolderish 
     13from Products.CMFCore.utils import getToolByName 
     14from Products.CMFPlone.utils import base_hasattr 
     15from Products.CMFPlone.utils import safe_callable 
    1316from zope.app.container.interfaces import IContainer 
    1417from plone.app.content.interfaces import INameFromTitle 
     
    4952    # isPrincipiaFolderish = True # already on Container 
    5053    dsn = FieldProperty(IBioSQLRoot['dsn']) 
     54    seqrecord_key = FieldProperty(IBioSQLRoot['seqrecord_key']) 
    5155    _v_dbserver = None 
     56 
     57    # see CMFPlone/CatalogTool.py 
     58    def refreshCatalog(self, clear=1): 
     59        def indexObject(obj, path): 
     60            if (base_hasattr(obj, 'indexObject') and 
     61                safe_callable(obj.indexObject)): 
     62                try: 
     63                    obj.indexObject() 
     64                except TypeError: 
     65                    # Catalogs have 'indexObject' as well, but they 
     66                    # take different args, and will fail 
     67                    pass 
     68        for database in self.values(): 
     69            database.invalidateCache() 
     70        portal_catalog = getToolByName(self, 'portal_catalog') 
     71        for obj in portal_catalog.searchResults(path=self.absolute_url_path()): 
     72            portal_catalog.uncatalog_object(obj.getPath()) 
     73        portal_catalog.ZopeFindAndApply(self, search_sub=True, apply_func=indexObject) 
     74 
     75    def __getattr__(self, name): 
     76        if self.has_key(name): 
     77            return self[name] 
     78        else: 
     79            raise AttributeError, name 
    5280 
    5381    security.declareProtected(View, "getBioSQLRoot")