Changeset 112 for plone4bio.biosql

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

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

Location:
plone4bio.biosql/trunk
Files:
7 added
14 modified

Legend:

Unmodified
Added
Removed
  • plone4bio.biosql/trunk/README.txt

    r62 r112  
    55-------- 
    66 
    7 TODO 
     7... 
    88 
    99Developer Notes 
     
    1313they are mainly tested in that environment. Usually there should be no 
    1414problem in installing the products in GNU/Linux Zope/Plone environments. 
    15  
    16 Postgresql 
    17  
    18 :: 
    19  
    20     sudo apt-get install libpq-dev 
    21  
    22 Maintainer 
    23 ---------- 
    24  
    25 Mauro Amico (mauro AT biodec DOT com) is the active maintainer of the 
    26 *plone4bio.biosql* framework. 
  • plone4bio.biosql/trunk/docs/AUTHORS.txt

    r62 r112  
    1 Mauro Amico - mauro (at) biodec.com 
     1Maintainer 
     2---------- 
     3 
     4Mauro Amico (mauro AT biodec DOT com) is the active maintainer of the 
     5*plone4bio.biosql* framework. 
     6 
  • plone4bio.biosql/trunk/docs/CHANGES.txt

    r62 r112  
    33=========================== 
    44 
     5plone4bio.biosql 1.0.1 (unreleased) 
     6=================================== 
     7 
    58Features 
    69-------- 
    710 
    8 * Added the new object `predictor'. 
     11* rebuild catalog action 
    912 
    10 * TODO: add a fully working predictor. 
     13* choice seqrecord key field (fix #6) 
    1114 
     15Bug fixes 
     16--------- 
     17 
     18* "biosql bioentries are not addressable by their given database accession" (see #6) 
     19 
     20plone4bio.biosql 1.0.0 (2009-10-18) 
     21=================================== 
     22 
     23Features 
     24-------- 
     25 
     26* mysql / postgresql support 
     27 
     28* initial read/write biosql support 
    1229 
    1330plone4bio.biosql  (2008-07-01) 
  • plone4bio.biosql/trunk/setup.py

    r94 r112  
    11from setuptools import setup, find_packages 
     2version = '1.0.1' 
    23 
    3 version = '1.0.0' 
    4 readme = open('README.txt') 
    5 long_description = readme.read() 
    6 readme.close() 
     4def read(*rnames): 
     5    return open(os.path.join(os.path.dirname(__file__), *rnames)).read() 
     6 
     7long_description = ( 
     8    read('README.txt') 
     9    + '\n' + 
     10    'Detailed Documentation\n' 
     11    '**********************\n' 
     12    + '\n' + 
     13    read('src', 'plone4bio', 'biosql', 'README.txt') 
     14    + '\n' + 
     15    'Contributors\n' 
     16    '************\n' 
     17    + '\n' + 
     18    read('docs', 'AUTHORS.txt') 
     19    + '\n' + 
     20    'Change history\n' 
     21    '**************\n' 
     22    + '\n' + 
     23    read('docs', 'CHANGES.txt') 
     24    + '\n' + 
     25   'Download\n' 
     26    '********\n' 
    727 
    828tests_require = ['collective.testcaselayer'] 
     
    3454          # -*- Extra requirements: -*- 
    3555          'z3c.sqlalchemy', 
     56          'collective.monkeypatcher', 
    3657      ], 
    3758      tests_require=tests_require, 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/README.txt

    r62 r112  
    11.. -*-doctest-*- 
    2  
    3 ================ 
    4 plone4bio.biosql 
    5 ================ 
    6  
    7 Overview 
    8 ======== 
    92 
    103Create biosqlroot 
    114================= 
    125 
    13 Developer Notes 
    14 =============== 
    15  
    16 The plone4bio.* plone products are mainly developed on Debian Stable, so 
    17 they are mainly tested in that environment. Usually there should be no 
    18 problem in installing the products in other Zope/Plone environments. 
    19  
    20 Maintainer 
    21 ========== 
    22  
    23 Mauro Amico (mauro AT biodec DOT com) is the active maintainer of the 
    24 *plone4bio.biosql* framework. 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/browser/biosql.py

    r94 r112  
    1212from plone4bio.base.content.seqrecord import SeqRecord 
    1313from plone4bio.biosql.interfaces import IBioSQLRoot, IBioSQLDatabase, IBioSQLSeqRecord 
    14  
    15 class LongTextWidget(TextWidget): 
    16     displayWidth = 50 
    17  
    18 class BioSQLRootAddForm(base.AddForm): 
    19     """Add form """ 
    20     form_fields = form.Fields(IBioSQLRoot) 
    21     form_fields['dsn'].custom_widget = LongTextWidget 
    22     label = _(u"Add BioSQLRoot") 
    23     form_name = _(u"Edit BioSQLRoot") 
    24     def create(self, data): 
    25         object = createObject(u"plone4bio.biosql.BioSQLRoot") 
    26         form.applyChanges(object, self.form_fields, data) 
    27         return object 
    28  
    29 class BioSQLRootEditForm(base.EditForm): 
    30     """Edit form """ 
    31     form_fields = form.Fields(IBioSQLRoot) 
    32     form_fields['dsn'].custom_widget = LongTextWidget 
    33     label = _(u"Edit BioSQLRoot") 
    34     form_name = _(u"Edit BioSQLRoot") 
    3514 
    3615class BioSQLDatabaseAddForm(base.AddForm): 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/browser/configure.zcml

    r62 r112  
    88> 
    99 
    10 <include package="plone.app.contentmenu" />  
     10    <include package="plone.app.contentmenu" />  
    1111 
    12     <browser:page 
    13       for="..interfaces.IBioSQLRoot" 
    14       name="view" 
    15       template="templates/biosqlroot.pt" 
    16       allowed_interface=".interfaces.IBioSQLRootView" 
    17       permission="zope2.View" 
    18       /> 
     12     <browser:page 
     13         for="..interfaces.IBioSQLRoot" 
     14         name="view" 
     15         template="templates/biosqlroot.pt" 
     16         allowed_interface=".interfaces.IBioSQLRootView" 
     17         permission="zope2.View" 
     18         /> 
    1919 
    2020     <browser:page 
    2121        for="zope.app.container.interfaces.IAdding" 
    2222        name="plone4bio.biosql.BioSQLRoot" 
    23         class=".biosql.BioSQLRootAddForm" 
     23        class=".root.BioSQLRootAddForm" 
    2424        permission="cmf.AddPortalContent" 
    2525        /> 
     
    2828        for="..interfaces.IBioSQLRoot" 
    2929        name="edit" 
    30         class=".biosql.BioSQLRootEditForm" 
     30        class=".root.BioSQLRootEditForm" 
     31        permission="cmf.ModifyPortalContent" 
     32        /> 
     33 
     34    <browser:view 
     35        name="refresh_catalog" 
     36        for="..interfaces.IBioSQLRoot" 
     37        class=".root.RefreshCatalog" 
    3138        permission="cmf.ModifyPortalContent" 
    3239        /> 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/browser/templates/biosqlroot.pt

    r62 r112  
    4343                        </tbody> 
    4444        </table> 
     45 
     46        <form action="@@refresh_catalog"> 
     47            <input class="context" type="submit" value="rebuild catalog" /> 
     48        </form> 
    4549    </tal:foldercontents>     
     50   
    4651 
    4752</div> 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/configure.zcml

    r62 r112  
    1111 
    1212    <!-- Include sub-packages --> 
     13    <include file="monkey.zcml" /> 
    1314    <include package=".content" /> 
    1415    <include package=".browser" /> 
     16    <include package=".events" /> 
    1517 
    1618    <!-- Register GenericSetup profile used for installation --> 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/content/database.py

    r94 r112  
    5252    #         del(kwargs['parent']) 
    5353    #    super(BioSQLDatabase, self).__init__(*args, **kwargs) 
     54 
     55    # def __getattr__(self, name): 
     56    #     if self.has_key(name): 
     57    #         return self[name] 
     58    #     else: 
     59    #         raise AttributeError, name 
     60 
     61    def invalidateCache(self): 
     62        self._v_database = None 
     63        self._v_keys = None 
    5464 
    5565    # @ram.cache(_cachekey) 
     
    122132        if not database: 
    123133            raise StopIteration 
    124         for name in database.get_all_primary_ids(): # -- bioentry_id 
    125             yield str(name) 
     134        if self.getBioSQLRoot().seqrecord_key == 'accession': 
     135            for name in database.adaptor.list_bioentry_accessions(database.dbid): 
     136                yield str(name) 
     137        elif self.getBioSQLRoot().seqrecord_key == 'version': 
     138            for name in database.adaptor.list_bioentry_versions(database.dbid): 
     139                yield str(name) 
     140        else: # default = 'bioentry_id': 
     141            for name in database.get_all_primary_ids(): # -- bioentry_id 
     142                yield str(name) 
    126143     
    127144    def keys(self, reload=False): 
     
    136153        if not isinstance(key, basestring): 
    137154            return False 
    138         try: 
    139             key = int(key) 
    140         except ValueError: 
    141             return False 
     155        if self.getBioSQLRoot().seqrecord_key == 'accession': 
     156            pass 
     157        elif self.getBioSQLRoot().seqrecord_key == 'version': 
     158            rv = key.split(".") 
     159            if len(rv) > 2: 
     160                return False 
     161            if len(rv) == 2: 
     162                try: 
     163                    int(rv[1]) 
     164                except ValueError: 
     165                    return False 
     166        else: # default = 'bioentry_id': 
     167            try: 
     168                key = int(key) 
     169            except ValueError: 
     170                return False 
    142171        try: 
    143172            database = self.getDatabase() 
     
    145174            # No acquisition context, fail silently 
    146175            return False 
    147         # TODO: bug in get_Seq_by_primary_id ??? see #XXX 
    148         if database.get_Seq_by_primary_id(key): 
    149             return True 
    150         else: 
     176        try: 
     177            if self.getBioSQLRoot().seqrecord_key == 'accession': 
     178                return bool(database.get_Seq_by_acc(key)) 
     179            if self.getBioSQLRoot().seqrecord_key == 'version': 
     180                return bool(database.get_Seq_by_ver(key)) 
     181            else: # default = 'bioentry_id': 
     182                return bool(database.get_Seq_by_primary_id(key)) # biopython's bug ??? 
     183        except IndexError: 
    151184            return False 
    152         # return key in [str(id) for id in self.keys()] 
    153         #try: 
    154         #    return key in self.keys() 
    155         #except: 
    156         #    return False 
    157185     
    158186    # Acquisition wrappers don't support the __iter__ slot, so re-implement 
  • 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") 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/content/seqrecord.py

    r62 r112  
    9595        # from stxnext import pdb;pdb.set_trace() 
    9696        if self._v_seqrecord is None or reload: 
    97             self._v_seqrecord = self._getBiodatabase().getDatabase()[self.id] 
     97            if self.getBioSQLRoot().seqrecord_key == 'accession': 
     98                self._v_seqrecord = self._getBiodatabase().getDatabase().get_Seq_by_acc(self.id) 
     99            elif self.getBioSQLRoot().seqrecord_key == 'version': 
     100                self._v_seqrecord = self._getBiodatabase().getDatabase().get_Seq_by_ver(self.id) 
     101            else: # default = 'bioentry_id': 
     102                self._v_seqrecord = self._getBiodatabase().getDatabase()[self.id] 
     103            logger.debug("%s -> %r" % (self.id, self._v_seqrecord)) 
    98104        return self._v_seqrecord 
    99105 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/interfaces.py

    r62 r112  
    11from zope.interface import Interface 
    22from zope import schema 
     3from zope.schema.vocabulary import SimpleVocabulary 
    34 
    45from plone4bio.base import Plone4BioMessageFactory as _ 
     
    3637        description=_(u"database source name, i.e.: postgres://user@dbserver/dbname"), 
    3738    ) 
     39    seqrecord_key = schema.Choice(title=_("seqrecord_key"), 
     40        description =_(u"select the field name key for seqrecord uris"), 
     41        vocabulary = SimpleVocabulary.fromItems([ 
     42                     (_(u"bioentry_id"), "bioentry_id"), 
     43                     (_(u"accession"), "accession"), 
     44                     (_(u"accession.version"), "version"),]) 
     45     ) 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/profiles/default/metadata.xml

    r94 r112  
    11<?xml version="1.0"?> 
    22<metadata> 
    3   <version>1.0.0</version> 
     3  <version>1.0.1</version> 
    44</metadata>