Changeset 1288

Show
Ignore:
Timestamp:
04/25/08 15:40:07 (7 months ago)
Author:
sgillies
Message:

Working tests of the content factory

Files:

Legend:

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

    r1287 r1288  
    5151            ).initialize(context) 
    5252 
    53 def createWorkspace(self, id, **kwargs): 
    54     import pdb; pdb.set_trace() 
    55     return id 
    56  
  • pleiades.workspace/trunk/pleiades/workspace/config.py

    r1287 r1288  
    1515 
    1616ADD_PERMISSIONS = { 
    17     "Pleiades Workspace" : "Pleiades: Add Workspace", 
     17    "Workspace" : "Pleiades: Add Workspace", 
    1818} 
  • pleiades.workspace/trunk/pleiades/workspace/content/configure.zcml

    r1287 r1288  
    11<configure 
    2     xmlns="http://namespaces.zope.org/zope" 
    3     xmlns:five="http://namespaces.zope.org/five" 
    4     i18n_domain="optilux.cinemacontent"> 
     2  xmlns="http://namespaces.zope.org/zope" 
     3  xmlns:five="http://namespaces.zope.org/five" 
     4  i18n_domain="pleiades.workspace" 
     5  > 
    56 
    6     <!-- Declare security for the field properties of the various content 
    7          types, and register other components, such as validation subscription 
    8          adapters, event subscribers (for adding a portlet to a newly created 
    9          cinema folder), and adapter factories. 
    10          
    11       --> 
    12  
    13     <!-- Cinema folders: --> 
    14      
    15     <class class=".cinemafolder.CinemaFolder"> 
    16         <require 
    17             permission="zope2.View" 
    18             interface="..interfaces.ICinemaFolder" 
    19             /> 
    20         <require 
    21             permission="cmf.ModifyPortalContent" 
    22             set_schema="..interfaces.ICinemaFolder" 
    23             /> 
    24     </class> 
    25      
    26     <subscriber handler=".cinemafolder.add_promotions_portlet" /> 
    27      
    28     <!-- Cinemas: --> 
    29      
    30     <class class=".cinema.Cinema"> 
    31         <require 
    32             permission="zope2.View" 
    33             interface="..interfaces.ICinema" 
    34             /> 
    35         <require 
    36             permission="cmf.ModifyPortalContent" 
    37             set_schema="..interfaces.ICinema" 
    38             /> 
    39     </class> 
    40      
    41     <subscriber  
    42         provides="Products.Archetypes.interfaces.IObjectPostValidation" 
    43         factory=".cinema.ValidateCinemaCodeUniqueness"  
    44         /> 
    45      
    46     <!-- Film folders: --> 
    47      
    48     <class class=".filmfolder.FilmFolder"> 
    49         <require 
    50             permission="zope2.View" 
    51             interface="..interfaces.IFilmFolder" 
    52             /> 
    53         <require 
    54             permission="cmf.ModifyPortalContent" 
    55             set_schema="..interfaces.IFilmFolder" 
    56             /> 
    57     </class> 
    58      
    59     <!-- Films: --> 
    60      
    61     <class class=".film.Film"> 
    62         <require 
    63             permission="zope2.View" 
    64             interface="..interfaces.IFilm" 
    65             /> 
    66         <require 
    67             permission="cmf.ModifyPortalContent" 
    68             set_schema="..interfaces.IFilm" 
    69             /> 
    70         <require 
    71             permission="zope2.View" 
    72             attributes="tag" 
    73             /> 
    74     </class> 
    75      
    76     <adapter factory=".film.BannerProvider" /> 
    77      
    78     <subscriber  
    79         provides="Products.Archetypes.interfaces.IObjectPostValidation" 
    80         factory=".film.ValidateFilmCodeUniqueness"  
    81         /> 
    82          
    83     <utility 
    84         component=".film.CurrentFilmsVocabularyFactory" 
    85         name="optilux.cinemacontent.CurrentFilms" 
    86         /> 
    87      
    88     <!-- Promotions: --> 
    89      
    90     <class class=".promotion.Promotion"> 
    91         <require 
    92             permission="zope2.View" 
    93             interface="..interfaces.IPromotion" 
    94             /> 
    95         <require 
    96             permission="cmf.ModifyPortalContent" 
    97             set_schema="..interfaces.IPromotion" 
    98             /> 
    99         <require 
    100             permission="zope2.View" 
    101             attributes="tag" 
    102             /> 
    103     </class> 
    104      
    105     <adapter factory=".promotion.BannerProvider" /> 
     7  <class class=".workspace.Workspace"> 
     8    <require 
     9      permission="zope2.View" 
     10      interface="..interfaces.IWorkspace" 
     11      /> 
     12    <require 
     13      permission="cmf.ModifyPortalContent" 
     14      set_schema="..interfaces.IWorkspace" 
     15      /> 
     16  </class> 
    10617     
    10718</configure> 
  • pleiades.workspace/trunk/pleiades/workspace/content/workspace.py

    r1287 r1288  
    2626from Products.ATContentTypes.content.schemata import finalizeATCTSchema 
    2727 
    28 from optilux.cinemacontent.interfaces import ICinemaFolder 
     28from pleiades.workspace.interfaces import IWorkspace 
     29from pleiades.workspace.config import PROJECTNAME 
     30from pleiades.workspace import WorkspaceMessageFactory as _ 
    2931 
    30 from optilux.cinemacontent.config import PROJECTNAME 
    31 from optilux.cinemacontent.config import PROMOTIONS_PORTLET_COLUMN 
    32  
    33 from optilux.cinemacontent import CinemaMessageFactory as _ 
    34 from optilux.cinemacontent.portlets import promotions 
     32from Products.PleiadesEntity.content.PlaceContainer import PlaceContainer 
     33from Products.PleiadesEntity.content.LocationContainer import LocationContainer 
    3534 
    3635# This is the Archetypes schema, defining fields and widgets. We extend 
    3736# the one from ATContentType's ATFolder with our additional fields. 
    38 CinemaFolderSchema = folder.ATFolderSchema.copy() + atapi.Schema(( 
     37WorkspaceSchema = folder.ATFolderSchema.copy() + atapi.Schema(( 
    3938    atapi.TextField('text', 
    4039        required=False, 
     
    5554# attributestorage 
    5655 
    57 CinemaFolderSchema['title'].storage = atapi.AnnotationStorage() 
    58 CinemaFolderSchema['description'].storage = atapi.AnnotationStorage() 
     56WorkspaceSchema['title'].storage = atapi.AnnotationStorage() 
     57WorkspaceSchema['description'].storage = atapi.AnnotationStorage() 
    5958     
    6059# Calling this re-orders a few fields to comply with Plone conventions. 
    61 finalizeATCTSchema(CinemaFolderSchema, folderish=True, moveDiscussion=False) 
     60finalizeATCTSchema(WorkspaceSchema, folderish=True, moveDiscussion=False) 
    6261 
    63 class CinemaFolder(folder.ATFolder): 
     62class Workspace(folder.ATFolder): 
    6463    """Contains multiple cinemas 
    6564     
     
    6867    into sub-groups. 
    6968    """ 
    70     implements(ICinemaFolder
     69    implements(IWorkspace
    7170     
    7271    # The portal type name must be set here, matching the one in types.xml 
    7372    # in the GenericSetup profile 
    74     portal_type = "Cinema Folder
     73    portal_type = "Workspace
    7574     
    7675    # This enables Archetypes' standard title-to-id renaming machinery 
     
    8079     
    8180    # We then associate the schema with our content type 
    82     schema = CinemaFolderSchema 
     81    schema = WorkspaceSchema 
    8382     
    8483    # Our interface specifies that we should use simple Python properties 
     
    9493    description = atapi.ATFieldProperty('description') 
    9594    text = atapi.ATFieldProperty('text') 
    96      
     95 
     96    def initializeArchetype(self, **kwargs): 
     97        self['places'] = PlaceContainer('places') 
     98        self['locations'] = LocationContainer('locations') 
     99        self['names'] = folder.ATFolder('names') 
     100 
    97101# This line tells Archetypes about the content type 
    98 atapi.registerType(CinemaFolder, PROJECTNAME) 
     102atapi.registerType(Workspace, PROJECTNAME) 
    99103 
    100 # We will register this function as an event handler, adding a "promotions" 
    101 # portlet whenever a cinema folder is first created.  
    102 @adapter(ICinemaFolder, IObjectInitializedEvent) 
    103 def add_promotions_portlet(obj, event): 
    104      
    105     # Only do this if the parent is not a cinema folder, i.e. only do it on 
    106     # top-level cinema folders. Of course, site managers can move things  
    107     # around once the site structure is created 
    108      
    109     parent = aq_parent(aq_inner(obj)) 
    110     if ICinemaFolder.providedBy(parent): 
    111         return 
    112      
    113     # A portlet manager is akin to a column 
    114     column = getUtility(IPortletManager, name=PROMOTIONS_PORTLET_COLUMN) 
    115      
    116     # We multi-adapt the object and the column to an assignment mapping, 
    117     # which acts like a dict where we can put portlet assignments 
    118     manager = getMultiAdapter((obj, column,), IPortletAssignmentMapping) 
    119      
    120     # We then create the assignment and put it in the assignment manager, 
    121     # using the default name-chooser to pick a suitable name for us. 
    122     assignment = promotions.Assignment() 
    123     chooser = INameChooser(manager) 
    124     manager[chooser.chooseName(None, assignment)] = assignment 
  • pleiades.workspace/trunk/pleiades/workspace/profiles/default/factorytool.xml

    r1287 r1288  
    99  --> 
    1010<object name="portal_factory" meta_type="Plone Factory Tool"> 
    11  <factorytypes> 
    12   <type portal_type="Workspace"/> 
    13  </factorytypes> 
     11  <factorytypes> 
     12    <type portal_type="Workspace"/> 
     13  </factorytypes> 
    1414</object> 
  • pleiades.workspace/trunk/pleiades/workspace/profiles/default/rolemap.xml

    r1287 r1288  
    1010      --> 
    1111    <permission 
    12       name="Optilux: Add Workspace" 
     12      name="Pleiades: Add Workspace" 
    1313      acquire="False" 
    1414      > 
  • pleiades.workspace/trunk/pleiades/workspace/profiles/default/types/Workspace.xml

    r1287 r1288  
    3232  <property name="content_meta_type">Workspace</property> 
    3333  <property name="product">pleiades.workspace</property> 
    34   <property name="factory">createWorkspace</property> 
     34  <property name="factory">addWorkspace</property> 
    3535  
    3636 <!-- The immediate_view is supposed to be the view that is shown immediately 
  • pleiades.workspace/trunk/pleiades/workspace/tests/base.py

    r1287 r1288  
    77from Products.PloneTestCase.layer import onsetup 
    88 
     9ztc.installProduct('ATVocabularyManager') 
     10ztc.installProduct('PleiadesEntity') 
     11 
    912@onsetup 
    10 def setup_optilux_cinemacontent(): 
     13def setup_pleiades_workspace(): 
    1114    """Set up the additional products required for the Optilux Cinema Content. 
    1215     
     
    1922     
    2023    fiveconfigure.debug_mode = True 
    21     import optilux.cinemacontent 
    22     zcml.load_config('configure.zcml', optilux.cinemacontent
     24    import pleiades.workspace 
     25    zcml.load_config('configure.zcml', pleiades.workspace
    2326    fiveconfigure.debug_mode = False 
    2427     
     
    2730    # the ZCML. 
    2831     
    29     ztc.installPackage('optilux.cinemacontent') 
     32    ztc.installPackage('pleiades.workspace') 
    3033     
    3134# The order here is important: We first call the (deferred) function which 
     
    3336# PloneTestCase set up this product on installation. 
    3437 
    35 setup_optilux_cinemacontent() 
    36 ptc.setupPloneSite(products=['optilux.cinemacontent']) 
     38setup_pleiades_workspace() 
     39ptc.setupPloneSite(products=['ATVocabularyManager', 'PleiadesEntity', 'pleiades.workspace']) 
    3740 
    38 class CinemaContentTestCase(ptc.PloneTestCase): 
     41class WorkspaceTestCase(ptc.PloneTestCase): 
    3942    """Base class used for test cases 
    4043    """ 
    4144         
    42 class CinemaContentFunctionalTestCase(ptc.FunctionalTestCase): 
     45class WorkspaceFunctionalTestCase(ptc.FunctionalTestCase): 
    4346    """Test case class used for functional (doc-)tests 
    4447    """ 
  • pleiades.workspace/trunk/pleiades/workspace/tests/test_doctest.py

    r1287 r1288  
    11import unittest 
    22import doctest 
    3  
    43from zope.testing import doctestunit 
    54from zope.component import testing, eventtesting 
     5from Testing import ZopeTestCase as ztc 
     6from pleiades.workspace.tests import base 
    67 
    7 from Testing import ZopeTestCase as ztc 
    8  
    9 from optilux.cinemacontent.tests import base 
    108 
    119def test_suite(): 
    1210    return unittest.TestSuite([ 
    13  
    14         # Demonstrate the main content types 
    1511        ztc.ZopeDocFileSuite( 
    16             'README.txt', package='optilux.cinemacontent', 
    17             test_class=base.CinemaContentFunctionalTestCase, 
     12            'factory.txt', 
     13            package='pleiades.workspace.tests', 
     14            test_class=base.WorkspaceFunctionalTestCase, 
    1815            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE | doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS), 
    19  
    2016        ]) 
    2117