Changeset 1374

Show
Ignore:
Timestamp:
08/29/08 19:07:53 (3 months ago)
Author:
sgillies
Message:

Force notification of new workspace initialization

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pleiades.workspace/trunk/pleiades/workspace/browser/kml.py

    r1373 r1374  
    1818        portal = getToolByName(self.context, 'portal_url').getPortalObject() 
    1919        ptool = getToolByName(self.context, 'plone_utils') 
     20        wtool = getToolByName(self.context, 'portal_workflow') 
    2021 
    2122        places = portal['places'] 
     
    6061                self.context.attach(f) 
    6162                self.context.attach(p) 
    62                  
     63                
    6364        except: 
    6465            savepoint.rollback() 
  • pleiades.workspace/trunk/pleiades/workspace/browser/workspace.css

    r1287 r1374  
    1 /* Styles specific to the optilux.cinemacontent views. 
    2  
    3    This is explicitly included from various page templates, since it only 
    4    pertains to a handful of them. If we wanted something more sitewide, 
    5    we could have used the portal_css registry instead. 
    6  */ 
    7  
    8 .film-banner { 
    9     float: left; 
    10     margin: 1em 1em 0 0; 
     1table { 
     2  text-align: left; 
     3  border-spacing: 1em; 
    114} 
    125 
    13 .promotion-banner { 
    14     float: right; 
    15     margin: 1em 1em 0 0; 
    16 } 
    17  
    18 .highlighted-films { 
    19     float: right; 
    20     margin: 0 0 0 1em; 
    21 } 
    22  
    23 .highlighted-films a { 
    24     display: block; 
    25 } 
    26  
    27 /* Make some fields render inline so that they get a label on the same line */ 
    28 #parent-fieldname-phone,   
    29 #parent-fieldname-startDate,  
    30 #parent-fieldname-endDate, 
    31 #parent-fieldname-effectiveDate, 
    32 #parent-fieldname-expirationDate { 
    33     display: inline; 
    34 } 
  • pleiades.workspace/trunk/pleiades/workspace/browser/workspace.pt

    r1287 r1374  
    77      i18n:domain="pleiades.workspace"> 
    88<body> 
     9 
     10<metal:css fill-slot="css_slot"> 
     11  <style  
     12    type="text/css" media="all" 
     13    tal:content="string: @import url(${context/++resource++pleiades-workspace.css});" 
     14    > 
     15  </style> 
     16</metal:css> 
    917 
    1018<metal:main fill-slot="main"> 
     
    3442        <div tal:condition="text" metal:use-macro="python:context.widget('text', mode='view')" /> 
    3543         
    36         <tal:areas condition="view/have_cinema_folders"> 
    37             <h2 i18n:translate="title_cinemafolder_subareas">Areas</h2> 
    38             <dl> 
    39                 <tal:block repeat="area view/cinema_folders"> 
    40                     <dt> 
    41                         <a tal:attributes="href area/url" 
    42                            tal:content="area/title" /> 
    43                     </dt> 
    44                     <dd tal:content="area/description" /> 
    45                 </tal:block> 
    46             </dl> 
    47         </tal:areas> 
     44        <tal:collections> 
     45            <h2 i18n:translate="title_workspace_collections">Data Dashboard</h2> 
     46            <table class="workspace-dashboard"> 
     47              <tr> 
     48                <th>Type</th> 
     49                <th>Drafting</th> 
     50                <th>Pending</th> 
     51                <th>Published</th> 
     52                <th>All</th> 
     53              </tr> 
     54              <tr tal:repeat="tname python:['locations', 'names', 'features', 'places']"> 
     55                <tal:row tal:define="row python:view.collections_data[tname]"> 
     56                <th tal:content="python:tname.capitalize()">NAME</th> 
     57                <td tal:repeat="data python:[row[state] for state in ('drafting', 'pending', 'published', 'all')]"> 
     58                  <a tal:attributes="href data/url"><span tal:replace="data/count">COUNT</span></a>,&nbsp;<a tal:attributes="href string:${data/url}/@@kml-document">[KML]</a> 
     59                </td> 
     60                </tal:row> 
     61              </tr> 
     62              <tr tal:define="row python:view.collections_data['all']"> 
     63                <th>All</th> 
     64                <td tal:repeat="data python:[row[state] for state in ('drafting', 'pending', 'published')]"> 
     65                  <a tal:attributes="href data/url"><span tal:replace="data/count">COUNT</span></a>&nbsp; 
     66                  <a tal:attributes="href string:${data/url}/@@kml-document">[KML]</a> 
     67                </td> 
     68              </tr> 
     69            </table> 
     70        </tal:collections> 
    4871         
    49         <tal:cinemas condition="view/have_cinemas"> 
    50             <h2 i18n:translate="title_cinemafolder_subareas">Cinemas</h2> 
    51             <dl> 
    52                 <tal:block repeat="cinema view/cinemas"> 
    53                     <dt> 
    54                         <a tal:attributes="href cinema/url" 
    55                            tal:content="cinema/title" /> 
    56                     </dt> 
    57                     <dd tal:content="cinema/address" /> 
    58                 </tal:block> 
    59             </dl> 
    60         </tal:cinemas> 
    61  
    6272        <div metal:use-macro="context/document_relateditems/macros/relatedItems"> 
    6373            show related items if they exist 
  • pleiades.workspace/trunk/pleiades/workspace/browser/workspace.py

    r1287 r1374  
    33from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile 
    44from Products.CMFCore.utils import getToolByName 
    5 from pleiades.workspace.interfaces import IWorkspace 
     5from pleiades.workspace.interfaces import IWorkspace, IWorkspaceCollection 
    66from plone.memoize.instance import memoize  
    77 
     
    1212     
    1313    __call__ = ViewPageTemplateFile('workspace.pt') 
    14      
     14 
     15    @memoize 
     16    def collections_data(self): 
     17        data = {} 
     18        for name in ['locations', 'names', 'features', 'places']: 
     19            row = {} 
     20            for state in ['drafting', 'pending', 'published']: 
     21                collection = self.context[name][state] 
     22                url = collection.absolute_url() 
     23                brains = collection.queryCatalog() 
     24                row[state] = dict(count=len(brains), url=url) 
     25             
     26            # Now the column of all states 
     27            collection = self.context[name] 
     28            url = collection.absolute_url() 
     29            brains = collection.queryCatalog() 
     30            row['all'] = dict(count=len(brains), url=url) 
     31            data[name] = row 
     32 
     33        # final row 
     34        row = {} 
     35        for state in ['drafting', 'pending', 'published']: 
     36            collection = self.context[state] 
     37            url = collection.absolute_url() 
     38            brains = collection.queryCatalog() 
     39            row[state] = dict(count=len(brains), url=url)             
     40        data['all'] = row 
     41         
     42        return data 
     43 
    1544    # Methods called from the associated template 
    1645     
  • pleiades.workspace/trunk/pleiades/workspace/config.py

    r1368 r1374  
    1717ADD_PERMISSIONS = { 
    1818    "Workspace" : "Pleiades: Add Workspace", 
     19    "Workspace Collection" : "Add portal content", 
    1920    "Workspace Folder" : "Add portal content" 
    2021} 
  • pleiades.workspace/trunk/pleiades/workspace/content/configure.zcml

    r1327 r1374  
    1616  </class> 
    1717 
     18  <class class=".workspace.WorkspaceCollection"> 
     19    <require 
     20      permission="zope2.View" 
     21      interface="..interfaces.IWorkspaceCollection" 
     22      /> 
     23    <require 
     24      permission="cmf.ModifyPortalContent" 
     25      set_schema="..interfaces.IWorkspaceCollection" 
     26      /> 
     27  </class> 
     28 
    1829  <class class=".folder.WorkspaceFolder"> 
    1930    <require 
     
    2738  </class> 
    2839 
     40  <subscriber handler=".workspace.add_workspace_collections"/> 
     41 
    2942</configure> 
  • pleiades.workspace/trunk/pleiades/workspace/content/workspace.py

    r1373 r1374  
    1313from Products.Archetypes.interfaces import IObjectInitializedEvent 
    1414 
    15 from Products.ATContentTypes.content import folder 
     15from Products.ATContentTypes.content import folder, topic 
    1616from Products.ATContentTypes.content.schemata import finalizeATCTSchema 
    1717 
     
    2222from Products.PleiadesEntity.content.LocationContainer import LocationContainer 
    2323 
    24 from pleiades.workspace.interfaces import IResource, IWorkspace 
     24from pleiades.workspace.interfaces import IResource, IWorkspace, IWorkspaceCollection 
    2525from pleiades.workspace.event import ResourceModifiedEvent 
     26 
     27 
     28class WorkspaceCollection(topic.ATTopic): 
     29    """Specialized topic. 
     30    """ 
     31    implements(IWorkspaceCollection) 
     32    portal_type = "Workspace Collection" 
     33 
    2634 
    2735# This is the Archetypes schema, defining fields and widgets. We extend 
     
    8694    text = atapi.ATFieldProperty('text') 
    8795 
    88     def initTopic(self, oid, type): 
    89         topic = self[oid] 
    90         c = topic.addCriterion('pleiades_wsuids', 'ATSimpleStringCriterion') 
    91         c.setValue(self.UID()) 
    92         c = topic.addCriterion('Type', 'ATPortalTypeCriterion') 
    93         c.setValue(type) 
    94  
    95     def initializeArchetype(self, **kwargs): 
    96         tid = self.invokeFactory('Topic', id='locations', title='Locations') 
    97         self.initTopic(tid, 'Location') 
    98         tid = self.invokeFactory('Topic', id='names', title='Names') 
    99         self.initTopic(tid, 'Name') 
    100         tid = self.invokeFactory('Topic', id='features', title='Features') 
    101         self.initTopic(tid, 'Feature') 
    102         tid = self.invokeFactory('Topic', id='places', title='Places') 
    103         self.initTopic(tid, 'Place') 
    104  
    10596    def attach(self, ob): 
    10697        IResource(ob).wsuids = [self.UID()] 
     
    114105# This line tells Archetypes about the content type 
    115106atapi.registerType(Workspace, PROJECTNAME) 
     107atapi.registerType(WorkspaceCollection, PROJECTNAME) 
    116108 
     109 
     110def initTypeTopic(topic, type, uid, acquire=True): 
     111    topic.setAcquireCriteria(acquire) 
     112    c = topic.addCriterion('pleiades_wsuids', 'ATSimpleStringCriterion') 
     113    c.setValue(uid) 
     114    c = topic.addCriterion('Type', 'ATPortalTypeCriterion') 
     115    c.setValue(type) 
     116 
     117def initStateTopic(topic, state, uid, acquire=True): 
     118    topic.setAcquireCriteria(acquire) 
     119    c = topic.addCriterion('pleiades_wsuids', 'ATSimpleStringCriterion') 
     120    c.setValue(uid) 
     121    c = topic.addCriterion('review_state', 'ATSimpleStringCriterion') 
     122    c.setValue(state) 
     123 
     124@adapter(IWorkspace, IObjectInitializedEvent) 
     125def add_workspace_collections(ob, event): 
     126    types = [('locations', 'Location'), 
     127             ('names', 'Name'), 
     128             ('features', 'Feature'), 
     129             ('places', 'Place')] 
     130    states = ['drafting', 'pending', 'published'] 
     131    for name, tname in types: 
     132        tid = ob.invokeFactory( 
     133                'Workspace Collection', id=name, title=name.capitalize() 
     134                ) 
     135        topic = ob[tid] 
     136        initTypeTopic(topic, tname, ob.UID()) 
     137        for s in states: 
     138            sid = topic.invokeFactory( 
     139                    'Workspace Collection', id=s, title=s.capitalize() 
     140                    ) 
     141            subtopic = topic[sid] 
     142            initStateTopic(subtopic, sid, ob.UID(), True) 
     143    for s in states: 
     144        sid = ob.invokeFactory( 
     145                'Workspace Collection', id=s, title=s.capitalize() 
     146                ) 
     147        topic = ob[sid] 
     148        initStateTopic(topic, s, ob.UID()) 
     149        for name, tname in types: 
     150            tid = topic.invokeFactory( 
     151                    'Workspace Collection', id=name, title=name.capitalize() 
     152                    ) 
     153            subtopic = topic[tid] 
     154            initTypeTopic(subtopic, tname, ob.UID(), True) 
  • pleiades.workspace/trunk/pleiades/workspace/interfaces.py

    r1373 r1374  
    1111 
    1212 
     13class IWorkspaceCollection(Interface): 
     14 
     15    contains('pleiades.workspace.interfaces.IWorkspaceCollection') 
     16 
     17 
    1318class IWorkspace(Interface): 
    1419    """A container 
    1520    """ 
    16     contains('Products.PleiadesEntity.content.interfaces.ILocationContainer', 
    17              'Products.PleiadesEntity.content.interfaces.IPlaceContainer', 
     21    contains('pleiades.workspace.interfaces.IWorkspaceCollection', 
    1822             'Products.ATContentTypes.interfaces.IATFolder' 
    1923             ) 
  • pleiades.workspace/trunk/pleiades/workspace/profiles/default/types.xml

    r1327 r1374  
    1414 
    1515  <object 
     16    name="Workspace Collection" 
     17    meta_type="Factory-based Type Information with dynamic views" 
     18    /> 
     19 
     20  <object 
    1621    name="Workspace Folder" 
    1722    meta_type="Factory-based Type Information with dynamic views" 
  • pleiades.workspace/trunk/pleiades/workspace/profiles/default/types/Workspace.xml

    r1355 r1374  
    4444  <property name="filter_content_types">True</property> 
    4545  <property name="allowed_content_types"> 
    46     <element value="Place Container" /> 
    47     <element value="Location Container" /> 
    4846    <element value="Folder" /> 
    4947    <element value="Topic" /> 
     48    <element value="Workspace Collection" /> 
    5049  </property> 
    5150  
  • pleiades.workspace/trunk/pleiades/workspace/tests/base.py

    r1359 r1374  
    2121    # This includes the other products below as well. 
    2222     
    23     #fiveconfigure.debug_mode = True 
    24     #import pleiades.workspace 
    25     #zcml.load_config('configure.zcml', pleiades.workspace) 
    26     #fiveconfigure.debug_mode = False 
     23    fiveconfigure.debug_mode = True 
     24    import pleiades.workspace 
     25    zcml.load_config('configure.zcml', pleiades.workspace) 
     26    fiveconfigure.debug_mode = False 
    2727     
    2828    # We need to tell the testing framework that these products 
  • pleiades.workspace/trunk/pleiades/workspace/tests/factory.txt

    r1359 r1374  
    1919    >>> wsid = folder.invokeFactory('Workspace', id='test-ws', title='Testing') 
    2020    >>> ws = folder[wsid] 
     21    >>> from zope.event import notify 
     22    >>> from Products.Archetypes.event import ObjectInitializedEvent 
     23    >>> notify(ObjectInitializedEvent(ws)) 
    2124    >>> 'places' in ws.objectIds() 
    2225    True 
     
    2730    >>> 'names' in ws.objectIds() 
    2831    True 
     32    >>> 'drafting' in ws.objectIds() 
     33    True 
     34    >>> 'drafting' in ws['places'].objectIds() 
     35    True 
  • pleiades.workspace/trunk/pleiades/workspace/tests/kml-import.txt

    r1359 r1374  
    1313    >>> wsid = folder.invokeFactory('Workspace', id='test-ws', title='Testing') 
    1414    >>> ws = folder[wsid] 
     15    >>> from zope.event import notify 
     16    >>> from Products.Archetypes.event import ObjectInitializedEvent 
     17    >>> notify(ObjectInitializedEvent(ws)) 
    1518    >>> 'places' in ws.objectIds() 
    1619    True 
  • pleiades.workspace/trunk/pleiades/workspace/tests/test_doctest.py

    r1355 r1374  
    22import doctest 
    33from zope.testing import doctestunit 
    4 from zope.component import testing, eventtesting 
     4import zope.component.eventtesting 
    55from Testing import ZopeTestCase as ztc 
    66from pleiades.workspace.tests import base 
     
    3030            package='pleiades.workspace.tests', 
    3131            test_class=base.WorkspaceFunctionalTestCase, 
    32             optionflags=doctest.REPORT_ONLY_FIRST_FAILURE | doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS), 
     32            optionflags=optionflags 
     33            ), 
    3334        ztc.ZopeDocFileSuite( 
    3435            'xml-import.txt', 
    3536            package='pleiades.workspace.tests', 
    3637            test_class=base.WorkspaceFunctionalTestCase, 
    37             optionflags=doctest.REPORT_ONLY_FIRST_FAILURE | doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS), 
     38            optionflags=optionflags 
     39            ), 
    3840        ]) 
    3941 
  • pleiades.workspace/trunk/pleiades/workspace/tests/workspaces.txt

    r1373 r1374  
    1717    >>> wsid = spaces.invokeFactory('Workspace', id='test-ws', title='Testing') 
    1818    >>> ws = spaces[wsid] 
     19    >>> from zope.event import notify 
     20    >>> from Products.Archetypes.event import ObjectInitializedEvent 
     21    >>> notify(ObjectInitializedEvent(ws)) 
    1922 
    2023Create some test entities 
  • pleiades.workspace/trunk/pleiades/workspace/tests/xml-import.txt

    r1359 r1374  
    1313    >>> wsid = folder.invokeFactory('Workspace', id='test-ws', title='Testing') 
    1414    >>> ws = folder[wsid] 
     15    >>> from zope.event import notify 
     16    >>> from Products.Archetypes.event import ObjectInitializedEvent 
     17    >>> notify(ObjectInitializedEvent(ws)) 
    1518    >>> 'places' in ws.objectIds() 
    1619    True