import urlparse from Globals import InitializeClass, HTMLFile from OFS.SimpleItem import Item from OFS.PropertyManager import PropertyManager from Acquisition import Explicit, Implicit from Persistence import Persistent from AccessControl import ClassSecurityInfo from AccessControl import ModuleSecurityInfo modulesecurity = ModuleSecurityInfo() import roundup.instance from roundup.cgi import client modulesecurity.declareProtected('View management screens', 'manage_addZRoundupForm') manage_addZRoundupForm = HTMLFile('dtml/manage_addZRoundupForm', globals()) modulesecurity.declareProtected('Add Z Roundups', 'manage_addZRoundup') def manage_addZRoundup(self, id, instance_home, REQUEST): """Add a ZRoundup product """ # validate the instance_home roundup.instance.open(instance_home) self._setObject(id, ZRoundup(id, instance_home)) return self.manage_main(self, REQUEST) class RequestWrapper: '''Make the Zope RESPONSE look like a BaseHTTPServer
# FOR A PARTICULAR PURPOSE. # ############################################################################## """ CMFSetup product initialization. $Id$ """ from AccessControl import ModuleSecurityInfo from interfaces import BASE, EXTENSION from permissions import ManagePortal from registry import _profile_registry as profile_registry security = ModuleSecurityInfo( 'Products.CMFSetup' ) security.declareProtected( ManagePortal, 'profile_registry' ) def initialize( context ): from Products.CMFCore.utils import ToolInit, registerIcon from tool import SetupTool ToolInit( 'CMF Setup Tool' , tools=[ SetupTool ] , product_name='CMFSetup' , icon='www/tool.png' ).initialize( context ) from factory import addConfiguredSiteForm from factory import addConfiguredSite
# -*- coding: utf-8 -*- # Copyright (c) 2012-2013 Infrae. All rights reserved. # See also LICENSE.txt from AccessControl import ModuleSecurityInfo from silva.translations import translate as _ module_security = ModuleSecurityInfo('Products.Silva.roleinfo') BUILTIN_VIEWER_ROLES = ('Anonymous', 'Authenticated') SILVA_VIEWER_ROLES = ('Viewer', 'Viewer +', 'Viewer ++') VIEWER_ROLES = BUILTIN_VIEWER_ROLES + SILVA_VIEWER_ROLES module_security.declareProtected('View', 'CHIEF_ROLES') MANAGER_ROLES = ('Manager',) CHIEF_ROLES = ('ChiefEditor',) + MANAGER_ROLES EDITOR_ROLES = ('Editor',) + CHIEF_ROLES AUTHOR_ROLES = ('Author',) + EDITOR_ROLES #aaltepet: 1/12/06: we want to be able test reader_roles #from pythonscripts. e.g. to see if current user #can access smi module_security.declareProtected('Change Silva access', 'READER_ROLES') READER_ROLES = ('Reader',) + AUTHOR_ROLES module_security.declareProtected('View', 'ALL_ROLES') ALL_ROLES = VIEWER_ROLES + READER_ROLES _i18n_markers = ( _('zope roles'), _('silva roles'),
security.declarePrivate('isdir') security.declarePrivate('deprecate') security.declarePrivate('Globals') security.declarePrivate('ImageFile') security.declarePrivate('pts_globals') security.declarePrivate('CACHE_PATH') security.declarePrivate('get_registered_packages') security.declarePrivate('ModuleSecurityInfo') security.declarePrivate('PTSWrapper') security.declarePrivate('get_products') security.declarePrivate('patches') security.declarePrivate('warnings') security.declarePrivate('misc_') security.declarePrivate('os') security.declareProtected(view, 'getTranslationService') @deprecate("The getTranslationService method of PTS is deprecated and " "will be removed in the next major version of PTS.") def getTranslationService(): """returns the PTS instance """ return translation_service security.declarePrivate('make_translation_service') @deprecate("The make_translation_service method of PTS is deprecated and " "will be removed in the next major version of PTS.")
""" GenericSetup product initialization. $Id: __init__.py,v 1.1.1.1 2005/08/08 19:38:37 tseaver Exp $ """ from AccessControl import ModuleSecurityInfo from interfaces import BASE, EXTENSION from permissions import ManagePortal from registry import _profile_registry as profile_registry security = ModuleSecurityInfo('Products.GenericSetup') security.declareProtected(ManagePortal, 'profile_registry') def initialize(context): import tool context.registerClass( tool.SetupTool, constructors=( #tool.addSetupToolForm, tool.addSetupTool, ), permissions=(ManagePortal, ), interfaces=None, icon='www/tool.png', )
# -*- coding: utf-8 -*- # Copyright (c) 2012-2013 Infrae. All rights reserved. # See also LICENSE.txt from AccessControl import ModuleSecurityInfo from silva.translations import translate as _ module_security = ModuleSecurityInfo('Products.Silva.roleinfo') BUILTIN_VIEWER_ROLES = ('Anonymous', 'Authenticated') SILVA_VIEWER_ROLES = ('Viewer', 'Viewer +', 'Viewer ++') VIEWER_ROLES = BUILTIN_VIEWER_ROLES + SILVA_VIEWER_ROLES module_security.declareProtected('View', 'CHIEF_ROLES') MANAGER_ROLES = ('Manager', ) CHIEF_ROLES = ('ChiefEditor', ) + MANAGER_ROLES EDITOR_ROLES = ('Editor', ) + CHIEF_ROLES AUTHOR_ROLES = ('Author', ) + EDITOR_ROLES #aaltepet: 1/12/06: we want to be able test reader_roles #from pythonscripts. e.g. to see if current user #can access smi module_security.declareProtected('Change Silva access', 'READER_ROLES') READER_ROLES = ('Reader', ) + AUTHOR_ROLES module_security.declareProtected('View', 'ALL_ROLES') ALL_ROLES = VIEWER_ROLES + READER_ROLES _i18n_markers = ( _('zope roles'), _('silva roles'), _('public silva roles'), _('Anonymous'),
# Copyright (c) 2008-2013 Infrae. All rights reserved. # See also LICENSE.txt import logging from smtplib import SMTPException # Zope from AccessControl import ModuleSecurityInfo from Products.MailHost.MailHost import _mungeHeaders from Products.Silva import MAILHOST_ID logger = logging.getLogger('silva.email') module_security = ModuleSecurityInfo('Products.Silva.helpers') module_security.declareProtected('Use mailhost services', 'sendmail') def sendmail(context, message, mto=None, mfrom=None, subject=None): """Send a fraking mail, should work with regular Zope Mailhost, and MaildropHost. """ mh = getattr(context.get_root(), MAILHOST_ID) messageText, mto, mfrom = _mungeHeaders(message, mto, mfrom, subject, charset='utf-8') try: mh._send(mfrom, mto, messageText)
return RESPONSE RESPONSE.setStatus(204) self.reindexObject() return RESPONSE _htmlsrc = ( '<html>\n <head>\n' ' <title>%(title)s</title>\n' '%(metatags)s\n' ' </head>\n' ' <body>\n%(body)s\n </body>\n' '</html>\n' ) security.declareProtected(Permissions.View, 'getMetadataHeaderList') def getMetadataHeaderList(self): hdrlist = [] for p in self.getPropertyMap(): pid = p.get('base_id', p['id']) if pid not in ('text_content', 'data', 'base_data'): hdrlist.append((pid, self.getProperty(p['id']))) return hdrlist security.declareProtected(Permissions.View, 'manage_FTPget') def manage_FTPget(self): "Get the document body for FTP download (also used for the WebDAV SRC)" hdrlist = self.getMetadataHeaderList() if self.getFormat() == 'text/html': hdrtext = '' for name, content in hdrlist:
import urlparse from Globals import InitializeClass, HTMLFile from OFS.SimpleItem import Item from OFS.PropertyManager import PropertyManager from Acquisition import Explicit, Implicit from Persistence import Persistent from AccessControl import ClassSecurityInfo from AccessControl import ModuleSecurityInfo modulesecurity = ModuleSecurityInfo() import roundup.instance from roundup.cgi import client modulesecurity.declareProtected("View management screens", "manage_addZRoundupForm") manage_addZRoundupForm = HTMLFile("dtml/manage_addZRoundupForm", globals()) modulesecurity.declareProtected("Add Z Roundups", "manage_addZRoundup") def manage_addZRoundup(self, id, instance_home, REQUEST): """Add a ZRoundup product """ # validate the instance_home roundup.instance.open(instance_home) self._setObject(id, ZRoundup(id, instance_home)) return self.manage_main(self, REQUEST) class RequestWrapper: """Make the Zope RESPONSE look like a BaseHTTPServer
transaction.abort() RESPONSE.setStatus(423) return RESPONSE RESPONSE.setStatus(204) self.reindexObject() return RESPONSE _htmlsrc = ('<html>\n <head>\n' ' <title>%(title)s</title>\n' '%(metatags)s\n' ' </head>\n' ' <body>\n%(body)s\n </body>\n' '</html>\n') security.declareProtected(Permissions.View, 'getMetadataHeaderList') def getMetadataHeaderList(self): hdrlist = [] for p in self.getPropertyMap(): pid = p.get('base_id', p['id']) if pid not in ('text_content', 'data', 'base_data'): hdrlist.append((pid, self.getProperty(p['id']))) return hdrlist security.declareProtected(Permissions.View, 'manage_FTPget') def manage_FTPget(self): "Get the document body for FTP download (also used for the WebDAV SRC)" hdrlist = self.getMetadataHeaderList() if self.getFormat() == 'text/html':
# module level translation service translation_service = None # icon misc_ = { 'PlacelessTranslationService.png': ImageFile('www/PlacelessTranslationService.png', globals()), 'GettextMessageCatalog.png': ImageFile('www/GettextMessageCatalog.png', globals()), } # set product-wide attrs for importing security = ModuleSecurityInfo('Products.PlacelessTranslationService') allow_module('Products.PlacelessTranslationService') security.declareProtected(view, 'getTranslationService') @deprecate("The getTranslationService method of PTS is deprecated and " "will be removed in the next major version of PTS.") def getTranslationService(): """returns the PTS instance """ return translation_service @deprecate("The make_translation_service method of PTS is deprecated and " "will be removed in the next major version of PTS.") def make_translation_service(cp): """Control_Panel translation service """ global translation_service translation_service = PlacelessTranslationService('default') translation_service.id = cp_id
# -*- coding: utf-8 -*- # Copyright (c) 2008-2013 Infrae. All rights reserved. # See also LICENSE.txt import logging from smtplib import SMTPException # Zope from AccessControl import ModuleSecurityInfo from Products.MailHost.MailHost import _mungeHeaders from Products.Silva import MAILHOST_ID logger = logging.getLogger('silva.email') module_security = ModuleSecurityInfo('Products.Silva.helpers') module_security.declareProtected('Use mailhost services', 'sendmail') def sendmail(context, message, mto=None, mfrom=None, subject=None): """Send a fraking mail, should work with regular Zope Mailhost, and MaildropHost. """ mh = getattr(context.get_root(), MAILHOST_ID) messageText, mto, mfrom = _mungeHeaders( message, mto, mfrom, subject, charset='utf-8') try: mh._send(mfrom, mto, messageText) except SMTPException as error: logger.error('Error sending email from %s to %s: %s' % ( mfrom, mto, str(error)))
# -*- coding: utf-8 -*- # Copyright (c) 2002-2013 Infrae. All rights reserved. # See also LICENSE.txt # Zope from AccessControl import ModuleSecurityInfo # Zope3 from zope import component from zope.publisher.interfaces.browser import IBrowserSkinType from silva.core.layout.interfaces import ISilvaSkin # Helpers to integrate Zope3, Five and SilvaLayout functionality # with Zope2 and Silva __allow_access_to_unprotected_subobjects__ = 1 module_security = ModuleSecurityInfo('silva.core.layout.helpers') module_security.declareProtected( 'Access Contents Information', 'getAvailableSkins') def getAvailableSkins(): skins = component.getUtilitiesFor(IBrowserSkinType) return [name for name, skin in skins if skin.extends(ISilvaSkin)]
format = self.checkFormat(source, format, file_name) parser = self.getParser(format) if parser: try: return parser.getEntries(source) except Exception, e: LOG.error('Import error while importing file (%s)' % e, exc_info=True) raise RuntimeError( 'An error occured (%s) - please check the log file for details' % e) else: return "No parser for '%s' available." % format security.declareProtected(View, 'getParser') def getParser(self, format, with_unavailables=False, with_disabled=False, **kw): """ returns the parser for the specified format first looks for a parser with the 'format' name next looks for a parser with the 'format' extension """ parsers = component.getAllUtilitiesRegisteredFor(IBibliographyParser) for parser in parsers: if (parser.isAvailable() or with_unavailables) and (parser.isEnabled()
''' import docutils.core, docutils.io from Globals import InitializeClass, DTMLFile from OFS.SimpleItem import Item from OFS.PropertyManager import PropertyManager from OFS.History import Historical, html_diff from Acquisition import Implicit from Persistence import Persistent from AccessControl import ClassSecurityInfo from AccessControl import ModuleSecurityInfo from DateTime.DateTime import DateTime modulesecurity = ModuleSecurityInfo() modulesecurity.declareProtected('View management screens', 'manage_addZReSTForm') manage_addZReSTForm = DTMLFile('dtml/manage_addZReSTForm', globals()) modulesecurity.declareProtected('Add Z Roundups', 'manage_addZReST') def manage_addZReST(self, id, file='', REQUEST=None): """Add a ZReST product """ # validate the instance_home self._setObject(id, ZReST(id)) self._getOb(id).manage_upload(file) if REQUEST: return self.manage_main(self, REQUEST) class Warnings: def __init__(self): self.messages = [] def write(self, message):
""" source = self.checkEncoding(source, input_encoding) format = self.checkFormat(source, format, file_name) parser = self.getParser(format) if parser: try: return parser.getEntries(source) except Exception, e: LOG.error('Import error while importing file (%s)' % e, exc_info=True) raise RuntimeError('An error occured (%s) - please check the log file for details' % e) else: return "No parser for '%s' available." % format security.declareProtected(View, 'getParser') def getParser(self, format, with_unavailables=False, with_disabled=False, **kw): """ returns the parser for the specified format first looks for a parser with the 'format' name next looks for a parser with the 'format' extension """ parsers = component.getAllUtilitiesRegisteredFor(IBibliographyParser) for parser in parsers: if (parser.isAvailable() or with_unavailables) and (parser.isEnabled() or with_disabled): if format.lower() == parser.getFormatName().lower(): return parser elif format.lower() == parser.getFormatExtension().lower(): return parser return None ## rr: we probabliy should raise an error here
# module level translation service translation_service = None # icon misc_ = { 'PlacelessTranslationService.png': Globals.ImageFile('www/PlacelessTranslationService.png', globals()), 'GettextMessageCatalog.png': Globals.ImageFile('www/GettextMessageCatalog.png', globals()), } # set product-wide attrs for importing security = ModuleSecurityInfo('Products.PlacelessTranslationService') allow_module('Products.PlacelessTranslationService') security.declareProtected(view, 'getTranslationService') def getTranslationService(): """returns the PTS instance """ return translation_service security.declareProtected(view, 'translate') @deprecate("The translate method of the PTS package is deprecated and will be " "removed in the next PTS release. Use the translate method of the " "global translation service instead.") def translate(*args, **kwargs): """see PlaceslessTranslationService.PlaceslessTranslationService """ return getTranslationService().translate(*args, **kwargs) security.declareProtected(view, 'utranslate')
# -*- coding: utf-8 -*- # Copyright (c) 2008-2013 Infrae. All rights reserved. # See also LICENSE.txt from zope.component import getMultiAdapter from AccessControl import ModuleSecurityInfo, allow_module from Products.Formulator.FieldRegistry import FieldRegistry from silva.captcha import formulator from silva.captcha.field import Captcha FieldRegistry.registerField(formulator.CaptchaField) # XXX fix icon allow_module('silva.captcha') module_security = ModuleSecurityInfo('silva.captcha') module_security.declareProtected('View', 'validate') def validate(context, request, input): """Validate a potential captcha entry for a Python Script. """ captcha = getMultiAdapter((context, request), name='captcha') return captcha.verify(input)