Changeset 153

Show
Ignore:
Timestamp:
08/05/10 18:37:06 (18 months ago)
Author:
mauro
Message:

plone4

Location:
plone4bio.biosql/trunk
Files:
13 modified

Legend:

Unmodified
Added
Removed
  • plone4bio.biosql/trunk/setup.py

    r136 r153  
    11from setuptools import setup, find_packages 
    22import os 
    3 version = '1.0.1' 
     3version = '1.1.0' 
    44 
    55tests_require = ['collective.testcaselayer', 'pysqlite', ] 
     
    3636          'z3c.sqlalchemy', 
    3737          'collective.monkeypatcher', 
     38          # 'collective.progressbar', 
    3839      ], 
    3940      tests_require=tests_require, 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/README.txt

    r136 r153  
    66Create a mockup for a biopython's biosql database: 
    77 
    8  import tempfile 
    9  import os 
    10  from BioSQL import BioSeqDatabase 
     8  >>> import tempfile 
     9  >>> import os 
     10  >>> from BioSQL import BioSeqDatabase 
    1111 
    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() 
    1717 
    1818Create a plone4bio's biosqlroot: 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/__init__.py

    r62 r153  
    22Plone4BioMessageFactory = MessageFactory('plone4bio') 
    33 
    4 # Kick the permission definition 
    5 #import permissions 
    6  
    74def initialize(context): 
    85    """Intializer called when used as a Zope 2 product.""" 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/browser/configure.zcml

    r112 r153  
    1717         permission="zope2.View" 
    1818         /> 
    19  
     19<!-- 
    2020     <browser:page 
    2121        for="zope.app.container.interfaces.IAdding" 
     
    3131        permission="cmf.ModifyPortalContent" 
    3232        /> 
     33--> 
    3334 
    3435    <browser:view 
     
    9697      attribute="contents" 
    9798      /> 
    98           
     99 
     100<!--          
    99101    <browser:addMenuItem 
    100102        title="BioSQLRoot" 
     
    103105        permission="cmf.AddPortalContent" 
    104106        /> 
     107--> 
    105108         
    106109    <!-- BioSQLDatabase --> 
     
    109112      name="view" 
    110113      template="templates/biosqldatabase.pt" 
     114      class=".database.BioSQLDatabaseView" 
    111115      allowed_interface=".interfaces.IBioSQLDatabaseView" 
    112116      permission="zope2.View" 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/browser/root.py

    r130 r153  
    1313    displayWidth = 50 
    1414 
     15''' 
    1516class BioSQLRootAddForm(base.AddForm): 
    1617    """Add form """ 
     
    3031    label = _(u"Edit BioSQLRoot") 
    3132    form_name = _(u"Edit BioSQLRoot") 
     33''' 
    3234 
    3335class 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" 
    64      i18n:domain="plone4bio"> 
    75<head> 
     
    97 
    108<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 
    1437 
    1538    <tal:foldercontents tal:define="folderContents here/keys; 
     
    2346       tal:define="batch python:Batch(folderContents, b_size, int(b_start), orphan=1);"> 
    2447 
     48    <!-- 
    2549    <table class="listing vertical" style="float:right"> 
    2650        <tr> 
     
    3458 
    3559    </table> 
    36  
    37  
     60    --> 
    3861 
    3962        <div metal:use-macro="here/batch_macros/macros/navigation" /> 
     
    94117    </div> 
    95118    </tal:foldercontents>     
    96      
    97 </div> 
     119 
     120    </metal:main-macro> 
     121  </div> 
    98122</body> 
    99123</html> 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/configure.zcml

    r112 r153  
    1212    <!-- Include sub-packages --> 
    1313    <include file="monkey.zcml" /> 
     14 
    1415    <include package=".content" /> 
    1516    <include package=".browser" /> 
     
    2526        /> 
    2627 
     28    <!-- 
    2729     <five:traversable class=".content.proxy.BaseProxy"/> 
     30    --> 
    2831 
    2932</configure> 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/content/database.py

    r112 r153  
    1010from Products.CMFCore.interfaces import IFolderish 
    1111from zope.app.container.interfaces import IContainer 
     12from Products.CMFCore.interfaces import IDynamicType 
    1213from plone.app.content.container import Container 
    1314 
     
    3637class BioSQLDatabase(BaseProxy, DynamicType, Container): 
    3738    """  BioSQLDatabase ... """ 
    38     __implements__ = (DynamicType.__implements__) 
    39     implements(IBioSQLDatabase, IContainer, IFolderish) 
     39    implements(IBioSQLDatabase, IContainer, IFolderish, IDynamicType) 
    4040    adapts(IBatch) 
    4141    meta_type = "BioSQLDatabase" 
     
    4545    _v_database = None 
    4646    _v_keys = None 
     47 
     48    # TODO: define wf 
     49    _Review_portal_content_Permission = '' 
     50    _Request_review_Permission = '' 
     51 
    4752    #_v_root = None 
    4853 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/content/root.py

    r112 r153  
     1# -*- coding: utf-8 -*- 
    12__author__ = '''Mauro Amico <mauro@biodec.com>''' 
    23__docformat__ = 'plaintext' 
    34 
     5from threading import local 
    46from zope.interface import implements 
    57from zope.component.factory import Factory 
    68from zope.schema.fieldproperty import FieldProperty 
     9 
     10from Acquisition import aq_base 
    711 
    812from plone.app.content.container import Container 
     
    1418from Products.CMFPlone.utils import base_hasattr 
    1519from Products.CMFPlone.utils import safe_callable 
     20from Products.CMFPlone.interfaces.constrains import IConstrainTypes 
     21 
     22from Products.ATContentTypes.content.base import ATCTContent 
     23from Products.ATContentTypes.content.schemata import ATContentTypeSchema 
     24 
     25from Products.Archetypes import atapi 
     26 
     27from Products.Archetypes.atapi import Schema 
     28from Products.Archetypes.atapi import BooleanWidget 
     29from Products.Archetypes.atapi import StringField 
     30from Products.Archetypes.atapi import StringWidget 
     31from Products.Archetypes.atapi import registerType 
     32 
    1633from zope.app.container.interfaces import IContainer 
    1734from plone.app.content.interfaces import INameFromTitle 
     
    4360    return self.dsn 
    4461 
    45 # WebDAV ... Collection 
    46 # class BioSQLRoot(BaseContent, BrowserDefaultMixin): 
     62""" 
     63 
    4764class BioSQLRoot(Container): 
    48     __implements__ = (BrowserDefaultMixin.__implements__) 
    4965    portal_type='BioSQLRoot' 
     66 
    5067    implements(IBioSQLRoot, IContainer, IFolderish, INameFromTitle) 
     68 
    5169    security = ClassSecurityInfo() 
    5270    # isPrincipiaFolderish = True # already on Container 
    53     dsn = FieldProperty(IBioSQLRoot['dsn']) 
     71    # dsn = FieldProperty(IBioSQLRoot['dsn']) 
     72    dsn = 'postgres://postgres@localhost/plone4bio' 
    5473    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 
     84Plone4BioSchema = 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 
     98class 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 [] 
    56115 
    57116    # see CMFPlone/CatalogTool.py 
    58117    def refreshCatalog(self, clear=1): 
     118        return 
    59119        def indexObject(obj, path): 
    60120            if (base_hasattr(obj, 'indexObject') and 
     
    66126                    # take different args, and will fail 
    67127                    pass 
     128                except: # CatalogError: 
     129                    # import pdb; pdb.set_trace() 
     130                    # obj.indexObject() 
     131                    logger.exception("indexObject %r for %r" % (obj, self)) 
    68132        for database in self.values(): 
    69133            database.invalidateCache() 
     
    73137        portal_catalog.ZopeFindAndApply(self, search_sub=True, apply_func=indexObject) 
    74138 
     139    """ 
    75140    def __getattr__(self, name): 
    76141        if self.has_key(name): 
     
    78143        else: 
    79144            raise AttributeError, name 
     145    """ 
    80146 
    81147    security.declareProtected(View, "getBioSQLRoot") 
     
    91157        if not self.dsn: 
    92158            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: 
    94161            try: 
    95162                wrapper = getSAWrapper(self.dsn) 
     
    97164                wrapper = createSAWrapper(dsn=self.dsn, name=self.dsn) 
    98165            #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 
    101169 
    102170    security.declareProtected(View, "getValues") 
     
    123191            logger.exception("getDBServer") 
    124192            raise StopIteration 
     193        if not dbserver: 
     194            raise StopIteration 
    125195        for name in dbserver.keys(): 
    126             yield name 
     196            yield str(name) 
    127197        #try: 
    128198        #    for name in dbserver.keys(): 
     
    149219            yield (k, self[k]) 
    150220 
     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 
    151238    # zope2/lib/python/OFS/ObjectManager.py 
    152239    def _getOb(self, id, default=_marker): 
     
    194281    setattr(BioSQLRoot, m, getattr(DictMixin, m).im_func) 
    195282 
     283# XXX: ??? 
    196284bioSQLRootFactory = Factory(BioSQLRoot, title=_(u"Create a new BioSQL Root")) 
     285 
     286atapi.registerType(BioSQLRoot, 'plone4bio.biosql') 
     287 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/content/seqrecord.py

    r137 r153  
    88from Globals import InitializeClass 
    99from Products.CMFCore.DynamicType import DynamicType 
     10from Products.CMFCore.interfaces import IDynamicType 
    1011 
    1112from plone4bio.base import Plone4BioMessageFactory as _ 
     
    3031        if inst is None: 
    3132            return self 
    32         from stxnext import pdb;pdb.set_trace() 
    3333        ob = inst._getSeqRecord() 
    3434        for name in self.__name.split('.'): 
     
    4646 
    4747    def __set__(self, inst, value): 
    48         from stxnext import pdb;pdb.set_trace() 
    4948        try: 
    5049            inst.seqrecord.set(self.__name, value) 
     
    5352 
    5453    #def __getattr__(self, name): 
    55     #    from stxnext import pdb;pdb.set_trace() 
    5654    #    return getattr(self.seqrecord, name) 
    5755""" 
    5856 
    59  
    60 class BioSQLSeqRecord(BaseProxy, SeqRecord, DynamicType): 
     57#XXX: removed DynamicType 
     58class BioSQLSeqRecord(BaseProxy, SeqRecord): #, DynamicType): 
    6159    """  BioSQLSeqRecord ... """ 
    62     __implements__ = (DynamicType.__implements__) 
     60    # implements(IDynamicType, IBioSQLSeqRecord, ISeqRecord) 
    6361    implements(IBioSQLSeqRecord, ISeqRecord) 
    6462    meta_type = "BioSQLSeqRecord" 
     
    118116        """Return our BioSQLDatabase. 
    119117        """ 
    120         # from stxnext import pdb;pdb.set_trace() 
    121118        if self._v_biodatabase is None or reload: 
    122119            for parent in self.aq_inner.aq_chain: 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/events/configure.zcml

    r112 r153  
    11<configure xmlns="http://namespaces.zope.org/zope"> 
     2 
    23    <subscriber for="..interfaces.IBioSQLRoot 
    34            zope.lifecycleevent.interfaces.IObjectModifiedEvent" 
    45            handler=".root.modifyedBioSQLRoot" /> 
     6 
    57</configure> 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/interfaces.py

    r112 r153  
    3232 
    3333class IBioSQLRoot(Interface): 
    34     """ """ 
     34    """ 
    3535    title = schema.TextLine(title=_(u"title")) 
    3636    dsn = schema.TextLine(title=_(u"DSN"), 
     
    4343                     (_(u"accession"), "accession"), 
    4444                     (_(u"accession.version"), "version"),]) 
    45      ) 
     45    ) 
     46    """ 
  • plone4bio.biosql/trunk/src/plone4bio/biosql/profiles/default/types/BioSQLRoot.xml

    r138 r153  
    1919 <alias from="(Default)" to="@@view"/> 
    2020 <alias from="view" to="@@view"/> 
    21  <alias from="edit" to="@@edit"/> 
     21 <alias from="edit" to="atct_edit"/> 
    2222 <action title="View" action_id="view" category="object" condition_expr="" 
    2323    url_expr="string:${object_url}" visible="True"> 
     
    2525 </action>  
    2626 <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"> 
    2828  <permission value="Modify portal content"/> 
    2929 </action>