[CMF-checkins] CVS: CMF - README.txt:1.1 AbstractCriterion.py:1.2 Topic.py:1.17 __init__.py:1.8 version.txt:1.3

Jeffrey Shell jeffrey@digicool.com
Wed, 11 Apr 2001 14:40:03 -0400 (EDT)


Update of /cvs-repository/CMF/CMFTopic
In directory korak:/home/jeffrey/InstanceHomes/cmf-dev/CMF/CMFTopic

Modified Files:
	AbstractCriterion.py Topic.py __init__.py version.txt 
Added Files:
	README.txt 
Log Message:
Dealing with CMF Topic issue (248), a lot of work done to move usage of REQUEST out of Topic.py and into Python Scripts in the default Topic skins.


--- Added File README.txt in package CMF ---
Installing CMF Topic into a CMF Site

 Since the CMF allows site by site configuration, just having CMF
 Topic installed into your Zope does not mean that any CMF Site
 instance will know what to do with it.  To get CMF Topic installed
 and registered, you need to go to the root of the CMF Site (aka
 *Portal* instance) that you want CMF Topic to be registered in and add an 
 External Method with the following configuration:

   **id** -- 'install_topic'
   **title** -- *Install Topic*
   **module name** -- 'CMFTopic.Install'
   **function name** -- 'install'

 Then go to the management screen for the newly added external method
 and click the 'Try it' tab.  The install function will execute and give
 information about the steps it took to register and install the CMF Topic
 into the CMF Site instance.

--- Updated File AbstractCriterion.py in package CMF --
--- AbstractCriterion.py	2001/03/01 16:59:05	1.1
+++ AbstractCriterion.py	2001/04/11 18:39:31	1.2
@@ -99,6 +99,15 @@
 
     security = ClassSecurityInfo()
 
+    security.declareProtected(ChangeTopics, 'apply')
+    def apply(self, command):
+        """\
+        command is expected to be a dictionary.  It gets applied
+        to self.edit, and exists to make using Python Scripts
+        easier.
+        """
+        apply(self.edit, (), command)
+
     security.declareProtected(ChangeTopics, 'editableAttributes')
     def editableAttributes(self):
         """\

--- Updated File Topic.py in package CMF --
--- Topic.py	2001/04/09 20:21:06	1.16
+++ Topic.py	2001/04/11 18:39:31	1.17
@@ -224,8 +224,7 @@
         return self.objectValues(self.meta_type)
 
     security.declareProtected(TopicPermissions.ChangeTopics, 'edit')
-    def edit(self, acquireCriteria, title=None, description=None,
-             REQUEST=None):
+    def edit(self, acquireCriteria, title=None, description=None):
         """\
         Enable the acquisition of criteria from parent topics, and update
         other meta data about the Topic.
@@ -234,9 +233,7 @@
         if title is not None: self.title = title
         self.description = description
         
-        if REQUEST is not None:
-            REQUEST['RESPONSE'].redirect('%s/topic_view' % self.absolute_url())
-    
+
     security.declareProtected(CMFCorePermissions.View, 'buildQuery')
     def buildQuery(self):
         """ Uses the criteria objects to construct a catalog query. """
@@ -268,7 +265,7 @@
 
     ### Criteria adding/editing/deleting
     security.declareProtected(TopicPermissions.ChangeTopics, 'addCriteria')
-    def addCriteria(self, field, criteria_type, REQUEST=None):
+    def addCriteria(self, field, criteria_type):
         """ Create a new search criteria in this topic """
         crit = None
         newid = 'crit__%s' % field
@@ -282,82 +279,29 @@
         
         self._setObject(newid, crit)
 
-        if REQUEST is not None:
-            message = urllib.quote_plus('New criteria added.')
-            REQUEST['RESPONSE'].redirect(
-                '%s/topic_criteria?portal_status_message=%s' % (
-                self.absolute_url(), message)
-                )
-
-    security.declareProtected(TopicPermissions.ChangeTopics, 'deleteCriteria')
-    def deleteCriteria(self, criterion_ids=[], REQUEST=None):
+    security.declareProtected(TopicPermissions.ChangeTopics, 'deleteCriterion')
+    def deleteCriterion(self, criterion_id):
         """ Delete selected criteria """
-        for cid in criterion_ids:
-            self._delObject(cid)
-
-        if REQUEST is not None:
-            message = urllib.quote_plus('Criteria deleted.')
-            REQUEST['RESPONSE'].redirect(
-                '%s/topic_criteria?portal_status_message=%s' % (
-                self.absolute_url(), message)
-                )
+        if type(criterion_id) is type(''):
+            self._delObject(criterion_id)
+        elif type(criterion_id) in (type(()), type([])):
+            for cid in criterion_id:
+                self._delObject(cid)
+
+    security.declarePublic(CMFCorePermissions.View, 'getCriterion')
+    def getCriterion(self, criterion_id):
+        """ Get the criterion object """
+        return self._getOb(criterion_id)
 
-    security.declareProtected(TopicPermissions.ChangeTopics, 'editCriteria')
-    def editCriteria(self, criteria=[], REQUEST=None):
-        """\
-        Save changes to the list of criteria.  This is done by going over
-        the submitted criteria records and comparing them against the
-        criteria object's editable attributes.  A 'command' object is
-        built to send to the Criteria objects 'edit' command.
-        """
-        for rec in criteria:
-            crit = self._getOb(rec.id)
-            command = {}
-            for attr in crit._editableAttributes:
-                tmp = getattr(rec, attr, None)
-                # Due to having multiple radio buttons on the same page
-                # with the same name, but belonging to different records,
-                # they needed to be associated with different ids.
-                if tmp is None:
-                    tmp = getattr(rec, '%s__%s' % (attr, rec.id), None)
-                
-                command[attr] = tmp
-            apply(crit.edit, (), command)
-
-        if REQUEST is not None:
-            message = urllib.quote_plus('Changes saved.')
-            REQUEST['RESPONSE'].redirect(
-                '%s/topic_criteria?portal_status_message=%s' % (
-                self.absolute_url(), message)
-                )
-
     security.declareProtected(TopicPermissions.AddTopics, 'addSubtopic')
-    def addSubtopic(self, id, REQUEST=None):
+    def addSubtopic(self, id):
         """ Add a new subtopic """
-        types = utils.getToolByName(self, 'portal_types')
-        topictype = types.getTypeInfo('Topic')
-
+        topictype = self.getTypeInfo()
         topictype.constructInstance(self, id)
 
-        if REQUEST is not None:
-            action = topictype.getActionById('subtopics')
-            url = '%s/%s?portal_status_message=%s' % (
-                self.absolute_url(), action,
-                urllib.quote_plus("Subtopic '%s' added" % id ))
-            REQUEST['RESPONSE'].redirect(url)
-        else:
-            return self._getOb(id)
+        return self._getOb(id)
 
 
 # Intialize the Topic class, setting up security.
 InitializeClass(Topic)
 
-# Waah.  This seems to be the only way to get the icon in correctly
-##from Products.CMFCore.register import registerPortalContent
-##registerPortalContent(
-##    Topic,
-##    meta_type='Portal Topic',
-##    icon = 'images/topic.gif',
-##    permission = TopicPermissions.AddTopics,
-##    productGlobals = globals(),
-##    )

--- Updated File __init__.py in package CMF --
--- __init__.py	2001/03/30 16:48:59	1.7
+++ __init__.py	2001/04/11 18:39:31	1.8
@@ -113,7 +113,7 @@
 registerDirectory('skins/topic', globals())
 
 def initialize( context ):
-    context.registerHelpTitle('PortalTopic Help')
+    context.registerHelpTitle('CMF Topic Help')
     context.registerHelp(directory='help')
 
     # CMF Initializers

--- Updated File version.txt in package CMF --
--- version.txt	2001/03/29 23:13:43	1.2
+++ version.txt	2001/04/11 18:39:31	1.3
@@ -1 +1 @@
-1.0
+1.1a1