示例#1
0
from AccessControl import ModuleSecurityInfo
from zope.i18nmessageid import MessageFactory

_ = MessageFactory('pretaweb.plomino2pdf')


def initialize(context):
    """Initializer called when used as a Zope 2 product."""


ModuleSecurityInfo('pretaweb.plomino2pdf.api').declarePublic('generate_pdf')
示例#2
0
    from types import ClassType
except ImportError:
    ClassType = type

if bbb.HAS_ZSERVER:
    from webdav.interfaces import IWriteLock
else:
    from OFS.interfaces import IWriteLock

deprecated_import(
    "Import from Products.CMFPlone.defaultpage instead",
    isDefaultPage='Products.CMFPlone.defaultpage:check_default_page_via_view',
    getDefaultPage='Products.CMFPlone.defaultpage:get_default_page_via_view',
)

security = ModuleSecurityInfo()
security.declarePrivate('deprecated')
security.declarePrivate('abspath')
security.declarePrivate('re')
security.declarePrivate('OFS')
security.declarePrivate('aq_get')
security.declarePrivate('package_home')
security.declarePrivate('ImageFile')
security.declarePrivate('CMFCoreToolInit')
security.declarePrivate('transaction')
security.declarePrivate('zope')

# Canonical way to get at CMFPlone directory
PACKAGE_HOME = package_home(globals())
security.declarePrivate('PACKAGE_HOME')
WWW_DIR = join(PACKAGE_HOME, 'www')
示例#3
0
from AccessControl.Role import gather_permissions

from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import SimpleItem
from OFS.PropertySheets import PropertySheets
from OFS.misc_ import misc_ as misc_images
from OFS.misc_ import Misc_ as MiscImage
try:
    from OFS.ObjectManager import UNIQUE
except ImportError:
    UNIQUE = 2
from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter


security = ModuleSecurityInfo( 'Products.CMFCore.utils' )

_dtmldir = os_path.join( package_home( globals() ), 'dtml' )

#
#   Simple utility functions, callable from restricted code.
#
_marker = []  # Create a new marker object.

security.declarePublic('getToolByName')
def getToolByName(obj, name, default=_marker):

    """ Get the tool, 'toolname', by acquiring it.

    o Application code should use this method, rather than simply
      acquiring the tool by name, to ease forward migration (e.g.,
示例#4
0
def initialize(context):

    # Stuff has been moved from module level to this method for a
    # better separation of import and installation.
    # For the general user this change does not make a difference.
    # For test authors (and people who use parts of Plone only)
    # it does speed up import *significantly*.

    from AccessControl import ModuleSecurityInfo
    from AccessControl import allow_class
    from AccessControl import allow_module
    from AccessControl import allow_type

    # protect OFS.ObjectManager
    ModuleSecurityInfo('OFS.ObjectManager').setDefaultAccess(0)
    ModuleSecurityInfo('OFS.ObjectManager').declareObjectPrivate()
    ModuleSecurityInfo('OFS.ObjectManager').declarePublic(
        'BeforeDeleteException')

    # allow logging
    ModuleSecurityInfo('logging').declarePublic('getLogger')
    from logging import Logger
    allow_class(Logger)

    # various small utils functions
    # added for unescaping view names in urls when finding selected action
    ModuleSecurityInfo('urllib').declarePublic('unquote')

    allow_module('Products.CMFPlone.utils')

    # For content_status_modify
    from Products.CMFCore.WorkflowCore import ObjectDeleted
    from Products.CMFCore.WorkflowCore import ObjectMoved
    from Products.CMFCore.WorkflowCore import WorkflowException
    ModuleSecurityInfo(
        'Products.CMFCore.WorkflowCore').declarePublic('ObjectDeleted')
    ModuleSecurityInfo(
        'Products.CMFCore.WorkflowCore').declarePublic('ObjectMoved')
    ModuleSecurityInfo(
        'Products.CMFCore.WorkflowCore').declarePublic('WorkflowException')
    allow_class(ObjectDeleted)
    allow_class(ObjectMoved)
    allow_class(WorkflowException)

    from Products.CMFPlone.PloneBatch import Batch
    allow_class(Batch)

    # Make Batch available at module level
    this_module.Batch = Batch

    ModuleSecurityInfo('StringIO').declarePublic('StringIO')
    from six import StringIO
    allow_class(StringIO)

    # Make Unauthorized importable TTW
    ModuleSecurityInfo('AccessControl').declarePublic('Unauthorized')

    # Make Forbidden importable TTW
    ModuleSecurityInfo('zExceptions').declarePublic('Forbidden')

    # Make ConflictError importable TTW
    ModuleSecurityInfo('ZODB.POSException').declarePublic('ConflictError')

    # Make ZCTextIndex ParseError importable TTW
    ModuleSecurityInfo('Products.ZCTextIndex.ParseTree') \
        .declarePublic('ParseError')

    # Make DateTimeError importable TTW
    ModuleSecurityInfo('DateTime.interfaces').declarePublic('DateTimeError')
    ModuleSecurityInfo('DateTime.interfaces').declarePublic('SyntaxError')

    # BBB support for DateTime < 3
    ModuleSecurityInfo('DateTime.DateTime').declarePublic('DateTimeError')
    ModuleSecurityInfo('DateTime.DateTime').declarePublic('SyntaxError')

    # Make CopyError importable TTW
    ModuleSecurityInfo('OFS.CopySupport').declarePublic('CopyError')

    # Make AllowSendto importable TTW
    ModuleSecurityInfo('Products.CMFPlone.PloneTool') \
        .declarePublic('AllowSendto')

    # Make ZCatalog's mergeResults importable TTW
    ModuleSecurityInfo('Products.ZCatalog.Catalog') \
        .declarePublic('mergeResults')

    # Make the navtree constructs available TTW
    allow_module('Products.CMFPlone.browser.navtree')

    # Allow access to the exception in the folder_delete script
    from OFS.ObjectManager import BeforeDeleteException
    allow_module('OFS.ObjectManager')
    allow_class(BeforeDeleteException)

    # Make cgi.escape available TTW
    ModuleSecurityInfo('cgi').declarePublic('escape')

    # We want to allow all methods on string type except 'format'.
    # That one needs special handling to avoid access to attributes.
    from Products.CMFPlone.utils import _safe_format
    rules = dict([(m, True) for m in dir(str) if not m.startswith('_')])
    rules['format'] = _safe_format
    allow_type(str, rules)

    # Same for unicode instead of str.
    rules = dict([(m, True) for m in dir(unicode) if not m.startswith('_')])
    rules['format'] = _safe_format
    allow_type(unicode, rules)

    # Apply monkey patches
    from Products.CMFPlone import patches  # noqa

    # Register unicode splitter w/ ZCTextIndex
    # pipeline registry
    from Products.CMFPlone import UnicodeSplitter  # noqa

    # Plone content

    # Usage of PloneFolder is discouraged.
    from Products.CMFPlone import PloneFolder

    contentClasses = (PloneFolder.PloneFolder, )
    contentConstructors = (PloneFolder.addPloneFolder, )

    # CMFCore tools
    from Products.CMFCore import CachingPolicyManager

    # Plone tools
    from Products.CMFPlone import PloneTool
    from Products.CMFPlone import MigrationTool
    from Products.CMFPlone import PloneControlPanel
    from Products.CMFPlone import WorkflowTool
    from Products.CMFPlone import URLTool
    from Products.CMFPlone import RegistrationTool
    from Products.CMFPlone import PropertiesTool
    from Products.CMFPlone import ActionsTool
    from Products.CMFPlone import TypesTool
    from Products.CMFPlone import CatalogTool
    from Products.CMFPlone import SkinsTool
    from Products.CMFPlone import QuickInstallerTool
    from Products.CMFPlone import TranslationServiceTool

    tools = (
        PloneTool.PloneTool,
        WorkflowTool.WorkflowTool,
        CachingPolicyManager.CachingPolicyManager,
        PropertiesTool.PropertiesTool,
        MigrationTool.MigrationTool,
        PloneControlPanel.PloneControlPanel,
        RegistrationTool.RegistrationTool,
        URLTool.URLTool,
        ActionsTool.ActionsTool,
        TypesTool.TypesTool,
        CatalogTool.CatalogTool,
        SkinsTool.SkinsTool,
        QuickInstallerTool.QuickInstallerTool,
        TranslationServiceTool.TranslationServiceTool,
    )

    from Products.CMFCore.utils import ContentInit
    from Products.CMFPlone.utils import ToolInit

    # Register tools and content
    ToolInit(
        'Plone Tool',
        tools=tools,
        icon='tool.gif',
    ).initialize(context)

    ContentInit(
        'Plone Content',
        content_types=contentClasses,
        permission=ADD_CONTENT_PERMISSION,
        extra_constructors=contentConstructors,
    ).initialize(context)

    from AccessControl.Permissions import view_management_screens
    from Products.CMFPlone.Portal import PloneSite
    from Products.CMFPlone.factory import zmi_constructor
    context.registerClass(
        instance_class=PloneSite,
        permission=view_management_screens,
        constructors=(zmi_constructor, ),
    )

    from plone.app.folder import nogopip
    context.registerClass(
        nogopip.GopipIndex,
        permission='Add Pluggable Index',
        constructors=(nogopip.manage_addGopipForm,
                      nogopip.manage_addGopipIndex),
        icon='index.gif',
        visibility=None
    )
示例#5
0
 def allow_module(module_name):
     ModuleSecurityInfo(module_name).setDefaultAccess(1)
     dot = module_name.find('.')
     while dot > 0:
         ModuleSecurityInfo(module_name[:dot]).setDefaultAccess(1)
         dot = module_name.find('.', dot + 1)
示例#6
0
from Products.CMFCore.utils import ContentInit
from Products.ATContentTypes.config import HAS_LINGUA_PLONE
if HAS_LINGUA_PLONE:
    from Products.LinguaPlone.public import process_types
    from Products.LinguaPlone.public import listTypes
else:
    from Products.Archetypes.public import process_types
    from Products.Archetypes.public import listTypes

from config import PROJECTNAME, GLOBALS, I18N_DOMAIN
from permissions import DEFAULT_ADD_CONTENT_PERMISSION
from permissions import ADD_CONTENT_PERMISSIONS

# Import "MarsMessageFactory as _" to create messages in atcontenttypes domain
MarsMessageFactory = MessageFactory(I18N_DOMAIN)
ModuleSecurityInfo(PROJECTNAME).declarePublic('MarsMessageFactory')

import analysis
import artefact
import collection
import curation
import excavation
#import externalfile
import fauna
import flora
import hominid
import institution
#import multimedia
import people
import picture
import site
示例#7
0
from AccessControl import ModuleSecurityInfo
from Products.CMFCore.permissions import setDefaultRoles

security = ModuleSecurityInfo('pcommerce.core.config')

security.declarePublic('AddProduct')
AddProduct = 'PCommerce: Add Product'
setDefaultRoles(AddProduct, (
    'Manager',
    'Contributer',
    'Owner',
))

security.declarePublic('AddVariation')
AddVariation = 'PCommerce: Add Variation'
setDefaultRoles(AddVariation, (
    'Manager',
    'Contributer',
    'Owner',
))

security.declarePublic('AddImage')
AddVariation = 'PCommerce: Add Image'
setDefaultRoles(AddVariation, (
    'Manager',
    'Contributer',
    'Owner',
))

security.declarePublic('AddPrice')
AddPrice = 'PCommerce: Add Price'
示例#8
0
    'issubset': 1,
    'issuperset': 1,
    'pop': get_set_pop,
    'remove': 1,
    'symmetric_difference': 1,
    'symmetric_difference_update': 1,
    'union': 1,
    'update': 1
}

ContainerAssertions[set] = _check_access_wrapper(set, _set_white_dict)

ContainerAssertions[frozenset] = 1

from collections import OrderedDict
ModuleSecurityInfo('collections').declarePublic('OrderedDict')

from collections import defaultdict
ModuleSecurityInfo('collections').declarePublic('defaultdict')

from AccessControl.ZopeGuards import _dict_white_list

# Attributes cannot be set on defaultdict, thus modify 'safetype' dict
# (closure) directly to ignore defaultdict like dict/list
from RestrictedPython.Guards import full_write_guard
ContainerAssertions[defaultdict] = _check_access_wrapper(
    defaultdict, _dict_white_list)
full_write_guard.func_closure[1].cell_contents.__self__[defaultdict] = True

# In contrary to builtins such as dict/defaultdict, it is possible to set
# attributes on OrderedDict instances, so only allow setitem/delitem
示例#9
0
##############################################################################
"""Module Import Tests
"""

__rcs_id__ = '$Id$'
__version__ = '$Revision: 1.4 $'[11:-2]

import os, sys, unittest

import Testing
import ZODB
from AccessControl import User
from AccessControl import Unauthorized, ModuleSecurityInfo
from AccessControl.ZopeGuards import guarded_import

ModuleSecurityInfo('AccessControl.tests.mixed_module').declarePublic('pub')

ModuleSecurityInfo('AccessControl.tests.public_module').declarePublic('pub')
ModuleSecurityInfo(
    'AccessControl.tests.public_module.submodule').declarePublic('pub')


class SecurityTests(unittest.TestCase):
    def assertUnauth(self, module, fromlist):
        try:
            guarded_import(module, fromlist=fromlist)
        except (Unauthorized, ImportError):
            # Passed the test.
            pass
        else:
            assert 0, ('Did not protect module instance %s, %s' %
示例#10
0
# id to use in the Control Panel
cp_id = 'TranslationService'

# 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.declarePrivate('os')
security.declarePrivate('logging')
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')
示例#11
0

# Initialization method
def initialize(context):
    utils.registerIcon(
        DefaultWorkflowPolicy.DefaultWorkflowPolicyDefinition,
        'images/workflow_policy.gif',
        globals())

    context.registerClass(
        PlacefulWorkflowTool.PlacefulWorkflowTool,
        meta_type="Placeful Workflow Tool",
        constructors=(PlacefulWorkflowTool.addPlacefulWorkflowTool, ),
        icon='tool.gif')

    context.registerClass(
        WorkflowPolicyConfig.WorkflowPolicyConfig,
        permission='Add Workflow Policy',
        constructors=(WorkflowPolicyConfig.manage_addWorkflowPolicyConfigForm,
                      WorkflowPolicyConfig.manage_addWorkflowPolicyConfig),
        icon='www/WorkflowPolicyConfig_icon.gif',
    )

    utils.ToolInit('CMF Placeful Workflow Tool', tools=tools, icon='tool.gif'
                   ).initialize(context)

ModuleSecurityInfo('Products.CMFPlacefulWorkflow').declarePublic(
    'CMFPlacefulWorkflowMessageFactory')

CMFPlacefulWorkflowMessageFactory = MessageFactory('cmfplacefulworkflow')
示例#12
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
#

__author__ = """Conselleria de Infraestructuras y Transporte de la Generalidad Valenciana <*****@*****.**>, 
Model Driven Development sl <*****@*****.**>, 
Antonio Carrasco Valero <*****@*****.**>"""
__docformat__ = 'plaintext'



from AccessControl import ModuleSecurityInfo


security = ModuleSecurityInfo('Products.gvSIGi18n.TRAArchetypesNotInPortalCatalog')



security.declarePublic('cTRAArchetypesNotInPortalCatalog_list')


cTRAArchetypeNames_NotInPortalCatalog = [
    'TRACadena',
    'TRATraduccion',
]


示例#13
0
def initialize(context):
    """Intializer called when used as a Zope 2 product."""
    ModuleSecurityInfo('osha.theme.config').declarePublic('EUROPEAN_NETWORK')
示例#14
0
def initialize(context):
    """Initializer called when used as a Zope 2 product."""
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("SetPortrait")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("validatePasteData")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("PasteError")

    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getsortedblogentries")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("setup_users_my_area")

    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("triggerAddOnDiscussionItem")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getAllItemsForContext")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("isBTreeFolder")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getDefaultWikiPageForContext")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("setDefaultWikiPageForContext")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("checkEditPermission")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("checkHasPermission")

    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getListingTemplateForContextParent")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getAppTitleForContext")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("buildOneLevelUpURL")

    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getTagsAndTagsCount")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("escapeSingleQuote")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getTitleForRating")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getWorkflowStateTitle")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("isAddNewScreen")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getNavAccordianSelection")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getFormattedHtmlForTextFile")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getCurrentStatusMessageForUser")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("CyninVersion")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("CyninEdition")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getAuthorInfo")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getCyninMessageFactory")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getWebdavServerPort")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getWebdavURL")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getWebIntelligentTextToHTML")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getAvailableAppViews")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("notifyobjectinitialization")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("IsSelfRegistrationEnabled")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("licenseCheck")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getSchemaSectionName")



    #ContentRoot related methods
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getRootURL")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getRootAllFeedsURL")
    ModuleSecurityInfo("ubify.cyninv2theme").declarePublic("getRootID")

    ModuleSecurityInfo("ubify.cyninv2theme.portlets.statistics").declarePublic("getjsondata")
    ModuleSecurityInfo("ubify.cyninv2theme.portlets.statistics").declarePublic("getContributionCount")
    ModuleSecurityInfo("ubify.cyninv2theme.portlets.statistics").declarePublic("getCommentCount")
    ModuleSecurityInfo("ubify.cyninv2theme.portlets.statistics").declarePublic("getRecentContributionForUser")
    ModuleSecurityInfo("ubify.cyninv2theme.portlets.statistics").declarePublic("getTopRatedContentForUser")
    ModuleSecurityInfo("ubify.cyninv2theme.portlets.statistics").declarePublic("getMostUsedTagsForUser")
    ModuleSecurityInfo("ubify.cyninv2theme.portlets.statistics").declarePublic("getTotalItemCount")
示例#15
0

def initialize(context):
    context.registerClass(
        ZSQLCatalog.ZCatalog,
        permission='Add ZCatalogs',
        constructors=(ZSQLCatalog.manage_addZSQLCatalogForm,
                      ZSQLCatalog.manage_addZSQLCatalog),
        icon='www/ZCatalog.gif',
    )

    context.registerClass(
        SQLCatalog.Catalog,
        permission='Add ZCatalogs',
        constructors=(SQLCatalog.manage_addSQLCatalogForm,
                      SQLCatalog.manage_addSQLCatalog),
        icon='www/ZCatalog.gif',
    )

    context.registerHelp()
    context.registerHelpTitle('Zope Help')


from AccessControl import ModuleSecurityInfo, ClassSecurityInfo
ModuleSecurityInfo('Products.ZSQLCatalog.SQLCatalog').declarePublic(
    'ComplexQuery', 'Query', 'NegatedQuery', 'AndQuery', 'OrQuery',
    'BaseQuery')

from Query import Query, SimpleQuery
from SearchKey import SearchKey
示例#16
0
from ZTUtils.Zope import complex_marshal

from zope import i18n
from zope.component import getUtility
from zope.component import queryUtility
from zope.i18n.interfaces import IUserPreferredCharsets
from zope.i18nmessageid import MessageFactory

from Products.CMFCore.interfaces import IPropertiesTool

from Products.CMFDefault.interfaces import IHTMLScrubber
from Products.CMFDefault.exceptions import EmailAddressInvalid
from Products.CMFDefault.exceptions import IllegalHTML


security = ModuleSecurityInfo( 'Products.CMFDefault.utils' )

security.declarePrivate('_dtmldir')
_dtmldir = os.path.join( package_home( globals() ), 'dtml' )
_wwwdir = os.path.join( package_home( globals() ), 'www' )

security.declarePublic('formatRFC822Headers')
def formatRFC822Headers( headers ):

    """ Convert the key-value pairs in 'headers' to valid RFC822-style
        headers, including adding leading whitespace to elements which
        contain newlines in order to preserve continuation-line semantics.
    """
    munged = []
    linesplit = re.compile( r'[\n\r]+?' )
示例#17
0
    FieldRegistry.registerField(HoneypotField.HoneypotField,
                                'www/StringField.gif')

    # register help for the product
    context.registerHelp()
    # register field help for all fields
    FieldRegistry.registerFieldHelp(context)

    # make Dummy Fields into real fields
    FieldRegistry.initializeFields()

    # do initialization of Form class to make fields addable
    Form.initializeForm(FieldRegistry)
    Form.initializeForm(FieldRegistry, form_class=Report.ERP5Report)

    # Register FSPDFTemplate icon
    registerIcon(PDFTemplate.FSPDFTemplate, 'www/PDF.png', globals())
    # Register ProxyField icon
    registerIcon(ProxyField.ProxyField, 'www/ProxyField.png', globals())


## Initialize security ##
ModuleSecurityInfo('Products.ERP5Form.Report').declarePublic('ReportSection', )
ModuleSecurityInfo('Products.ERP5Form.MultiRelationField').declarePublic(
    'SUB_FIELD_ID', )
allow_module('Products.ERP5Form.Selection')
from .Selection import Selection
allow_class(Selection)

__module_aliases__ = ('Products.ERP5Form.SelectionTool', SelectionTool),
示例#18
0
# The following code lifted from Products.CMFCore for portability
from AccessControl import ModuleSecurityInfo
from Acquisition import aq_get
from Acquisition import aq_parent
from Acquisition.interfaces import IAcquirer
from zope.component import getUtility
from zope.component.interfaces import ComponentLookupError

security = ModuleSecurityInfo('alm.solrindex.utils')
_marker = []  # Create a new marker object.
_tool_interface_registry = {}

security.declarePublic('getToolByName')


def getToolByName(obj, name, default=_marker):
    """ Get the tool, 'toolname', by acquiring it.

    o Application code should use this method, rather than simply
      acquiring the tool by name, to ease forward migration (e.g.,
      to Zope3).
    """
    tool_interface = _tool_interface_registry.get(name)

    if tool_interface is not None:
        try:
            utility = getUtility(tool_interface)
            # Site managers, except for five.localsitemanager, return unwrapped
            # utilities. If the result is something which is acquisition-unaware
            # but unwrapped we wrap it on the context.
            if IAcquirer.providedBy(obj) and \
示例#19
0
    'issubset': 1,
    'issuperset': 1,
    'pop': get_set_pop,
    'remove': 1,
    'symmetric_difference': 1,
    'symmetric_difference_update': 1,
    'union': 1,
    'update': 1
}

ContainerAssertions[set] = _check_access_wrapper(set, _set_white_dict)

ContainerAssertions[frozenset] = 1

from collections import OrderedDict
ModuleSecurityInfo('collections').declarePublic('OrderedDict')

from collections import defaultdict
ModuleSecurityInfo('collections').declarePublic('defaultdict')

from AccessControl.ZopeGuards import _dict_white_list

# Attributes cannot be set on defaultdict, thus modify 'safetype' dict
# (closure) directly to ignore defaultdict like dict/list
from RestrictedPython.Guards import full_write_guard
ContainerAssertions[defaultdict] = _check_access_wrapper(
    defaultdict, _dict_white_list)
full_write_guard.func_closure[1].cell_contents.__self__[defaultdict] = True

# In contrary to builtins such as dict/defaultdict, it is possible to set
# attributes on OrderedDict instances, so only allow setitem/delitem
示例#20
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from .allgroups import AllGroupsOnSite
from AccessControl import ModuleSecurityInfo
from AccessControl import allow_class

groupsInfo_security = ModuleSecurityInfo('gs.groups.groupsInfo')
from .groupsInfo import GSGroupsInfoFactory, GSGroupsInfo

allow_class(GSGroupsInfoFactory)
allow_class(GSGroupsInfo)
示例#21
0
## Hide internal implementation
#from Products.ERP5Type.Globals import InitializeClass
#import Products.ERP5Type.Core.Folder as ERP5Folder
## Default constructor for Folder
## Can be overriden by adding a method addFolder in class Folder
#def addFolder(folder, id, REQUEST=None, **kw):
#o = ERP5Folder.Folder(id)
#folder._setObject(id, o)
#if kw is not None: o.__of__(folder)._edit(force_update=1, **kw)
## contentCreate already calls reindex 3 times ...
## o.reindexObject()
#if REQUEST is not None:
#REQUEST['RESPONSE'].redirect( 'manage_main' )

#InitializeClass(ERP5Folder.Folder)

from Products.ERP5Type.Base import TempBase
from Products.PythonScripts.Utility import allow_class
allow_class(TempBase)


def newTempBase(folder, id, REQUEST=None, **kw):
    o = TempBase(id)
    o = o.__of__(folder)
    if kw is not None: o._edit(force_update=1, **kw)
    return o


from AccessControl import ModuleSecurityInfo
ModuleSecurityInfo('Products.ERP5Type.Document').declarePublic('newTempBase', )
示例#22
0
from .interfaces.plugins import IRoleAssignerPlugin
from .interfaces.plugins import IRoleEnumerationPlugin
from .interfaces.plugins import IRolesPlugin
from .interfaces.plugins import IUpdatePlugin
from .interfaces.plugins import IUserAdderPlugin
from .interfaces.plugins import IUserEnumerationPlugin
from .interfaces.plugins import IUserFactoryPlugin
from .interfaces.plugins import IValidationPlugin
from .permissions import SearchPrincipals
from .PropertiedUser import PropertiedUser
from .utils import _wwwdir
from .utils import classImplements
from .utils import createKeywords
from .utils import createViewName

security = ModuleSecurityInfo(
    'Products.PluggableAuthService.PluggableAuthService')

logger = logging.getLogger('PluggableAuthService')

#   Errors which plugins may raise, and which we suppress:
_SWALLOWABLE_PLUGIN_EXCEPTIONS = (NameError, AttributeError, KeyError,
                                  TypeError, ValueError)


# except if they tell us not to do so
def reraise(plugin):
    try:
        doreraise = plugin._dont_swallow_my_exceptions
    except AttributeError:
        return
    if doreraise:
示例#23
0
""" CMFPlone product permissions """
from AccessControl import ModuleSecurityInfo

security = ModuleSecurityInfo('Products.CMFPlone.permissions')

security.declarePublic('AccessContentsInformation')
from Products.CMFCore.permissions import AccessContentsInformation

security.declarePublic('AddPortalContent')
from Products.CMFCore.permissions import AddPortalContent

security.declarePublic('AddPortalFolders')
from Products.CMFCore.permissions import AddPortalFolders

security.declarePublic('AddPortalMember')
from Products.CMFCore.permissions import AddPortalMember

security.declarePublic('DeleteObjects')
from Products.CMFCore.permissions import DeleteObjects

security.declarePublic('FTPAccess')
from Products.CMFCore.permissions import FTPAccess

security.declarePublic('ListFolderContents')
from Products.CMFCore.permissions import ListFolderContents

security.declarePublic('ListPortalMembers')
from Products.CMFCore.permissions import ListPortalMembers

security.declarePublic('ListUndoableChanges')
from Products.CMFCore.permissions import ListUndoableChanges
示例#24
0
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
#

__author__ = """Conselleria de Infraestructuras y Transporte de la Generalidad Valenciana <*****@*****.**>, 
Model Driven Development sl <*****@*****.**>, 
Antonio Carrasco Valero <*****@*****.**>"""
__docformat__ = 'plaintext'

# ACV 200905280016 unused
#from Products.CMFCore.permissions import setDefaultRoles
from AccessControl import ModuleSecurityInfo

security = ModuleSecurityInfo('Products.gvSIGi18n.TRARoles')

# #########################################
"""Creation of new instances of TRACatalogo (the root element) requires the user to have been granted the 
"gvSIGi18n: Add TRACatalogo" permission on the containing folder.
This is achieved by granting to the TRACreator role 
    through the Zope Management Interface security tab of the containing folder  
    the permissions below:
    [   'ACI', perm_AccessContentsInformation,],
    [   'APC', permissions.AddPortalContent,],  
    [   'APF', permissions.AddPortalFolders,],  
    [   'CHP', permissions.ChangePermissions,],
    [   'DOB', permissions.DeleteObjects,],     
    [   'LFC', permissions.ListFolderContents,],
    [   'MGR', perm_ManageGroups, ],
    [   'MPR', permissions.ManageProperties,], 
示例#25
0
from Products.ERP5 import _dtmldir

from mimetypes import guess_type
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.mime.audio import MIMEAudio
from email.mime.image import MIMEImage
from email.utils import formataddr
from email.header import make_header
from email import encoders

class ConversionError(Exception): pass
class MimeTypeException(Exception): pass

security = ModuleSecurityInfo('Products.ERP5.Tool.NotificationTool')
security.declarePublic('buildEmailMessage',)

def buildAttachmentDictList(document_list, document_type_list=()):
  """return a list of dictionary which will be used by buildEmailMessage"""
  attachment_list = []
  for attachment in document_list:
    mime_type = None
    content = None
    name = None
    if not attachment.getPortalType() in document_type_list:
      mime_type = 'application/pdf'
      content = attachment.asPDF() # XXX - Not implemented yet
    else:
      #
      # Document type attachment
示例#26
0
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" CMFSetup product initialization.

$Id$
"""

from AccessControl import ModuleSecurityInfo

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='Setup',
             icon=None).initialize(context)

    registerIcon(SetupTool, 'www/tool.png', globals())
示例#27
0
from Products.Archetypes.public import DisplayList
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
from time import time
from weasyprint import HTML, CSS
from zope.component import queryUtility
from zope.i18n import translate
from zope.i18n.locales import locales

import os
import re
import tempfile
import types
import urllib2

ModuleSecurityInfo('email.Utils').declarePublic('formataddr')
allow_module('csv')


def to_utf8(text):
    if text is None:
        text = ''
    return safe_unicode(text).encode('utf-8')


def to_unicode(text):
    if text is None:
        text = ''
    return safe_unicode(text)

示例#28
0
""" Product-specifict permissions.

$Id$
"""
from AccessControl import ModuleSecurityInfo
from AccessControl import Permissions
from AccessControl.Permission import _registeredPermissions
from AccessControl.Permission import pname
from Globals import ApplicationDefaultPermissions
import Products

security = ModuleSecurityInfo('Products.PluggableAuthService.permissions')

security.declarePublic('ManageUsers')
ManageUsers = Permissions.manage_users

security.declarePublic('ManageGroups')
ManageGroups = "Manage Groups"

security.declarePrivate('setDefaultRoles')


def setDefaultRoles(permission, roles):
    """ Set the defaults roles for a permission.

    o XXX This ought to be in AccessControl.SecurityInfo.
    """
    registered = _registeredPermissions

    if not registered.has_key(permission):
示例#29
0
""" 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',
    )
示例#30
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

import warnings

from AccessControl import ModuleSecurityInfo
from DateTime import DateTime
from datetime import datetime
from string import zfill

security = ModuleSecurityInfo(__name__)
security.declarePublic(
    'addToDate', 'getClosestDate', 'getIntervalBetweenDates',
    'getMonthAndDaysBetween', 'getCompletedMonthBetween',
    'getRoundedMonthBetween', 'getMonthFraction', 'getYearFraction',
    'getAccountableYearFraction', 'getBissextilCompliantYearFraction',
    'getIntervalListBetweenDates', 'getDecimalNumberOfYearsBetween',
    'roundMonthToGreaterEntireYear', 'roundDate', 'convertDateToHour',
    'getNumberOfDayInMonth', 'atTheEndOfPeriod', 'copyDate')

millis = DateTime('2000/01/01 12:00:00.001') - DateTime('2000/01/01 12:00:00')
centis = millis * 10
number_of_months_in_year = 12.
number_of_hours_in_day = 24.
number_of_minutes_in_hour = 60.
number_of_seconds_in_minute = 60.