Back to index

plone3  3.1.7
setuphandlers.py
Go to the documentation of this file.
00001 from StringIO import StringIO
00002 
00003 from zope.component import getUtility
00004 from zope.component import getMultiAdapter
00005 
00006 from plone.portlets.interfaces import IPortletAssignmentMapping
00007 from plone.portlets.interfaces import IPortletManager
00008 from plone.app.portlets import portlets
00009 
00010 
00011 def addSearchPortlet(portal, out):
00012     leftColumn = getUtility(IPortletManager, name=u'plone.leftcolumn', context=portal)
00013     left = getMultiAdapter((portal, leftColumn,), IPortletAssignmentMapping, context=portal)
00014     if u'portlets.Search' not in left:
00015         print >> out, "Adding search portlet to the left column"
00016         left[u'portlets.Search'] = portlets.search.Assignment()
00017         order = [left.keys()[-1]]+left.keys()[:-1]
00018         left.updateOrder(list(order))
00019 
00020 def addLanguagePortlet(portal, out):
00021     leftColumn = getUtility(IPortletManager, name=u'plone.leftcolumn', context=portal)
00022     left = getMultiAdapter((portal, leftColumn,), IPortletAssignmentMapping, context=portal)
00023     if u'portlets.Language' not in left:
00024         print >> out, "Adding language portlet to the left column"
00025         left[u'portlets.Language'] = portlets.language.Assignment()
00026         order = [left.keys()[-1]]+left.keys()[:-1]
00027         left.updateOrder(list(order))
00028 
00029 
00030 def importVarious(context):
00031     
00032     if context.readDataFile('nuplone_various.txt') is None:
00033         return
00034     
00035     site = context.getSite()
00036     out = StringIO()
00037 
00038     addSearchPortlet(site, out)
00039     addLanguagePortlet(site, out)