Skip to content

Commit

Permalink
Tagging 3.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Mar 21, 2010
1 parent 385900d commit 676889b
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 0 deletions.
52 changes: 52 additions & 0 deletions bootstrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
##############################################################################
#
# Copyright (c) 2006 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Bootstrap a buildout-based project
Simply run this script in a directory containing a buildout.cfg.
The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
$Id$
"""

import os, shutil, sys, tempfile, urllib2

tmpeggs = tempfile.mkdtemp()

ez = {}
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
).read() in ez
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)

import pkg_resources

cmd = 'from setuptools.command.easy_install import main; main()'
if sys.platform == 'win32':
cmd = '"%s"' % cmd # work around spawn lamosity on windows

ws = pkg_resources.working_set
assert os.spawnle(
os.P_WAIT, sys.executable, sys.executable,
'-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
dict(os.environ,
PYTHONPATH=
ws.find(pkg_resources.Requirement.parse('setuptools')).location
),
) == 0

ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)
18 changes: 18 additions & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[buildout]
develop = .
parts = test coverage-test coverage-report

[test]
recipe = zc.recipe.testrunner
eggs = zope.app.localpermission

[coverage-test]
recipe = zc.recipe.testrunner
eggs = zope.app.localpermission
defaults = ['--coverage', '../../coverage']

[coverage-report]
recipe = zc.recipe.egg
eggs = z3c.coverage
scripts = coverage=coverage-report
arguments = ('coverage', 'coverage/report')
1 change: 1 addition & 0 deletions src/zope/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
1 change: 1 addition & 0 deletions src/zope/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
1 change: 1 addition & 0 deletions src/zope/app/localpermission/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from zope.app.localpermission.permission import LocalPermission
98 changes: 98 additions & 0 deletions src/zope/app/localpermission/permission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
##############################################################################
#
# Copyright (c) 2009 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Persistent Local Permissions
$Id: permission.py 97714 2009-03-09 18:52:31Z nadako $
"""
__docformat__ = 'restructuredtext'

from persistent import Persistent
from zope.component import adapter
from zope.component.interfaces import IRegistered, IUnregistered
from zope.i18nmessageid import MessageFactory
from zope.interface import implements
from zope.location import Location
from zope.security.interfaces import IPermission

_ = MessageFactory('zope')

NULL_ID = _(u'<permission not activated>')


class LocalPermission(Persistent, Location):
implements(IPermission)

def __init__(self, title=u'', description=u''):
self.id = NULL_ID
self.title = title
self.description = description


@adapter(IPermission, IRegistered)
def setIdOnActivation(permission, event):
"""Set the permission id upon registration activation.
Let's see how this notifier can be used. First we need to create an event
using the permission instance and a registration stub:
>>> class Registration:
... def __init__(self, obj, name):
... self.component = obj
... self.name = name
>>> perm1 = LocalPermission('Permission 1', 'A first permission')
>>> perm1.id
u'<permission not activated>'
>>> import zope.component.interfaces
>>> event = zope.component.interfaces.Registered(
... Registration(perm1, 'perm1'))
Now we pass the event into this function, and the id of the permission
should be set to 'perm1'.
>>> setIdOnActivation(perm1, event)
>>> perm1.id
'perm1'
"""
permission.id = event.object.name


@adapter(IPermission, IUnregistered)
def unsetIdOnDeactivation(permission, event):
"""Unset the permission id up registration deactivation.
Let's see how this notifier can be used. First we need to create an event
using the permission instance and a registration stub:
>>> class Registration:
... def __init__(self, obj, name):
... self.component = obj
... self.name = name
>>> perm1 = LocalPermission('Permission 1', 'A first permission')
>>> perm1.id = 'perm1'
>>> import zope.component.interfaces
>>> event = zope.component.interfaces.Unregistered(
... Registration(perm1, 'perm1'))
Now we pass the event into this function, and the id of the permission
should be set to NULL_ID.
>>> unsetIdOnDeactivation(perm1, event)
>>> perm1.id
u'<permission not activated>'
"""
permission.id = NULL_ID
24 changes: 24 additions & 0 deletions src/zope/app/localpermission/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Tests for zope.localpermission.
$Id$
"""
import unittest
import doctest

def test_suite():
return unittest.TestSuite((
doctest.DocTestSuite('zope.app.localpermission.permission'),
))

0 comments on commit 676889b

Please sign in to comment.