def initialize(context): """ The 'initialize' function of this Product. It is called when Zope is restarted with these files in the Products directory. (I'm not sure what it does or if it is neccessary at all. Best leave it alone.) """ log('Start: "initialize()"\n') try: content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) utils.ContentInit( PROJECTNAME + ' Content', content_types = content_types, permission = PERMISSION_ADD_MCTEST, extra_constructors = constructors, fti = ftis, ).initialize(context) log('\tWorked: "ContentInit()"\n') # Add permissions to allow control on a per-class basis for i in range(0, len(content_types)): content_type = content_types[i].__name__ if ADD_CONTENT_PERMISSIONS.has_key(content_type): context.registerClass(meta_type = ftis[i]['meta_type'], constructors = (constructors[i],), permission = ADD_CONTENT_PERMISSIONS[content_type]) from ECQTool import ECQTool utils.ToolInit( ECQTool.meta_type, tools = (ECQTool,), product_name = PROJECTNAME, icon = 'ECQTool.png', ).initialize(context) if profile_registry is not None: profile_registry.registerProfile('default', 'ECQuiz', 'Extension profile for ECQuiz', 'profiles/default', 'ECQuiz', EXTENSION, for_=IPloneSiteRoot) #~ parsers.initialize(context) #~ renderers.initialize(context) log('Worked: "initialize()"\n') except Exception, e: # Log any errors that occurred in 'initialize()' log('Failed: "initialize()": ' + str(e) + '\n')
def installQIDependencies(context): """Install dependencies """ if isNotECQuizProfile(context): return site = context.getSite() portal = getToolByName(site, 'portal_url').getPortalObject() quickinstaller = portal.portal_quickinstaller for dependency in config.DEPENDENCIES: if quickinstaller.isProductInstalled(dependency): log('Reinstalling dependency %s:' % dependency) quickinstaller.reinstallProducts([dependency]) transaction.savepoint() else: log('Installing dependency %s:' % dependency) quickinstaller.installProduct(dependency) transaction.savepoint()
def initialize(context): """ The 'initialize' function of this Product. It is called when Zope is restarted with these files in the Products directory. (I'm not sure what it does or if it is neccessary at all. Best leave it alone.) """ log('Start: "initialize()"') # Initialize portal tools tools = [ECQTool] ToolInit(PROJECTNAME + " Tools", tools=tools, icon="ec_tool.png").initialize(context) # Init contetn types content_types, constructors, ftis = process_types(listTypes(PROJECTNAME), PROJECTNAME) cmfutils.ContentInit( PROJECTNAME + " Content", content_types=content_types, permission=PERMISSION_ADD_MCTEST, extra_constructors=constructors, fti=ftis, ).initialize(context) log('Done: "ContentInit()"') # Add permissions to allow control on a per-class basis for i in range(0, len(content_types)): content_type = content_types[i].__name__ if ADD_CONTENT_PERMISSIONS.has_key(content_type): context.registerClass( meta_type=ftis[i]["meta_type"], constructors=(constructors[i],), permission=ADD_CONTENT_PERMISSIONS[content_type], ) # ~ parsers.initialize(context) # ~ renderers.initialize(context) log('Done: "initialize()"') # Mark end of Product initialization in log file. log("------------------------------------------------------------------")
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with ECQuiz; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ This file is needed in order to make Zope import this directory. All the following statements will be executed and finally the 'initialize' function will be called. """ from Products.ECQuiz.tools import log # mark start of Product initialization in log file # for details on 'log' see Products.ECQuiz.config log('------------------------------------------------------------------\n') import os, os.path from Products.Archetypes.public import process_types, listTypes from Products.CMFCore import utils from Products.CMFCore.DirectoryView import registerDirectory from Products.validation.validators.validator import RegexValidator from Products.ECQuiz.XMLValidator import XMLValidator # some global constants (in ALL_CAPS) and functions from Products.ECQuiz.config import * from Products.ECQuiz.tools import * from Products.ECQuiz.permissions import *
def install(self): """Installs the Product.""" out = StringIO() def descr(step): #return out.write("%s ... " % step) try: # install depending products descr('Installing Dependencies') install_dependencies(self, out) # out.write("QUESTION_TYPES = " + unicode(QUESTION_TYPES) + "\n") # out.write("ANSWER_TYPES = " + unicode(ANSWER_TYPES) + "\n") # Call Archetypes' install functions descr('Installing Types') installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME) # Make some settings for types, currently: # # - Hide types from the potal_navigation tree (controlled by # navigation_exclude = True in the class definition) # # - Enable the portal_factory (controlled by # use_portal_factory = True in the class definition) # navtree_props = self.portal_properties.navtree_properties unlisted = getattr(navtree_props, 'metaTypesNotToList', ()) factory_tool = getToolByName(self, 'portal_factory') factory_types = [] content_types, constructors, ftis = process_types( listTypes(PROJECTNAME), PROJECTNAME) for i in range(0, len(content_types)): meta_type = ftis[i]['meta_type'] exclude = getattr(content_types[i], 'navigation_exclude', False) use_portal_factory = getattr(content_types[i], 'use_portal_factory', False) if exclude: if meta_type not in unlisted: addLinesToProperty(navtree_props, 'metaTypesNotToList', meta_type) if use_portal_factory: factory_types.append(meta_type) factory_tool.manage_setPortalFactoryTypes(listOfTypeIds=factory_types) print >> out, "success." descr('Installing Skins') install_subskin(self, out, GLOBALS) print >> out, "success." # Install workflows descr('Installing Workflows') install_workflows(self, out) # Install the multiple choice tool descr('Installing Tool') from Products.ECQuiz.ECQTool \ import ECQTool as Tool if hasattr(self, Tool.id): self.manage_delObjects([Tool.id]) out.write('Deleting old %s; make sure you repeat ' 'customizations.\n' % Tool.id) addTool = self.manage_addProduct[PROJECTNAME].manage_addTool addTool(Tool.meta_type) # set title of tool: tool = getToolByName(self, Tool.id) tool.title = Tool.meta_type print >> out, "Added %s to the portal root folder." % tool.title out.write("\n") out.write("Successfully installed %s." % PROJECTNAME) except Exception, e: log("install() failed: " + str(e) + "\n") out.write("\n") out.write("Failed to install %s:\n\n %s" % (PROJECTNAME, str(e)))
# # You should have received a copy of the GNU General Public License # along with ECQuiz; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ This file is needed in order to make Zope import this directory. All the following statements will be executed and finally the 'initialize' function will be called. """ import logging from Products.ECQuiz.tools import log # mark start of Product initialization in log file # for details on 'log' see Products.ECQuiz.config log("------------------------------------------------------------------") import os.path from Products.Archetypes.public import process_types, listTypes from Products.CMFCore import utils as cmfutils from Products.CMFPlone.utils import ToolInit from Products.CMFCore.DirectoryView import registerDirectory from Products.ECQuiz.validators import * # some global constants (in ALL_CAPS) and functions from Products.ECQuiz import config from Products.ECQuiz.tools import * from Products.ECQuiz.permissions import * from Products.ECQuiz.ECQTool import ECQTool