Example #1
0
def whitelist_module(module, classes=[], definitions=[]):

    # For python scripts and zope
    allow_module(module)
    for klass in classes:
        allow_class(klass)
    if definitions:
        ModuleSecurityInfo(module).declarePublic(*definitions)

    # for zope.untrustedpython
    defineChecker(imodule, NamesChecker([meth for meth in dir(imodule) if meth[0] != "_"]))
Example #2
0
from Products.PythonScripts.Utility import allow_module

allow_module('zlib')
allow_module('urllib')
allow_module('sys')
allow_module('os')
allow_module('uuid')
allow_module('appy.pod')
allow_module('appy.pod.renderer')
allow_module('subprocess')
allow_module('App.FindHomes')
allow_module('trml2pdf')
allow_module('cStringIO.StringIO')
allow_module('time')
allow_module('csv')
allow_module('email.MIMEMultipart')
allow_module('email.MIMEText')
Example #3
0
import sys
try:
    from importlib import reload
except ImportError:
    from imp import reload
if sys.version_info.major == 2:
    reload(sys)
    sys.setdefaultencoding('utf-8')


# try:
#     from chameleon import exc
#     exc._ellipsify = exc.ellipsify
#     exc.ellipsify = lambda x, y: x
# except ImportError:
#     pass


try:
    from pkgutil import iter_modules
    from Products.PythonScripts.Utility import allow_module
    [allow_module(module[0]) for module in iter_modules()]
except:
    pass
from Products.PythonScripts.Utility import allow_module
from Products.CMFCore.DirectoryView import registerDirectory

allow_module('collective.tagmanager')

GLOBALS = globals()
registerDirectory('skins', GLOBALS)

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

def outputConfig(configOptions):
    """Called from the javascript Ready() function and used to
       process the configuration settings making javascript
       function calls as necessary.
       """
    final_config = []
    for key in configOptions[1]:
        final_config.append('categoryList = addTagCategory("%s");' % key)
        for item in configOptions[0][key]:
            final_config.append('manageTags(categoryList, "%s", "%s");' % tuple(item));
    
    return ("\n"+" "*8).join(final_config)
Example #5
0
        
    return searches

def getSearchEngineURL(choice=default_search_destination, path='', q=''):
    searches = getSearchConfig(path=path, q=q)
    
    search_engine_data = dict([(x.get('key', None), x) for x in searches])
    
    search_engine = search_engine_data.get(choice, search_engine_data.get(default_search_destination, {}))
    
    return search_engine.get('url', '')
    

# Allow us to use this module in scripts

allow_module('Products.agCommon')
allow_module('feedparser')
allow_module('premailer')
allow_module('datetime')
allow_module('datetime.datetime')
allow_module('Products.feedSync')
allow_module('Products.feedSync.sync')
allow_module('Products.feedSync.cvent')
allow_module('Products.feedSync.cvent.api')
allow_module('Products.feedSync.tags')
allow_module('Products.feedSync.cvent.importEvents')
allow_module('Products.CMFCore.utils')
allow_module('Products.CMFCore.utils.getToolByName')
allow_module('urllib2')
allow_module('urllib')
allow_module('zope.component')
Example #6
0
from zope.i18nmessageid import MessageFactory
from Products.PythonScripts.Utility import allow_module
from Products.CMFCore.DirectoryView import registerDirectory

allow_module('agsci.common')
allow_module('agsci.common.utilities')
allow_module('Products.CMFPlone.utils')
allow_module('plone.app.textfield.value')

AgsciMessageFactory = MessageFactory('agsci.common')
GLOBALS = globals()

registerDirectory('skins/agsci_common', GLOBALS)

# Register indexers
from . import indexer


def initialize(context):
    pass


# Returns an object with the keyword arguments as properties
def object_factory(**kwargs):

    # https://stackoverflow.com/questions/1305532/convert-python-dict-to-object
    class _(object):
        def __init__(self, **kwargs):
            self.__dict__.update(kwargs)

            # Provide placeholder for empty text
Example #7
0
        'set_attr',
    ]


component.provideUtility(PlominoCoreUtils, interfaces.IPlominoUtils)


def get_utils():
    utils = {}
    for plugin_utils in component.getUtilitiesFor(interfaces.IPlominoUtils):
        module = plugin_utils[1].module
        utils[module] = plugin_utils[1].methods
    return utils


allow_module("Products.CMFPlomino.utils")


class PlominoSafeDomains:
    implements(interfaces.IPlominoSafeDomains)

    # by default, there is no domains allowed
    # but we can provide a IPlominoSafeDomains utility to declare some
    domains = []


component.provideUtility(PlominoSafeDomains, interfaces.IPlominoSafeDomains)


def get_resource_directory():
    """Obtain the Plomino persistent resource directory, creating it if
Example #8
0
from zope import component
from Products.CMFPlomino import interfaces
from zope.interface import implements

# TODO: support more of these:
# from tablib import Databook, Dataset, detect, import_set, InvalidDatasetType, InvalidDimensions, UnsupportedFormat

from tablib import Dataset
from tablib import Databook

from Products.PythonScripts.Utility import allow_module, allow_class

allow_module('plomino.tablib')
allow_class(Dataset)
allow_class(Databook)

def dataset(data, headers=None):
    """ `data` is a list of dicts.
    """
    dataset = Dataset()
    dataset.dict = data
    if headers:
        dataset.headers = headers
    return dataset

def databook(data):
    """ `data` is a tuple of datasets.
    """
    return Databook(data)

class PlominoTablibUtils:
# Allowing whole modules
# allow_module("module_name").

# Allow some names in modules
# ModuleSecurityInfo('module_name').declarePublic('name1', 'name2', ...)

# Allowing a class
# from <module_name> import <class>
# allow_class(<class>)

# Allow access to the exception "Redirect" in Python Scripts
ModuleSecurityInfo('zExceptions').declarePublic('Redirect')

# Allow regular expressions
allow_module("re")

# Allow the datetime module
allow_module("datetime")

# Allow the time module
allow_module("time")

# Allow ZTUtils, it provides url_query which is used in db_edit_magnetic
allow_module("ZTUtils")

# Allow access to python module "perfact" and submodules
allow_module("perfact.LDAP")
allow_module("perfact.asterisk_utils")
allow_module("perfact.balances")
allow_module("perfact.barcode")
Example #10
0
from .FieldRegistry import FieldRegistry
from . import Errors
from Products.PythonScripts.Utility import allow_module

try:
    try:
        import Products.FileSystemSite
    except ImportError:
        import Products.CMFCore
except ImportError:
    pass
else:
    from . import FSForm

# Allow Errors to be imported TTW
allow_module('Products.Formulator.Errors')


def initialize(context):
    """Initialize the Formulator product.
    """
    # register field classes
    FieldRegistry.registerField(StandardFields.StringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(StandardFields.CheckBoxField,
                                'www/CheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.IntegerField,
                                'www/IntegerField.gif')
    FieldRegistry.registerField(StandardFields.TextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.RawTextAreaField,
Example #11
0
# -*- coding: utf-8 -*-
"""Init and utils."""
from AccessControl import allow_class, ModuleSecurityInfo
from Products.PythonScripts.Utility import allow_module

# Whitelist pdf functions
allow_module('pretaweb.plomino2pdf.api')
pdf_api = ModuleSecurityInfo('pretaweb.plomino2pdf.api')
pdf_api.declarePublic('generate_pdf')

# Whitelist email functions
allow_module('email.mime.multipart')
multipart = ModuleSecurityInfo('email.mime.multipart')
multipart.declarePublic('MIMEMultipart')
allow_module('email.mime.text')
text = ModuleSecurityInfo('email.mime.text')
text.declarePublic('MIMEMultipart')
allow_module('email.mime.application')
application = ModuleSecurityInfo('email.mime.application')
application.declarePublic('MIMEApplication')

# Whitelist plone.api
allow_module('plone.api.portal')
portal = ModuleSecurityInfo('plone.api.portal')
portal.declarePublic('get_tool')
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.DirectoryView import registerDirectory
from Products.PythonScripts.Utility import allow_module
from zope.component.interfaces import ComponentLookupError
from Products.CMFCore.WorkflowCore import WorkflowException
from subprocess import Popen,PIPE
from zLOG import LOG, INFO, ERROR

import re

GLOBALS = globals()
registerDirectory('skins', GLOBALS)

# Allow us to use this module in scripts

allow_module('Products.agCommon')
allow_module('feedparser')
allow_module('datetime')
allow_module('datetime.datetime')
allow_module('Products.feedSync')
allow_module('Products.feedSync.sync')
allow_module('Products.feedSync.cvent')
allow_module('Products.feedSync.cvent.importEvents')
allow_module('Products.CMFCore.utils')
allow_module('Products.CMFCore.utils.getToolByName')
allow_module('zope.component')
allow_module('zope.component.getSiteManager')

allow_module('Products.GlobalModules')
allow_module('Products.GlobalModules.makeHomePage')
allow_module('Products.GlobalModules.makePhotoFolder')
from AccessControl import ModuleSecurityInfo, allow_type
from Products.PythonScripts.Utility import allow_module

import csv
import re
import StringIO

allow_module('re')
ModuleSecurityInfo('re').declarePublic('compile', 'findall',
  'match', 'search', 'split', 'sub', 'subn', 'error',
  'I', 'L', 'M', 'S', 'X')
allow_type(type(re.compile('')))
allow_type(type(re.match('x', 'x')))


allow_module('StringIO')
ModuleSecurityInfo('StringIO').declarePublic('StringIO',)
allow_type(type(StringIO.StringIO("")))


allow_module('csv')
ModuleSecurityInfo('csv').declarePublic('reader', 'writer', 'register_dialect',
    'QUOTE_ALL', 'QUOTE_MINIMAL', 'QUOTE_NONNUMERIC', 'QUOTE_NONE', 'Error',
    'Sniffer'
    )
# reader type
allow_type(type(csv.reader(StringIO.StringIO(""))))
# writer type
allow_type(type(csv.writer(StringIO.StringIO(""))))
# Sniffer type
Example #14
0
from FieldRegistry import FieldRegistry
import Errors
from Products.PythonScripts.Utility import allow_module

try:
    try:
        import Products.FileSystemSite
    except ImportError:
        import Products.CMFCore
except ImportError:
    pass
else:
    import FSForm

# Allow Errors to be imported TTW
allow_module('Products.Formulator.Errors')

def initialize(context):
    """Initialize the Formulator product.
    """
    # register field classes
    FieldRegistry.registerField(StandardFields.StringField,
                                'www/StringField.gif')
    FieldRegistry.registerField(StandardFields.CheckBoxField,
                                'www/CheckBoxField.gif')
    FieldRegistry.registerField(StandardFields.IntegerField,
                                'www/IntegerField.gif')
    FieldRegistry.registerField(StandardFields.TextAreaField,
                                'www/TextAreaField.gif')
    FieldRegistry.registerField(StandardFields.RawTextAreaField,
                                'www/TextAreaField.gif')
Example #15
0
#This software is released under GNU public license. See details in the URL:
#http://www.gnu.org/copyleft/gpl.html

from base import Base
from baseobject import BaseObject
import compounddoc
import utility
import basewidget

from Products.PythonScripts.Utility import allow_module, allow_class
from AccessControl import ModuleSecurityInfo, ClassSecurityInfo
from AccessControl.class_init import InitializeClass

allow_module('com.javascript')
allow_module('com.css')
allow_module('com.detection')
allow_module('com.html')
allow_module('com.form')
allow_module('com.catalog')
allow_module('com.parsers')
allow_module('com.db')
allow_module('com.google')


def initialize(context):
    "Initialize the CompoundDoc object."
    root = getattr(context, '_ProductContext__app')

    if root is not None and root.hasObject('CDocShared'):
        root.manage_delObjects(['CDocShared'])
Example #16
0
#
###############################################################################

import sys
import os
import Globals
import Portal
from lexml import SAPLOAIServer

from Products.CMFCore.DirectoryView import registerDirectory

from config import SKINS_DIR, GLOBALS, PROJECTNAME

from Products.PythonScripts.Utility import allow_module

allow_module('zlib')
allow_module('urllib')
allow_module('sys')
allow_module('os')
allow_module('App.FindHomes')
allow_module('trml2pdf')
allow_module('cStringIO.StringIO')
allow_module('time')

registerDirectory(SKINS_DIR, GLOBALS)

from Products.CMFCore.utils import ToolInit
from SAPLTool import SAPLTool


def initialize(context):
from zope.i18nmessageid import MessageFactory
from Products.CMFCore.utils import getToolByName
from Products.PythonScripts.Utility import allow_module
from Products.Five.utilities.interfaces import IMarkerInterfaces
from agsci.ExtensionExtender.interfaces import IExtensionCountiesExtender, IExtensionCourseExtender
from Products.CMFCore import DirectoryView

ExtensionExtenderMessageFactory = MessageFactory('agsci.ExtensionExtender')

# Register our skins directory - this makes it available via portal_skins.

DirectoryView.registerDirectory('skins', globals())

allow_module('agsci.ExtensionExtender')

def initialize(context):
    pass

def getContactEmails(context, county=None, topic=None, subtopic=None):
    portal_catalog = getToolByName(context, "portal_catalog")

    query = {'portal_type' : 'FSDPerson'}
    emails = []
    
    if county:
        query['Counties'] = county

    if topic:
        query['Topics'] = topic

    if subtopic:
Example #18
0


# Allow RE in restricted python. Based on collective.localfunctions
# by Steve McMahon
import re
#allow_module('re')
ModuleSecurityInfo('re').declarePublic(
    'compile', 'findall', 'match', 'search', 'split', 'sub', 'subn', 'error',
    'I', 'L', 'M', 'S', 'X')
allow_type(type(re.compile('')))
allow_type(type(re.match('x', 'x')))


# Random
allow_module('random')
#z3
import random
#defineChecker(random, NamesChecker(['uniform','shuffle']))
defineChecker(random, NamesChecker([meth for meth in dir(random) if meth[0] != '_']))
allow_class(random.SystemRandom)


# UUID

#allow_module('uuid')
import uuid
allow_class(uuid.UUID)
ModuleSecurityInfo('uuid').declarePublic(
    'uuid1', 'uuid2', 'uuid3', 'uuid4', 'uuid5')
Example #19
0
from Globals import package_home

from Products.Archetypes.public import process_types, listTypes
from Products.CMFCore import utils
from Products.CMFCore.DirectoryView import registerDirectory



from config import SKINS_DIR, GLOBALS, PROJECTNAME
from config import ADD_CONTENT_PERMISSION

registerDirectory(SKINS_DIR, GLOBALS)

from Products.PythonScripts.Utility import allow_module
allow_module('csv')

def initialize(context):
    ##Import Types here to register them
    import Importer

    content_types, constructors, ftis = process_types(
        listTypes(PROJECTNAME),
        PROJECTNAME)

    utils.ContentInit(
        PROJECTNAME + ' Content',
        content_types      = content_types,
        permission         = ADD_CONTENT_PERMISSION,
        extra_constructors = constructors,
        fti                = ftis,
        ).initialize(context)
Example #20
0
File: policy.py Project: RBINS/mars
for i in [
    'csv',
    'datetime',
    're',
    'time',
    'urllib',
    'urllib2',
    'StringIO',
    'cStringIO',
    'rbins_masschange',
    'rbins_masschange.utils',
    'plone.app.textfield.value',
]:
    exec 'import {0}'.format(i)
    allow_module(i)

ModuleSecurityInfo('datetime').declarePublic('datetime')
allow_class(csv.DictReader)
allow_class(csv.DictWriter)
allow_class(csv.Dialect)
allow_class(csv.excel)
allow_class(csv.excel_tab)
allow_class(csv.Sniffer)
allow_class(plone.app.textfield.value.RichTextValue)


allow_module('re')
ModuleSecurityInfo('re').declarePublic(
    'compile', 'findall', 'match', 'search', 'split', 'sub', 'subn', 'error',
    'I', 'L', 'M', 'S', 'X')
Example #21
0
except ImportError:
    # < Zope 2.10
    from zope.app.schema import vocabulary
    IVocabularyFactory = vocabulary.IVocabularyFactory

try:
    from zope.app.component.hooks import getSite
except ImportError:
    from zope.component.hooks import getSite

from Products.PythonScripts.Utility import allow_module

import logging
logger = logging.getLogger('pretaweb.plominolib')

allow_module('pretaweb.plominolib')
# allow_module('time')
# allow_module('tktauth')

#Uses files but doesn't open them. need to double check
allow_module('csv')
# ModuleSecurityInfo('nntplib').declarePublic('NNTP',
#   'error_reply', 'error_temp', 'error_perm', 'error_proto')
import csv
allow_class(csv.DictReader)
allow_class(csv.DictWriter)
allow_class(csv.Dialect)
allow_class(csv.excel)
allow_class(csv.excel_tab)
allow_class(csv.Sniffer)
Example #22
0
import Products.CMFPlone.interfaces
from Products.Archetypes import listTypes
from Products.Archetypes.atapi import *
from Products.Archetypes.utils import capitalize
from Products.CMFCore import DirectoryView
from Products.CMFCore import permissions as cmfpermissions
from Products.CMFCore import utils as cmfutils
from Products.CMFPlone.utils import ToolInit
from config import *

DirectoryView.registerDirectory('skins', product_globals)


##code-section custom-init-head #fill in your manual code here
from Products.PythonScripts.Utility import allow_module
allow_module('Products.cooptation.wfsubscribers.notifyCooptationToUser')
##/code-section custom-init-head


def initialize(context):
    """initialize product (called by zope)"""
    ##code-section custom-init-top #fill in your manual code here
    ##/code-section custom-init-top

    # imports packages and types for registration
    import content
    import tool


    # Initialize portal tools
    tools = [tool.Cooptations.Cooptations]
Example #23
0
"""Main product initializer
"""

from zope.i18nmessageid import MessageFactory
trashcanMessageFactory = MessageFactory('ecreall.trashcan')

from Products.PythonScripts.Utility import allow_module
allow_module('ecreall.trashcan.ITrashedProvidedBy')
allow_module('ecreall.trashcan.providesITrashed')
allow_module('ecreall.trashcan.noLongerProvidesITrashed')
allow_module('ecreall.trashcan.moveObjectsToTrashcanByPaths')
allow_module('ecreall.trashcan.restoreObjectsFromTrashcanByPaths')

import transaction
from zope.interface import alsoProvides, noLongerProvides, Interface
from zope.annotation.interfaces import IAnnotations
from OFS.interfaces import IFolder
from AccessControl import Unauthorized
from AccessControl.requestmethod import postonly
from ZODB.POSException import ConflictError

from Products.CMFPlone.utils import transaction_note
from Products.CMFCore.utils import getToolByName
try:
    from Products.PluginIndexes.BooleanIndex.BooleanIndex import BooleanIndex
    HAS_BOOLEANINDEX = True
except:
    HAS_BOOLEANINDEX = False

from ecreall.trashcan.interfaces import ITrashed
Example #24
0
# Place, Suite 330, Boston, MA  02111-1307  USA
#
###############################################################################

import sys
import os
import Globals
import Portal

from Products.CMFCore.DirectoryView import registerDirectory

from config import SKINS_DIR, GLOBALS

from Products.PythonScripts.Utility import allow_module

allow_module('zlib')
allow_module('urllib')
allow_module('sys')
allow_module('os')
allow_module('App.FindHomes')
allow_module('trml2pdf')
allow_module('cStringIO.StringIO')
allow_module('time')

registerDirectory(SKINS_DIR, GLOBALS)

def initialize(context):

    # inicializa a instalacao e estrutura do SAPL

    context.registerClass( Portal.SAPL,
Example #25
0
def initialize(context):
    # inicializa a instalacao e estrutura do SAPL


    ModuleSecurityInfo('socket.socket').declarePublic('fileno')
    ModuleSecurityInfo('tempfile.NamedTemporaryFile').declarePublic('flush')

    allow_module('zlib')
    allow_module('urllib')
    allow_module('urllib2')
    allow_module('sys')
    allow_module('os')
    allow_module('App.FindHomes')
    allow_module('trml2pdf')
    allow_module('cStringIO.StringIO')
    allow_module('time')
    allow_module('_strptime')
    allow_module('csv')
    allow_module('pdb')
    allow_module('simplejson')
    allow_module('tempfile.NamedTemporaryFile')

    allow_module('socket')
    allow_module('fcntl')
    allow_module('struct')
    allow_module('array')
    allow_module('datetime')
    allow_module('datetime.datetime.timetuple')
    allow_module('re')


    tools = (SAPLTool.SAPLTool,)
    ToolInit('SAPL Tool',
                tools = tools,
                icon = 'tool.gif'
                ).initialize( context )

    context.registerClass( Portal.SAPL,
                           constructors=( Portal.manage_addSAPLForm,
                                          Portal.manage_addSAPL,),
                           icon='interlegisIcon.gif')

    context.registerClass( lexml.SAPLOAIServer.SAPLOAIServer,
                           constructors = ( SAPLOAIServer.manage_addSAPLOAIServerForm,
                                            SAPLOAIServer.manage_addSAPLOAIServer, ),
                            icon='oai_service.png')
Example #26
0
from Acquisition import aq_get
from Products.PythonScripts.Utility import allow_module
allow_module('ecreall.trashcan.utils.get_session')

def get_session(obj):
    # Don't use request.SESSION because it uses
    # session_data_manager.getSessionData(create=1)
    # and so create a TransientObject for each webdav request (because it
    # doesn't use cookie) and you get finally a "MaxTransientObjectsExceeded:
    # 1000 exceeds maximum number of subobjects 1000"
    request = aq_get(obj, 'REQUEST', None)
    if request is None:
        # in test environment, we don't have REQUEST
        return

    session_data_manager = getattr(obj, 'session_data_manager', None)
    if session_data_manager is None:
        # in test environment, we don't have session_data_manager
        return

    session = session_data_manager.getSessionData(create=False)
    if session is None:
        return

    return session
Example #27
0
def initialize(context):
    # inicializa a instalacao e estrutura do SAGL-OpenLegis

    ModuleSecurityInfo('socket.socket').declarePublic('fileno')
    ModuleSecurityInfo('tempfile.NamedTemporaryFile').declarePublic('flush')

    allow_module('zlib')
    allow_module('urllib')
    allow_module('urllib2')
    allow_module('sys')
    allow_module('os')
    allow_module('lacunarestpki')
    allow_module('Acquisition')
    allow_module('ExtensionClass')
    allow_module('App.FindHomes')
    allow_module('trml2pdf')
    allow_module('cStringIO.StringIO')
    allow_module('time')
    allow_module('_strptime')
    allow_module('csv')
    allow_module('pdb')
    allow_module('simplejson')
    allow_module('tempfile.NamedTemporaryFile')
    allow_module('collections')
    allow_module('base64')
    allow_module('socket')
    allow_module('fcntl')
    allow_module('struct')
    allow_module('array')
    allow_module('datetime')
    allow_module('datetime.datetime.timetuple')
    allow_module('PyPDF2')
    allow_module('StringIO')
    allow_module('PIL')

    tools = (SAPLTool.SAPLTool, )
    ToolInit('SAPL Tool', tools=tools, icon='tool.gif').initialize(context)

    context.registerClass(Portal.SAPL,
                          constructors=(
                              Portal.manage_addSAPLForm,
                              Portal.manage_addSAPL,
                          ),
                          icon='interlegisIcon.gif')

    context.registerClass(lexml.SAPLOAIServer.SAPLOAIServer,
                          constructors=(
                              SAPLOAIServer.manage_addSAPLOAIServerForm,
                              SAPLOAIServer.manage_addSAPLOAIServer,
                          ),
                          icon='oai_service.png')
Example #28
0
from Products.PythonScripts.Utility import allow_module

allow_module("zlib")
allow_module("urllib")
allow_module("sys")
allow_module("os")
allow_module("uuid")
allow_module("appy.pod")
allow_module("appy.pod.renderer")
allow_module("subprocess")
allow_module("App.FindHomes")
allow_module("trml2pdf")
allow_module("cStringIO.StringIO")
allow_module("time")
allow_module("csv")
allow_module("email.MIMEMultipart")
allow_module("email.MIMEText")
Example #29
0
        'SCRIPT_ID_DELIMITER',
        'save_point',
        'set_attr',
    ]

component.provideUtility(PlominoCoreUtils, interfaces.IPlominoUtils)


def get_utils():
    utils = {}
    for plugin_utils in component.getUtilitiesFor(interfaces.IPlominoUtils):
        module = plugin_utils[1].module
        utils[module] = plugin_utils[1].methods
    return utils

allow_module("Products.CMFPlomino.utils")


class PlominoSafeDomains:
    implements(interfaces.IPlominoSafeDomains)

    # by default, there is no domains allowed
    # but we can provide a IPlominoSafeDomains utility to declare some
    domains = []

component.provideUtility(PlominoSafeDomains, interfaces.IPlominoSafeDomains)


def get_resource_directory():
    """Obtain the Plomino persistent resource directory, creating it if
    necessary.
Example #30
0
from AccessControl import allow_class, ModuleSecurityInfo, ClassSecurityInfo
from AccessControl.class_init import InitializeClass
from Products.PythonScripts.Utility import allow_module
from zope.security.checker import defineChecker, CheckerPublic, NamesChecker


allow_module("plone.subrequest")

# Whitelist plone.api
allow_module('plone.api.portal')
portal = ModuleSecurityInfo('plone.api.portal')
portal.declarePublic('get_tool')

# zope transcation stuff
ModuleSecurityInfo("transaction").declarePublic("savepoint")

# Basic ZODB stuff
import persistent.list
import persistent.dict
defineChecker(persistent.list, NamesChecker(['PersistentList']))
defineChecker(persistent.dict, NamesChecker(['PersistentDict']))

dict_checker = NamesChecker(['__call__','__init__','__getitem__', '__len__', '__iter__',
                        'get', 'has_key', 'copy', '__str__', 'keys',
                        'values', 'items', 'iterkeys', 'iteritems',
                        'itervalues', '__contains__'])
persistent.dict.PersistentDict.__Security_checker__ = dict_checker
list_checker = NamesChecker(['__call__','__init__','__getitem__', '__getslice__', '__len__', '__iter__',
                        '__contains__', 'index', 'count', '__str__',
                        '__add__', '__radd__','__setitem__' ])
persistent.list.PersistentList.__Security_checker__ = list_checker
except:
    from Products.Archetypes.public import process_types, listTypes
 
from Products.CMFCore import utils
from Products.CMFCore.DirectoryView import registerDirectory

from ContentPanelsTool import registerViewlets
from ContentPanelsTool import ContentPanelsTool
from config import SKINS_DIR, GLOBALS,VIEWLETS
from config import PROJECTNAME, ADD_CONTENT_PERMISSION
from config import MessageFactory

registerViewlets(VIEWLETS)
from Products.PythonScripts.Utility import allow_module

allow_module("feedparser")
allow_module('Products.CMFContentPanels.browser.subnavtree')
    
def initialize(context):

    import ContentPanels
    content_types, constructors, ftis = process_types(
        listTypes(PROJECTNAME),
        PROJECTNAME)

    utils.ContentInit(
        PROJECTNAME + ' Content',
        content_types      = content_types,
        permission         = ADD_CONTENT_PERMISSION,
        extra_constructors = constructors,
        fti                = ftis,
Example #32
0
# -*- coding: utf-8 -*-
# Copyright (c) 2011-2013 RelationWare, Benno Luthiger. All rights reserved.
# See also LICENSE.txt
from silva.core import conf as silvaconf
from silva.core.conf.installer import DefaultInstaller
from zope.interface import Interface

_extensionName = "RwLayout"
silvaconf.extensionName(_extensionName)
silvaconf.extensionTitle("RelationWare Layout")
silvaconf.extensionDepends(("SilvaDocument", "SilvaExternalSources"))

from Products.PythonScripts.Utility import allow_module
allow_module('Products.RwLayout.helpers')


class IExtension(Interface):
    '''
    RwLayout Extension
    '''

class RwLayoutInstaller(DefaultInstaller):

    def install_custom(self, root):
        pass
    
    def uninstall_custom(self, root):
        pass
    
install = RwLayoutInstaller(_extensionName, IExtension)
from Products.CMFCore.utils import getToolByName
from Products.PythonScripts.Utility import allow_module
from zope.i18nmessageid import MessageFactory
from DateTime import DateTime

seoMessageFactory = MessageFactory('agsci.seo')

allow_module('agsci.seo')

def initialize(context):
    pass


def getDisallowedPaths(context):
    
    now = DateTime()
    
    portal_catalog = getToolByName(context, 'portal_catalog')

    results = [x for x in portal_catalog.searchResults({'exclude_from_robots' : True})]
    results.extend([x for x in portal_catalog.searchResults({'portal_type' : 'Event', 'end' : {'query' : now, 'range' : 'max'}})])
    results.extend([x for x in portal_catalog.searchResults({'expires' : {'query' : now, 'range' : 'max'}})])
    
    portal_url = context.portal_url()
    
    disallow = []
    
    for r in results:
        disallow.append(r.getURL().replace(portal_url, '') )
    
    return sorted(list(set(disallow)))