Changeset 112 for plone4bio.biosql
- Timestamp:
- 10/18/09 21:40:10 (2 years ago)
- Location:
- plone4bio.biosql/trunk
- Files:
-
- 7 added
- 14 modified
-
README.txt (modified) (2 diffs)
-
docs/AUTHORS.txt (modified) (1 diff)
-
docs/CHANGES.txt (modified) (1 diff)
-
setup.py (modified) (2 diffs)
-
src/plone4bio/biosql/README.txt (modified) (1 diff)
-
src/plone4bio/biosql/browser/biosql.py (modified) (1 diff)
-
src/plone4bio/biosql/browser/configure.zcml (modified) (2 diffs)
-
src/plone4bio/biosql/browser/root.py (added)
-
src/plone4bio/biosql/browser/templates/biosqlroot.pt (modified) (1 diff)
-
src/plone4bio/biosql/configure.zcml (modified) (1 diff)
-
src/plone4bio/biosql/content/database.py (modified) (4 diffs)
-
src/plone4bio/biosql/content/root.py (modified) (2 diffs)
-
src/plone4bio/biosql/content/seqrecord.py (modified) (1 diff)
-
src/plone4bio/biosql/events (added)
-
src/plone4bio/biosql/events/__init__.py (added)
-
src/plone4bio/biosql/events/configure.zcml (added)
-
src/plone4bio/biosql/events/root.py (added)
-
src/plone4bio/biosql/interfaces.py (modified) (2 diffs)
-
src/plone4bio/biosql/monkey.py (added)
-
src/plone4bio/biosql/monkey.zcml (added)
-
src/plone4bio/biosql/profiles/default/metadata.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
plone4bio.biosql/trunk/README.txt
r62 r112 5 5 -------- 6 6 7 TODO 7 ... 8 8 9 9 Developer Notes … … 13 13 they are mainly tested in that environment. Usually there should be no 14 14 problem in installing the products in GNU/Linux Zope/Plone environments. 15 16 Postgresql17 18 ::19 20 sudo apt-get install libpq-dev21 22 Maintainer23 ----------24 25 Mauro Amico (mauro AT biodec DOT com) is the active maintainer of the26 *plone4bio.biosql* framework. -
plone4bio.biosql/trunk/docs/AUTHORS.txt
r62 r112 1 Mauro Amico - mauro (at) biodec.com 1 Maintainer 2 ---------- 3 4 Mauro 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 3 3 =========================== 4 4 5 plone4bio.biosql 1.0.1 (unreleased) 6 =================================== 7 5 8 Features 6 9 -------- 7 10 8 * Added the new object `predictor'.11 * rebuild catalog action 9 12 10 * TODO: add a fully working predictor.13 * choice seqrecord key field (fix #6) 11 14 15 Bug fixes 16 --------- 17 18 * "biosql bioentries are not addressable by their given database accession" (see #6) 19 20 plone4bio.biosql 1.0.0 (2009-10-18) 21 =================================== 22 23 Features 24 -------- 25 26 * mysql / postgresql support 27 28 * initial read/write biosql support 12 29 13 30 plone4bio.biosql (2008-07-01) -
plone4bio.biosql/trunk/setup.py
r94 r112 1 1 from setuptools import setup, find_packages 2 version = '1.0.1' 2 3 3 version = '1.0.0' 4 readme = open('README.txt') 5 long_description = readme.read() 6 readme.close() 4 def read(*rnames): 5 return open(os.path.join(os.path.dirname(__file__), *rnames)).read() 6 7 long_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' 7 27 8 28 tests_require = ['collective.testcaselayer'] … … 34 54 # -*- Extra requirements: -*- 35 55 'z3c.sqlalchemy', 56 'collective.monkeypatcher', 36 57 ], 37 58 tests_require=tests_require, -
plone4bio.biosql/trunk/src/plone4bio/biosql/README.txt
r62 r112 1 1 .. -*-doctest-*- 2 3 ================4 plone4bio.biosql5 ================6 7 Overview8 ========9 2 10 3 Create biosqlroot 11 4 ================= 12 5 13 Developer Notes14 ===============15 16 The plone4bio.* plone products are mainly developed on Debian Stable, so17 they are mainly tested in that environment. Usually there should be no18 problem in installing the products in other Zope/Plone environments.19 20 Maintainer21 ==========22 23 Mauro Amico (mauro AT biodec DOT com) is the active maintainer of the24 *plone4bio.biosql* framework. -
plone4bio.biosql/trunk/src/plone4bio/biosql/browser/biosql.py
r94 r112 12 12 from plone4bio.base.content.seqrecord import SeqRecord 13 13 from plone4bio.biosql.interfaces import IBioSQLRoot, IBioSQLDatabase, IBioSQLSeqRecord 14 15 class LongTextWidget(TextWidget):16 displayWidth = 5017 18 class BioSQLRootAddForm(base.AddForm):19 """Add form """20 form_fields = form.Fields(IBioSQLRoot)21 form_fields['dsn'].custom_widget = LongTextWidget22 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 object28 29 class BioSQLRootEditForm(base.EditForm):30 """Edit form """31 form_fields = form.Fields(IBioSQLRoot)32 form_fields['dsn'].custom_widget = LongTextWidget33 label = _(u"Edit BioSQLRoot")34 form_name = _(u"Edit BioSQLRoot")35 14 36 15 class BioSQLDatabaseAddForm(base.AddForm): -
plone4bio.biosql/trunk/src/plone4bio/biosql/browser/configure.zcml
r62 r112 8 8 > 9 9 10 <include package="plone.app.contentmenu" />10 <include package="plone.app.contentmenu" /> 11 11 12 <browser:page13 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 /> 19 19 20 20 <browser:page 21 21 for="zope.app.container.interfaces.IAdding" 22 22 name="plone4bio.biosql.BioSQLRoot" 23 class=". biosql.BioSQLRootAddForm"23 class=".root.BioSQLRootAddForm" 24 24 permission="cmf.AddPortalContent" 25 25 /> … … 28 28 for="..interfaces.IBioSQLRoot" 29 29 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" 31 38 permission="cmf.ModifyPortalContent" 32 39 /> -
plone4bio.biosql/trunk/src/plone4bio/biosql/browser/templates/biosqlroot.pt
r62 r112 43 43 </tbody> 44 44 </table> 45 46 <form action="@@refresh_catalog"> 47 <input class="context" type="submit" value="rebuild catalog" /> 48 </form> 45 49 </tal:foldercontents> 50 46 51 47 52 </div> -
plone4bio.biosql/trunk/src/plone4bio/biosql/configure.zcml
r62 r112 11 11 12 12 <!-- Include sub-packages --> 13 <include file="monkey.zcml" /> 13 14 <include package=".content" /> 14 15 <include package=".browser" /> 16 <include package=".events" /> 15 17 16 18 <!-- Register GenericSetup profile used for installation --> -
plone4bio.biosql/trunk/src/plone4bio/biosql/content/database.py
r94 r112 52 52 # del(kwargs['parent']) 53 53 # 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 54 64 55 65 # @ram.cache(_cachekey) … … 122 132 if not database: 123 133 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) 126 143 127 144 def keys(self, reload=False): … … 136 153 if not isinstance(key, basestring): 137 154 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 142 171 try: 143 172 database = self.getDatabase() … … 145 174 # No acquisition context, fail silently 146 175 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: 151 184 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 False157 185 158 186 # Acquisition wrappers don't support the __iter__ slot, so re-implement -
plone4bio.biosql/trunk/src/plone4bio/biosql/content/root.py
r88 r112 11 11 from Products.CMFCore.permissions import View 12 12 from Products.CMFCore.interfaces import IFolderish 13 from Products.CMFCore.utils import getToolByName 14 from Products.CMFPlone.utils import base_hasattr 15 from Products.CMFPlone.utils import safe_callable 13 16 from zope.app.container.interfaces import IContainer 14 17 from plone.app.content.interfaces import INameFromTitle … … 49 52 # isPrincipiaFolderish = True # already on Container 50 53 dsn = FieldProperty(IBioSQLRoot['dsn']) 54 seqrecord_key = FieldProperty(IBioSQLRoot['seqrecord_key']) 51 55 _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 52 80 53 81 security.declareProtected(View, "getBioSQLRoot") -
plone4bio.biosql/trunk/src/plone4bio/biosql/content/seqrecord.py
r62 r112 95 95 # from stxnext import pdb;pdb.set_trace() 96 96 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)) 98 104 return self._v_seqrecord 99 105 -
plone4bio.biosql/trunk/src/plone4bio/biosql/interfaces.py
r62 r112 1 1 from zope.interface import Interface 2 2 from zope import schema 3 from zope.schema.vocabulary import SimpleVocabulary 3 4 4 5 from plone4bio.base import Plone4BioMessageFactory as _ … … 36 37 description=_(u"database source name, i.e.: postgres://user@dbserver/dbname"), 37 38 ) 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 1 1 <?xml version="1.0"?> 2 2 <metadata> 3 <version>1.0. 0</version>3 <version>1.0.1</version> 4 4 </metadata>
