Changeset 153
- Timestamp:
- 08/05/10 18:37:06 (18 months ago)
- Location:
- plone4bio.biosql/trunk
- Files:
-
- 13 modified
-
setup.py (modified) (2 diffs)
-
src/plone4bio/biosql/README.txt (modified) (1 diff)
-
src/plone4bio/biosql/__init__.py (modified) (1 diff)
-
src/plone4bio/biosql/browser/configure.zcml (modified) (5 diffs)
-
src/plone4bio/biosql/browser/root.py (modified) (2 diffs)
-
src/plone4bio/biosql/browser/templates/biosqldatabase.pt (modified) (5 diffs)
-
src/plone4bio/biosql/configure.zcml (modified) (2 diffs)
-
src/plone4bio/biosql/content/database.py (modified) (3 diffs)
-
src/plone4bio/biosql/content/root.py (modified) (11 diffs)
-
src/plone4bio/biosql/content/seqrecord.py (modified) (5 diffs)
-
src/plone4bio/biosql/events/configure.zcml (modified) (1 diff)
-
src/plone4bio/biosql/interfaces.py (modified) (2 diffs)
-
src/plone4bio/biosql/profiles/default/types/BioSQLRoot.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plone4bio.biosql/trunk/setup.py
r136 r153 1 1 from setuptools import setup, find_packages 2 2 import os 3 version = '1. 0.1'3 version = '1.1.0' 4 4 5 5 tests_require = ['collective.testcaselayer', 'pysqlite', ] … … 36 36 'z3c.sqlalchemy', 37 37 'collective.monkeypatcher', 38 # 'collective.progressbar', 38 39 ], 39 40 tests_require=tests_require, -
plone4bio.biosql/trunk/src/plone4bio/biosql/README.txt
r136 r153 6 6 Create a mockup for a biopython's biosql database: 7 7 8 import tempfile9 import os10 from BioSQL import BioSeqDatabase8 >>> import tempfile 9 >>> import os 10 >>> from BioSQL import BioSeqDatabase 11 11 12 (dbh, dbpath) = tempfile.mkstemp(suffix=".db")13 server = BioSeqDatabase.open_database(driver = 'sqlite3', db = dbpath)14 server.load_database_sql('biosqldb-sqlite.sql')15 server.commit()16 server.close()12 >>> (dbh, dbpath) = tempfile.mkstemp(suffix=".db") 13 >>> server = BioSeqDatabase.open_database(driver = 'sqlite3', db = dbpath) 14 >>> server.load_database_sql('biosqldb-sqlite.sql') 15 >>> server.commit() 16 >>> server.close() 17 17 18 18 Create a plone4bio's biosqlroot: -
plone4bio.biosql/trunk/src/plone4bio/biosql/__init__.py
r62 r153 2 2 Plone4BioMessageFactory = MessageFactory('plone4bio') 3 3 4 # Kick the permission definition5 #import permissions6 7 4 def initialize(context): 8 5 """Intializer called when used as a Zope 2 product.""" -
plone4bio.biosql/trunk/src/plone4bio/biosql/browser/configure.zcml
r112 r153 17 17 permission="zope2.View" 18 18 /> 19 19 <!-- 20 20 <browser:page 21 21 for="zope.app.container.interfaces.IAdding" … … 31 31 permission="cmf.ModifyPortalContent" 32 32 /> 33 --> 33 34 34 35 <browser:view … … 96 97 attribute="contents" 97 98 /> 98 99 100 <!-- 99 101 <browser:addMenuItem 100 102 title="BioSQLRoot" … … 103 105 permission="cmf.AddPortalContent" 104 106 /> 107 --> 105 108 106 109 <!-- BioSQLDatabase --> … … 109 112 name="view" 110 113 template="templates/biosqldatabase.pt" 114 class=".database.BioSQLDatabaseView" 111 115 allowed_interface=".interfaces.IBioSQLDatabaseView" 112 116 permission="zope2.View" -
plone4bio.biosql/trunk/src/plone4bio/biosql/browser/root.py
r130 r153 13 13 displayWidth = 50 14 14 15 ''' 15 16 class BioSQLRootAddForm(base.AddForm): 16 17 """Add form """ … … 30 31 label = _(u"Edit BioSQLRoot") 31 32 form_name = _(u"Edit BioSQLRoot") 33 ''' 32 34 33 35 class RefreshCatalog(BrowserView): -
plone4bio.biosql/trunk/src/plone4bio/biosql/browser/templates/biosqldatabase.pt
r62 r153 1 <html xmlns="http://www.w3.org/1999/xhtml" 2 xmlns:metal="http://xml.zope.org/namespaces/metal" 3 xmlns:tal="http://xml.zope.org/namespaces/tal" 4 xmlns:i18n="http://xml.zope.org/namespaces/i18n" 5 metal:use-macro="context/@@standard_macros/page" 1 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" 2 lang="en" 3 metal:use-macro="here/main_template/macros/master" 6 4 i18n:domain="plone4bio"> 7 5 <head> … … 9 7 10 8 <body> 11 <div metal:fill-slot="body"> 12 13 <h1 class="documentFirstHeading" tal:content="context/title" /> 9 <div metal:fill-slot="main"> 10 <metal:main-macro define-macro="main"> 11 12 <div tal:replace="structure provider:plone.abovecontenttitle" /> 13 14 <h1 tal:content="object_title|nothing" class="documentFirstHeading"> 15 Title or id 16 </h1> 17 18 <div tal:replace="structure provider:plone.belowcontenttitle" /> 19 20 <a href="" 21 class="link-parent" 22 tal:define="parent_url python:here.navigationParent(here)" 23 tal:condition="parent_url" 24 tal:attributes="href parent_url" 25 i18n:translate="go_to_parent_url"> 26 Up one level 27 </a> 28 29 <p class="documentDescription" 30 tal:content="here/Description" 31 tal:condition="here/Description"> 32 Description 33 </p> 34 35 <div tal:replace="structure provider:plone.abovecontentbody" /> 36 14 37 15 38 <tal:foldercontents tal:define="folderContents here/keys; … … 23 46 tal:define="batch python:Batch(folderContents, b_size, int(b_start), orphan=1);"> 24 47 48 <!-- 25 49 <table class="listing vertical" style="float:right"> 26 50 <tr> … … 34 58 35 59 </table> 36 37 60 --> 38 61 39 62 <div metal:use-macro="here/batch_macros/macros/navigation" /> … … 94 117 </div> 95 118 </tal:foldercontents> 96 97 </div> 119 120 </metal:main-macro> 121 </div> 98 122 </body> 99 123 </html> -
plone4bio.biosql/trunk/src/plone4bio/biosql/configure.zcml
r112 r153 12 12 <!-- Include sub-packages --> 13 13 <include file="monkey.zcml" /> 14 14 15 <include package=".content" /> 15 16 <include package=".browser" /> … … 25 26 /> 26 27 28 <!-- 27 29 <five:traversable class=".content.proxy.BaseProxy"/> 30 --> 28 31 29 32 </configure> -
plone4bio.biosql/trunk/src/plone4bio/biosql/content/database.py
r112 r153 10 10 from Products.CMFCore.interfaces import IFolderish 11 11 from zope.app.container.interfaces import IContainer 12 from Products.CMFCore.interfaces import IDynamicType 12 13 from plone.app.content.container import Container 13 14 … … 36 37 class BioSQLDatabase(BaseProxy, DynamicType, Container): 37 38 """ BioSQLDatabase ... """ 38 __implements__ = (DynamicType.__implements__) 39 implements(IBioSQLDatabase, IContainer, IFolderish) 39 implements(IBioSQLDatabase, IContainer, IFolderish, IDynamicType) 40 40 adapts(IBatch) 41 41 meta_type = "BioSQLDatabase" … … 45 45 _v_database = None 46 46 _v_keys = None 47 48 # TODO: define wf 49 _Review_portal_content_Permission = '' 50 _Request_review_Permission = '' 51 47 52 #_v_root = None 48 53 -
plone4bio.biosql/trunk/src/plone4bio/biosql/content/root.py
r112 r153 1 # -*- coding: utf-8 -*- 1 2 __author__ = '''Mauro Amico <mauro@biodec.com>''' 2 3 __docformat__ = 'plaintext' 3 4 5 from threading import local 4 6 from zope.interface import implements 5 7 from zope.component.factory import Factory 6 8 from zope.schema.fieldproperty import FieldProperty 9 10 from Acquisition import aq_base 7 11 8 12 from plone.app.content.container import Container … … 14 18 from Products.CMFPlone.utils import base_hasattr 15 19 from Products.CMFPlone.utils import safe_callable 20 from Products.CMFPlone.interfaces.constrains import IConstrainTypes 21 22 from Products.ATContentTypes.content.base import ATCTContent 23 from Products.ATContentTypes.content.schemata import ATContentTypeSchema 24 25 from Products.Archetypes import atapi 26 27 from Products.Archetypes.atapi import Schema 28 from Products.Archetypes.atapi import BooleanWidget 29 from Products.Archetypes.atapi import StringField 30 from Products.Archetypes.atapi import StringWidget 31 from Products.Archetypes.atapi import registerType 32 16 33 from zope.app.container.interfaces import IContainer 17 34 from plone.app.content.interfaces import INameFromTitle … … 43 60 return self.dsn 44 61 45 # WebDAV ... Collection 46 # class BioSQLRoot(BaseContent, BrowserDefaultMixin): 62 """ 63 47 64 class BioSQLRoot(Container): 48 __implements__ = (BrowserDefaultMixin.__implements__)49 65 portal_type='BioSQLRoot' 66 50 67 implements(IBioSQLRoot, IContainer, IFolderish, INameFromTitle) 68 51 69 security = ClassSecurityInfo() 52 70 # isPrincipiaFolderish = True # already on Container 53 dsn = FieldProperty(IBioSQLRoot['dsn']) 71 # dsn = FieldProperty(IBioSQLRoot['dsn']) 72 dsn = 'postgres://postgres@localhost/plone4bio' 54 73 seqrecord_key = FieldProperty(IBioSQLRoot['seqrecord_key']) 55 _v_dbserver = None 74 _v_thread_local = local() 75 76 def __init__(self, *args, **kwargs): 77 if kwargs.has_key('parent'): 78 parent = kwargs['parent'] 79 del(kwargs['parent']) 80 super(BioSQLRoot, self).__init__(*args, **kwargs) 81 """ 82 83 84 Plone4BioSchema = ATContentTypeSchema.copy() + Schema(( 85 StringField("dsn", 86 required = True, 87 widget = StringWidget( 88 label = "dsn", 89 label_msgid = "dsn_label", 90 description = "DSN " 91 "... " 92 "...", 93 description_msgid = "dsn_help", 94 i18n_domain = "plone4bio") 95 ), 96 )) 97 98 class BioSQLRoot(ATCTContent): 99 portal_type='BioSQLRoot' 100 101 implements(IBioSQLRoot, IConstrainTypes) 102 103 security = ClassSecurityInfo() 104 schema = Plone4BioSchema 105 _at_rename_after_creation = True 106 isPrincipiaFolderish = True 107 # dsn = atapi.ATFieldProperty('dsn') 108 dsn = 'postgres://postgres@localhost/plone4bio' 109 seqrecord_key = "version" 110 _v_thread_local = local() 111 112 # XXX 113 def getLocallyAllowedTypes(self): 114 return [] 56 115 57 116 # see CMFPlone/CatalogTool.py 58 117 def refreshCatalog(self, clear=1): 118 return 59 119 def indexObject(obj, path): 60 120 if (base_hasattr(obj, 'indexObject') and … … 66 126 # take different args, and will fail 67 127 pass 128 except: # CatalogError: 129 # import pdb; pdb.set_trace() 130 # obj.indexObject() 131 logger.exception("indexObject %r for %r" % (obj, self)) 68 132 for database in self.values(): 69 133 database.invalidateCache() … … 73 137 portal_catalog.ZopeFindAndApply(self, search_sub=True, apply_func=indexObject) 74 138 139 """ 75 140 def __getattr__(self, name): 76 141 if self.has_key(name): … … 78 143 else: 79 144 raise AttributeError, name 145 """ 80 146 81 147 security.declareProtected(View, "getBioSQLRoot") … … 91 157 if not self.dsn: 92 158 return None 93 if self._v_dbserver is None or not self._v_dbserver.adaptor.conn.is_valid: 159 dbserver = getattr(self._v_thread_local, 'dbserver', None) 160 if dbserver is None or not dbserver.adaptor.conn.is_valid: 94 161 try: 95 162 wrapper = getSAWrapper(self.dsn) … … 97 164 wrapper = createSAWrapper(dsn=self.dsn, name=self.dsn) 98 165 #TODO: manage OperationalError on connection 99 self._v_dbserver = DBServer(wrapper.connection, __import__(drivers[self.dsn.split(':')[0]])) 100 return self._v_dbserver 166 dbserver = DBServer(wrapper.connection, __import__(drivers[self.dsn.split(':')[0]])) 167 self._v_thread_local.dbserver = dbserver 168 return dbserver 101 169 102 170 security.declareProtected(View, "getValues") … … 123 191 logger.exception("getDBServer") 124 192 raise StopIteration 193 if not dbserver: 194 raise StopIteration 125 195 for name in dbserver.keys(): 126 yield name196 yield str(name) 127 197 #try: 128 198 # for name in dbserver.keys(): … … 149 219 yield (k, self[k]) 150 220 221 def __bobo_traverse__(self, REQUEST, name): 222 try: 223 return self[name] 224 except KeyError: 225 pass 226 if hasattr(aq_base(self), name): 227 return getattr(self, name) 228 # webdav 229 """ 230 method = REQUEST.get('REQUEST_METHOD', 'GET').upper() 231 if (method not in ('GET', 'POST') and not 232 isinstance(REQUEST.RESPONSE, xmlrpc.Response) and 233 REQUEST.maybe_webdav_client and not REQUEST.path): 234 return ReflectoNullResource(self, name, REQUEST).__of__(self) 235 """ 236 return ATCTContent.__bobo_traverse__(self, REQUEST, name) 237 151 238 # zope2/lib/python/OFS/ObjectManager.py 152 239 def _getOb(self, id, default=_marker): … … 194 281 setattr(BioSQLRoot, m, getattr(DictMixin, m).im_func) 195 282 283 # XXX: ??? 196 284 bioSQLRootFactory = Factory(BioSQLRoot, title=_(u"Create a new BioSQL Root")) 285 286 atapi.registerType(BioSQLRoot, 'plone4bio.biosql') 287 -
plone4bio.biosql/trunk/src/plone4bio/biosql/content/seqrecord.py
r137 r153 8 8 from Globals import InitializeClass 9 9 from Products.CMFCore.DynamicType import DynamicType 10 from Products.CMFCore.interfaces import IDynamicType 10 11 11 12 from plone4bio.base import Plone4BioMessageFactory as _ … … 30 31 if inst is None: 31 32 return self 32 from stxnext import pdb;pdb.set_trace()33 33 ob = inst._getSeqRecord() 34 34 for name in self.__name.split('.'): … … 46 46 47 47 def __set__(self, inst, value): 48 from stxnext import pdb;pdb.set_trace()49 48 try: 50 49 inst.seqrecord.set(self.__name, value) … … 53 52 54 53 #def __getattr__(self, name): 55 # from stxnext import pdb;pdb.set_trace()56 54 # return getattr(self.seqrecord, name) 57 55 """ 58 56 59 60 class BioSQLSeqRecord(BaseProxy, SeqRecord , DynamicType):57 #XXX: removed DynamicType 58 class BioSQLSeqRecord(BaseProxy, SeqRecord): #, DynamicType): 61 59 """ BioSQLSeqRecord ... """ 62 __implements__ = (DynamicType.__implements__)60 # implements(IDynamicType, IBioSQLSeqRecord, ISeqRecord) 63 61 implements(IBioSQLSeqRecord, ISeqRecord) 64 62 meta_type = "BioSQLSeqRecord" … … 118 116 """Return our BioSQLDatabase. 119 117 """ 120 # from stxnext import pdb;pdb.set_trace()121 118 if self._v_biodatabase is None or reload: 122 119 for parent in self.aq_inner.aq_chain: -
plone4bio.biosql/trunk/src/plone4bio/biosql/events/configure.zcml
r112 r153 1 1 <configure xmlns="http://namespaces.zope.org/zope"> 2 2 3 <subscriber for="..interfaces.IBioSQLRoot 3 4 zope.lifecycleevent.interfaces.IObjectModifiedEvent" 4 5 handler=".root.modifyedBioSQLRoot" /> 6 5 7 </configure> -
plone4bio.biosql/trunk/src/plone4bio/biosql/interfaces.py
r112 r153 32 32 33 33 class IBioSQLRoot(Interface): 34 """ """34 """ 35 35 title = schema.TextLine(title=_(u"title")) 36 36 dsn = schema.TextLine(title=_(u"DSN"), … … 43 43 (_(u"accession"), "accession"), 44 44 (_(u"accession.version"), "version"),]) 45 ) 45 ) 46 """ -
plone4bio.biosql/trunk/src/plone4bio/biosql/profiles/default/types/BioSQLRoot.xml
r138 r153 19 19 <alias from="(Default)" to="@@view"/> 20 20 <alias from="view" to="@@view"/> 21 <alias from="edit" to=" @@edit"/>21 <alias from="edit" to="atct_edit"/> 22 22 <action title="View" action_id="view" category="object" condition_expr="" 23 23 url_expr="string:${object_url}" visible="True"> … … 25 25 </action> 26 26 <action title="Edit" action_id="edit" category="object" condition_expr="" 27 url_expr="string:${object_url}/ @@edit" visible="True">27 url_expr="string:${object_url}/edit" visible="True"> 28 28 <permission value="Modify portal content"/> 29 29 </action>
