[zopeorg-checkins] CVS: Products/ZopeOrg-NV - CaseStudy.py:1.2 ZopeServiceProvider.py:1.2 __init__.py:1.18

Sidnei da Silva sidnei at x3ng.com.br
Mon Jan 20 14:03:05 EST 2003


Update of /cvs-zopeorg/Products/ZopeOrg-NV
In directory cvs.zope.org:/tmp/cvs-serv32678

Modified Files:
	CaseStudy.py ZopeServiceProvider.py __init__.py 
Log Message:
Initialize content types and add a few management views.

=== Products/ZopeOrg-NV/CaseStudy.py 1.1 => 1.2 ===
 from Products.CMFDefault.Document import Document
 from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
 from AccessControl import ClassSecurityInfo
+from Acquisition import aq_base
+
+factory_type_information = ( { 'id'             : 'Case Study'
+                             , 'meta_type'      : 'Case Study'
+                             , 'description'    : """\
+A Case Study holds details about sucessful implementations of
+Zope by Community Members or Zope Service Providers."""
+                             , 'icon'           : 'document_icon.gif'
+                             , 'product'        : 'ZopeOrg'
+                             , 'factory'        : 'addCaseStudy'
+                             , 'immediate_view' : 'casestudy_edit_form'
+                             , 'actions'        :
+                                ( { 'id'            : 'view' 
+                                  , 'name'          : 'View'
+                                  , 'action'        : 'casestudy_view'
+                                  , 'permissions'   : (View,)
+                                  }
+                                , { 'id'            : 'edit'
+                                  , 'name'          : 'Edit'
+                                  , 'action'        : 'casestudy_edit_form'
+                                  , 'permissions'   : (ModifyPortalContent,)
+                                  }
+                                , { 'id'            : 'metadata'
+                                  , 'name'          : 'Metadata'
+                                  , 'action'        : 'metadata_edit_form'
+                                  , 'permissions'   : (ModifyPortalContent,)
+                                  }
+                                )
+                             }
+                           ,
+                           )
 
 class CaseStudy(Document):
 
@@ -17,22 +48,26 @@
     _problem = ''
     _solution = ''
     _logo = ''
+    _stx_level = 2
 
     def __init__(self, id, title='', description='', text_format='', text=''):
         DefaultDublinCoreImpl.__init__(self)
         Document.__init__(self, id, title, description, text_format, text)
 
     security.declareProtected(View, 'Summary')
-    Summary = Description
+    Summary = Document.Description
 
     security.declareProtected(ModifyPortalContent, 'setSummary')
-    setSummary = setDescription
+    setSummary = Document.setDescription
+
+    security.declareProtected(View, 'editableCaseFacts')
+    editableCaseFacts = Document.EditableBody
 
     security.declareProtected(View, 'CaseFacts')
-    CaseFacts = CookedBody
+    CaseFacts = Document.CookedBody
     
     security.declareProtected(ModifyPortalContent, 'setCaseFacts')
-    setCaseFacts = edit
+    setCaseFacts = Document.edit
 
     security.declareProtected(View, 'ExternalURL')
     def ExternalURL(self):
@@ -42,6 +77,10 @@
     def setExternalURL(self, external_url):
         self._external_url = external_url
 
+    security.declareProtected(View, 'Logo')
+    def Logo(self):
+        return self._logo
+
     security.declareProtected(View, 'getLogo')
     def getLogo(self):
         logo = self._logo
@@ -53,28 +92,76 @@
     def setLogo(self, logo):
         self._logo = logo
 
+    security.declareProtected(View, 'editableProblem')
+    def editableProblem(self):
+        return self._problem
+
     security.declareProtected(View, 'Problem')
     def Problem(self):
-        return getCookedText(self, self._problem)
+        return self._getCookedText('_problem')
 
     security.declareProtected(ModifyPortalContent, 'setProblem')
-    def setProblem(self, problem):
-        self._problem = problem
+    def setProblem(self, text_format, problem, file, safety_belt):
+        self._editText(text_format, problem, file, safety_belt, '_problem')
+
+    security.declareProtected(View, 'editableSolution')
+    def editableSolution(self):
+        return self._solution
 
     security.declareProtected(View, 'Solution')
     def Solution(self):
-        return getCookedText(self, self._solution)
+        return self._getCookedText('_solution')
 
     security.declareProtected(ModifyPortalContent, 'setSolution')
-    def setSolution(self, solution):
-        self._solution = solution
+    def setSolution(self, text_format, solution, file, safety_belt):
+        self._editText(text_format, solution, file, safety_belt, '_solution')
+
+    def _getCookedText(self, property, stx_level=None, set_level=0):
+        text_format = getattr(aq_base(self), '%s_text_format' %property, \
+                              'structured-text')
+        text = getattr(aq_base(self), property, '')
+        cooked = getattr(aq_base(self), 'cooked%s' %property, '')
+        if (text_format == 'html' or text_format == 'plain'
+            or (stx_level is None)
+            or (stx_level == self._stx_level)):
+            return cooked
+        else:
+            cooked = format_stx(text, stx_level)
+            if set_level:
+                self._stx_level = stx_level
+                setattr(self, 'cooked%s' %property, cooked)
+            return cooked
+
+    def _editText(self, text_format='structured-text', text='', \
+                  file=None, safety_belt='', property='text'):
+        level = self._stx_level
+        if not text_format:
+            text_format = getattr(aq_base(self), '%s_text_format' %property, \
+                                  'structured-text')
+        if not safety_belt:
+            safety_belt = ''
+        if not self._safety_belt_update(safety_belt=safety_belt):
+            msg = ("Intervening changes from elsewhere detected."
+                   " Please refetch the document and reapply your changes."
+                   " (You may be able to recover your version using the"
+                   " browser 'back' button, but will have to apply them"
+                   " to a freshly fetched copy.)")
+            raise 'EditingConflict', msg
+        if text_format == 'html':
+            setattr(self, property, text)
+            setattr(self, 'cooked%s' %property, text)
+        elif text_format == 'plain':
+            setattr(self, property, text)
+            setattr(self, 'cooked%s' %property, \
+                    html_quote(text).replace('\n','<br>'))
+        else:
+            setattr(self, property, text)
+            setattr(self, 'cooked%s' %property, \
+                    format_stx(text=text, level=level))
 
 InitializeClass(CaseStudy)
 
-def getCookedText(self, text, stx_level=None):
-    if (self.text_format == 'html' or self.text_format == 'plain'):
-        return text
-    else:
-        cooked = format_stx(text, stx_level)
-        return cooked
     
+def addCaseStudy( self , id, title=''):
+    cs = CaseStudy(id, title)
+    obj = self._setObject(id, cs) 


=== Products/ZopeOrg-NV/ZopeServiceProvider.py 1.1 => 1.2 ===
 from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl
 from AccessControl import ClassSecurityInfo
 
+factory_type_information = ( { 'id'             : 'Zope Service Provider'
+                             , 'meta_type'      : 'Zope Service Provider'
+                             , 'description'    : """\
+A Zope Service Provider holds contact info for companies that provide
+any kind of service related to Zope (Hosting, Consulting, Development)."""
+                             , 'icon'           : 'document_icon.gif'
+                             , 'product'        : 'ZopeOrg'
+                             , 'factory'        : 'addZSP'
+                             , 'immediate_view' : 'zsp_edit_form'
+                             , 'actions'        :
+                                ( { 'id'            : 'view' 
+                                  , 'name'          : 'View'
+                                  , 'action'        : 'document_view'
+                                  , 'permissions'   : (View,)
+                                  }
+                                , { 'id'            : 'edit'
+                                  , 'name'          : 'Edit'
+                                  , 'action'        : 'zsp_edit_form'
+                                  , 'permissions'   : (ModifyPortalContent,)
+                                  }
+                                , { 'id'            : 'metadata'
+                                  , 'name'          : 'Metadata'
+                                  , 'action'        : 'metadata_edit_form'
+                                  , 'permissions'   : (ModifyPortalContent,)
+                                  }
+                                )
+                             }
+                           ,
+                           )
+
 class ZopeServiceProvider(Document):
 
     portal_type = meta_type = "Zope Service Provider"
@@ -23,22 +53,22 @@
         Document.__init__(self, id, title, description, text_format, text)
 
     security.declareProtected(View, 'Company')
-    Company = Title
+    Company = Document.Title
 
     security.declareProtected(ModifyPortalContent, 'setCompany')
-    setCompany = setTitle
+    setCompany = Document.setTitle
 
     security.declareProtected(View, 'Summary')
-    Summary = Description
+    Summary = Document.Description
 
     security.declareProtected(ModifyPortalContent, 'setSummary')
-    setSummary = setDescription
+    setSummary = Document.setDescription
 
     security.declareProtected(View, 'ServiceInfo')
-    ServiceInfo = CookedBody
+    ServiceInfo = Document.CookedBody
     
     security.declareProtected(ModifyPortalContent, 'setServiceInfo')
-    setServiceInfo = edit
+    setServiceInfo = Document.edit
 
     security.declareProtected(View, 'Location')
     def Location(self):
@@ -76,3 +106,7 @@
         self._contact_email = contact_email
 
 InitializeClass(ZopeServiceProvider)
+
+def addZSP( self , id, title=''):
+    zsp = ZopeServiceProvider(id, title)
+    obj = self._setObject(id, zsp) 


=== Products/ZopeOrg-NV/__init__.py 1.17 => 1.18 ===
 #import ZopeOrgMembershipTool
 import ContentList
 import Acquisition
+import CaseStudy
+import ZopeServiceProvider
 
 #Hackish workaround to allow accesing the broken ZODB on ZopeOrg
 class ImplicitAcquirerWrapper:
@@ -21,10 +23,14 @@
 # Make the skins available as DirectoryViews
 registerDirectory('skins', globals())
 registerDirectory('skins/zopeorg', globals())
+registerDirectory('skins/zopeorg_products', globals())
 registerDirectory('skins/zopeorg_membership', globals())
 
 #ftis = SoftwareProduct.factory_type_information
 
+ftis = ( CaseStudy.factory_type_information + \
+         ZopeServiceProvider.factory_type_information )
+
 CL_CTORS = ( ( 'manage_addContentListForm', ContentList.addContentListForm )
            , ContentList.addContentList
            )
@@ -66,3 +72,15 @@
     #                         ),
     #    fti = ftis ,
     #    ).initialize(context)
+
+    ContentInit(
+       'Zope.org Content',
+       content_types = ( CaseStudy.CaseStudy
+                       , ZopeServiceProvider.ZopeServiceProvider
+                       ),
+       permission = AddPortalContent,
+       extra_constructors = ( CaseStudy.addCaseStudy
+                            , ZopeServiceProvider.addZSP
+                            ),
+       fti = ftis ,
+       ).initialize(context)





More information about the zopeorg-checkins mailing list