Back to index

plone3  3.1.7
adding.py
Go to the documentation of this file.
00001 from warnings import warn
00002 
00003 from zope.interface import implements
00004 from zope.component import getMultiAdapter
00005 
00006 from zope.app.container.interfaces import INameChooser
00007 
00008 from Acquisition import aq_inner, aq_base, aq_parent
00009 from OFS.SimpleItem import SimpleItem
00010 from Products.Five import BrowserView
00011 
00012 from plone.app.portlets.browser.interfaces import IPortletAdding
00013 from plone.app.portlets.interfaces import IPortletPermissionChecker
00014 
00015 class PortletAdding(SimpleItem, BrowserView):
00016     implements(IPortletAdding)
00017 
00018     context = None
00019     request = None
00020 
00021     # This is necessary so that context.absolute_url() works properly on the 
00022     # add form, which in turn fixes the <base /> URL
00023     id = '+'
00024 
00025     def add(self, content):
00026         """Add the rule to the context
00027         """
00028         context = aq_inner(self.context)
00029         manager = aq_base(context)
00030         
00031         IPortletPermissionChecker(context)()
00032         
00033         chooser = INameChooser(manager)
00034         manager[chooser.chooseName(None, content)] = content
00035         
00036     def nextURL(self):
00037         referer = self.request.get('referer')
00038         if not referer:
00039             context = aq_parent(aq_inner(self.context))
00040             url = str(getMultiAdapter((context, self.request), name=u"absolute_url"))
00041             referer = url + '/@@manage-portlets'
00042         return referer
00043 
00044     def renderAddButton(self):
00045         warn("The renderAddButton method is deprecated, use nameAllowed",
00046             DeprecationWarning, 2)
00047 
00048     def namesAccepted(self):
00049         return False
00050 
00051     def nameAllowed(self):
00052         return False
00053 
00054     @property
00055     def contentName(self):
00056          return None
00057 
00058     def addingInfo():
00059         return None
00060 
00061     def isSingleMenuItem():
00062         return False
00063 
00064     def hasCustomAddView():
00065         return 0