def test_interfaces(self): # TODO: Pass any keyword arguments to the Assignment constructor portlet1 = hot_threads.Assignment(5, 'testforum') portlet2 = popular_threads.Assignment(5, 'interval', 'testforum',) self.failUnless(IPortletAssignment.providedBy(portlet1)) self.failUnless(IPortletAssignment.providedBy(portlet2)) self.failUnless(IPortletDataProvider.providedBy(portlet1.data)) self.failUnless(IPortletDataProvider.providedBy(portlet2.data))
def _check(self): registered = self._registered_objects() if len(registered) > 0 and \ not IDisableCSRFProtection.providedBy(self.request): # Okay, we're writing here, we need to protect! try: check(self.request) return True except ComponentLookupError: # okay, it's possible we're at the zope root and the KeyManager # hasn't been installed yet. Let's check and carry on # if this is the case if IApplication.providedBy(self.getContext()): LOGGER.info('skipping csrf protection on zope root until ' 'keymanager gets installed') return True raise except Forbidden: if self.request.REQUEST_METHOD != 'GET': # only try to be "smart" with GET requests raise # XXX # okay, so right now, we're going to check if the current # registered objects to write, are just portlet assignments. # I don't know why, but when a site is created, these # cause some writes on read. ALL, registered objects # need to be portlet assignments. XXX needs to be fixed # somehow... safe = True for obj in registered: if (not IPortletAssignment.providedBy(obj) and not getattr(obj, '_v_safe_write', False)): safe = False break if not safe: LOGGER.info('aborting transaction due to no CSRF ' 'protection on url %s' % self.request.URL) transaction.abort() # conditions for doing the confirm form are: # 1. 301, 302 response code # 2. text/html response # 3. getSite could be none, zope root maybe, carry on # otherwise, # just abort with a log entry because we tried to # write on read, without a POST request and we don't # know what to do with it gracefully. resp = self.request.response ct = resp.headers.get('content-type') if self.site and ( resp.status in (301, 302) or 'text/html' in ct): data = self.request.form.copy() data['original_url'] = self.request.URL resp.redirect('%s/@@confirm-action?%s' % ( self.site.absolute_url(), urlencode(data) )) return False return True
def test_interfaces(self): portlet = actions.Assignment(ptitle=u'actions', category=u'document', show_icons=True) self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data)) return
def test_interfaces(self): # TODO: Pass any keyword arguments to the Assignment constructor portlet = fblikebox.Assignment(api_key=u"test", page_url=u"http://facebook.com/test") self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def _check(self): registered = self._registered_objects() if len(registered) > 0 and \ not IDisableCSRFProtection.providedBy(self.request): # Okay, we're writing here, we need to protect! try: check(self.request) return True except ComponentLookupError: # okay, it's possible we're at the zope root and the KeyManager # hasn't been installed yet. Let's check and carry on # if this is the case if IApplication.providedBy(self.getContext()): LOGGER.info('skipping csrf protection on zope root until ' 'keymanager gets installed') return True raise except Forbidden: if self.request.REQUEST_METHOD != 'GET': # only try to be "smart" with GET requests raise # XXX # okay, so right now, we're going to check if the current # registered objects to write, are just portlet assignments. # I don't know why, but when a site is created, these # cause some writes on read. ALL, registered objects # need to be portlet assignments. XXX needs to be fixed # somehow... safe = True for obj in registered: if (not IPortletAssignment.providedBy(obj) and not getattr(obj, '_v_safe_write', False)): safe = False break if not safe: LOGGER.info('aborting transaction due to no CSRF ' 'protection on url %s' % self.request.URL) transaction.abort() # conditions for doing the confirm form are: # 1. 301, 302 response code # 2. text/html response # 3. getSite could be none, zope root maybe, carry on # otherwise, # just abort with a log entry because we tried to # write on read, without a POST request and we don't # know what to do with it gracefully. resp = self.request.response ct = resp.headers.get('content-type') if self.site and (resp.status in (301, 302) or 'text/html' in ct): data = self.request.form.copy() data['original_url'] = self.request.URL resp.redirect( '%s/@@confirm-action?%s' % (self.site.absolute_url(), urlencode(data))) return False return True
def test_interfaces(self): # TODO: Pass any keyword arguments to the Assignment constructor portlet = fbwall.Assignment(fb_account = u"test", wall_id = u"Test", max_results = 20) self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def _check(self): registered = self._registered_objects() if len(registered) > 0 and \ not IDisableCSRFProtection.providedBy(self.request): # Okay, we're writing here, we need to protect! try: check(self.request, manager=self.key_manager) return True except ComponentLookupError: LOGGER.info('Can not find key manager for CSRF protection. ' 'This should not happen.') raise except Forbidden: # XXX # okay, so right now, we're going to check if the current # registered objects to write, are just portlet assignments. # I don't know why, but when a site is created, these # cause some writes on read. ALL, registered objects # need to be portlet assignments. XXX needs to be fixed # somehow... safe_oids = [] if SAFE_WRITE_KEY in getattr(self.request, 'environ', {}): safe_oids = self.request.environ[SAFE_WRITE_KEY] safe = True for obj in registered: if (not IPortletAssignment.providedBy(obj) and getattr(obj, '_p_oid', False) not in safe_oids): safe = False break if not safe: if self.request.REQUEST_METHOD != 'GET': # only try to be "smart" with GET requests raise LOGGER.info('%s\naborting transaction due to no CSRF ' 'protection on url %s'%(traceback.print_stack(), self.request.URL)) transaction.abort() # conditions for doing the confirm form are: # 1. 301, 302 response code # 2. text/html response # 3. getSite could be none, zope root maybe, carry on # otherwise, # just abort with a log entry because we tried to # write on read, without a POST request and we don't # know what to do with it gracefully. resp = self.request.response ct = resp.getHeader('Content-Type', '') or '' if self.site and ( resp.status in (301, 302) or 'text/html' in ct): data = self.request.form.copy() data['original_url'] = self.request.URL resp.redirect('%s/@@confirm-action?%s' % ( self.site.absolute_url(), urlencode(data) )) return False return True
def test_interfaces(self): # TODO: Pass any keyword arguments to the Assignment constructor portlet = twsearch.Assignment(tw_account = u"test", search_string = u"Test", show_avatars = False, max_results = 20) self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): # TODO: Pass any keyword arguments to the Assignment constructor portlet = twprofile.Assignment(tw_account=u"test", tw_user=u"Test", show_avatars=False, max_results=20) self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def _check(self): registered = self._registered_objects() if len(registered) > 0 and \ not IDisableCSRFProtection.providedBy(self.request): # Okay, we're writing here, we need to protect! try: check(self.request, manager=self.key_manager) return True except ComponentLookupError: LOGGER.info('Can not find key manager for CSRF protection. ' 'This should not happen.') raise except Forbidden: # XXX # okay, so right now, we're going to check if the current # registered objects to write, are just portlet assignments. # I don't know why, but when a site is created, these # cause some writes on read. ALL, registered objects # need to be portlet assignments. XXX needs to be fixed # somehow... safe_oids = [] if SAFE_WRITE_KEY in getattr(self.request, 'environ', {}): safe_oids = self.request.environ[SAFE_WRITE_KEY] safe = True for obj in registered: if (not IPortletAssignment.providedBy(obj) and getattr( obj, '_p_oid', False) not in safe_oids): safe = False break if not safe: if self.request.REQUEST_METHOD != 'GET': # only try to be "smart" with GET requests raise LOGGER.info('aborting transaction due to no CSRF ' 'protection on url %s' % self.request.URL) transaction.abort() # conditions for doing the confirm form are: # 1. 301, 302 response code # 2. text/html response # 3. getSite could be none, zope root maybe, carry on # otherwise, # just abort with a log entry because we tried to # write on read, without a POST request and we don't # know what to do with it gracefully. resp = self.request.response ct = resp.getHeader('Content-Type', '') or '' if self.site and (resp.status in (301, 302) or 'text/html' in ct): data = self.request.form.copy() data['original_url'] = self.request.URL resp.redirect( '%s/@@confirm-action?%s' % (self.site.absolute_url(), urlencode(data))) return False return True
def test_interfaces(self): portlet = flattrportlet.Assignment(button_type=u'Static', thing_url=u'http://example.com/thing1', text=u'Hello World') self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data)) self.assertEquals(portlet.button_type, u'Static') self.assertEquals(portlet.thing_url, u'http://example.com/thing1') self.assertEquals(portlet.text, u'Hello World')
def cke_config_url(self, context=None): """" return the dynamic configuration file url """ def findContentish(context): # find context by walking up acquisition chain while True: context = aq_parent(context) if IContentish.providedBy(context): break elif IFolderish.providedBy(context): break return context # when used by plone.app.form.widgets.wysiwygwidget # to add or edit a portlet if IPortletAssignment.providedBy(context): context = findContentish(context) elif IPortletAdding.providedBy(context): context = findContentish(context) else: context = aq_inner(self.context) return '%s/ckeditor_plone_config.js' % context.absolute_url()
def test_interfaces(self): # TODO: Pass any keyword arguments to the Assignment constructor portlet = mybookmarksportlet.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): # TODO: Pass any keywoard arguments to the Assignment constructor portlet = addoriginalfile.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): latest_sectionable = latest_sectionable_nitf.Assignment() self.assertTrue(IPortletAssignment.providedBy(latest_sectionable)) self.assertTrue(IPortletDataProvider.providedBy(latest_sectionable.data))
def test_interfaces(self): portlet = localcontents.Assignment(**{'name':'In this section...', 'display_when_not_default_page': False}) self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = mailinglijst.Assignment(name="foo") self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): last = buscaleg.Assignment() self.assertTrue(IPortletAssignment.providedBy(last)) self.assertTrue(IPortletDataProvider.providedBy(last.data))
def testInterfaces(self): portlet = author.Assignment(count=5) self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): for module in [p['module'] for p in self.portlets]: portlet = module.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): portlet = voteportlet.Assignment(header='Polls', poll='latest') self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def __init__(self, context, request): super(DisplayPanelView, self).__init__(context, request) # todo: move away from init # The parent object is the Plone content object here; we get # it from the acquisition chain. # The panel can be rendered in different contexts, where the length of # the chain to the Plone content object is not obvious; # on portlet edit forms for instance, where we have a panel of # portlets below the edit form. # So to get the content object we go up in the aq chain, until we are # out of the chain of portlet assignments, panels etc. parent = self.context.aq_inner while True: parent = parent.aq_parent if not (IPanel.providedBy(parent) or IPortletAssignment.providedBy(parent) or IPortletAssignmentMapping.providedBy(parent)): break panel = self.context portlets = [] for assignment in panel: settings = IPortletAssignmentSettings(assignment) if not settings.get('visible', True): continue try: portlet = getMultiAdapter((parent, self.request, self, panel, assignment.__of__(panel)), IPortletRenderer) except ComponentLookupError: logging.getLogger("panels").info( "unable to look up renderer for '%s.%s'." % (assignment.__class__.__module__, assignment.__class__.__name__)) continue info = { 'manager': "panels", 'category': CONTEXT_CATEGORY, 'key': str('/'.join(parent.getPhysicalPath())), 'name': assignment.__name__, 'renderer': portlet, 'settings': settings, 'assignment': assignment } # todo: check new impl. of portlet rendering hashPortletInfo(info) portlet.__portlet_metadata__ = info.copy() del portlet.__portlet_metadata__['renderer'] portlet.update() try: available = portlet.available except ConflictError: raise except Exception as err: logging.getLogger('panels').info( "available threw an exception for %s (%s %s)" % (assignment.__name__, type(err), str(err))) continue info['available'] = available portlets.append(info) self.portlets = portlets
def test_interfaces(self): # TODO: Pass any keywoard arguments to the Assignment constructor portlet = librarianworkplans.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = mailchimp.Assignment(name="foo") self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = static.Assignment(header=u"title", text="text") self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = currency_converter.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = existing_content_portlet.Assignment() self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = carousel.Assignment(header=u"title") self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): portlet = audiogallery.Assignment() self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): # TODO: Pass any keyword arguments to the Assignment constructor portlet = rerportletadvancedstatic.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = news.Assignment(count=5) self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = collection.Assignment(header=u"title") self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): # TODO: Pass any keyword arguments to the Assignment constructor for p in (LineageEventsPortlet, LineageNewsPortlet): portlet = p.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): portlet = practical_solutions.Assignment(["agriculture"]) self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_portlet_interfaces(self): portlet = speeches_portlet.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = portlet_mod.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): portlet = personleadimagecollectionportlet.Assignment(header=u"title") self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): portlet = weather.Assignment() self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = news.Assignment(count=5) self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): portlet = contentleadimagecollectionportlet.Assignment(header=u"title") self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): sb_portlet = portlet.Assignment() self.assertTrue(IPortletAssignment.providedBy(sb_portlet)) self.assertTrue(IPortletDataProvider.providedBy(sb_portlet.data))
def test_interfaces(self): # TODO: Pass any keywoard arguments to the Assignment constructor portlet = customizabletagcloudportlet.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = classic.Assignment(template='portlet_recent', macro='portlet') self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = portlet_events.Assignment() self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = review.Assignment() self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): # TODO: Pass any keyword arguments to the Assignment constructor portlet = groupcollection.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): portlet = actions.Assignment(ptitle=u'actions', category=u'document', show_icons=True) self.assertTrue(IPortletAssignment.providedBy(portlet)) self.assertTrue(IPortletDataProvider.providedBy(portlet.data)) return
def test_interfaces(self): last_sectionable = latest_sectionable_nitf.Assignment() self.assertTrue(IPortletAssignment.providedBy(last_sectionable)) self.assertTrue(IPortletDataProvider.providedBy(last_sectionable.data))
def testInterfaces(self): portlet = portlet_events.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def testInterfaces(self): portlet = quicklinks.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet))
def testInterfaces(self): portlet = sliderportlet.Assignment(over=u"blah", under=u"blah") self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))
def test_interfaces(self): # TODO: Pass any keywoard arguments to the Assignment constructor portlet = producentregisteringhelp.Assignment() self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))