[Zope-Checkins] SVN: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py Get the Zope2 path from the selected Python interpreter, which is not

2009-04-13 Thread Stefan H. Holek
Log message for revision 99032:
  Get the Zope2 path from the selected Python interpreter, which is not
  necessarily the same as the one used to run mkzopeinstance.
  

Changed:
  U   Zope/trunk/src/Zope2/utilities/mkzopeinstance.py

-=-
Modified: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py
===
--- Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 12:28:27 UTC 
(rev 99031)
+++ Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 14:24:24 UTC 
(rev 99032)
@@ -123,8 +123,7 @@
 # we're on UNIX or we have a nonstandard Windows setup
 PYTHON = PYTHONW = python
 
-import Zope2
-zope2path = os.path.realpath(os.path.dirname(Zope2.__file__))
+zope2path = get_zope2path(PYTHON)
 
 kw = {
 PYTHON:PYTHON,
@@ -198,5 +197,15 @@
 parser.read('buildout.cfg')
 return 'zopepy' in parser.sections()
 
+def get_zope2path(python):
+ Get Zope2 path from selected Python interpreter.
+
+p = os.popen('%s -cimport os, Zope2; '
+ 'print os.path.realpath(os.path.dirname(Zope2.__file__))' % 
python)
+try:
+return p.readline()[:-1]
+finally:
+p.close()
+
 if __name__ == __main__:
 main()

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py Change indentation to reduce line length.

2009-04-13 Thread Stefan H. Holek
Log message for revision 99033:
  Change indentation to reduce line length.

Changed:
  U   Zope/trunk/src/Zope2/utilities/mkzopeinstance.py

-=-
Modified: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py
===
--- Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 14:24:24 UTC 
(rev 99032)
+++ Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 15:14:35 UTC 
(rev 99033)
@@ -201,7 +201,7 @@
  Get Zope2 path from selected Python interpreter.
 
 p = os.popen('%s -cimport os, Zope2; '
- 'print os.path.realpath(os.path.dirname(Zope2.__file__))' % 
python)
+'print os.path.realpath(os.path.dirname(Zope2.__file__))' % python)
 try:
 return p.readline()[:-1]
 finally:

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py Remove checks that cannot possibly fail.

2009-04-13 Thread Stefan H. Holek
Log message for revision 99039:
  Remove checks that cannot possibly fail.

Changed:
  U   Zope/trunk/src/Zope2/utilities/mkzopeinstance.py

-=-
Modified: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py
===
--- Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 15:49:07 UTC 
(rev 99038)
+++ Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 15:50:58 UTC 
(rev 99039)
@@ -56,14 +56,8 @@
 for opt, arg in opts:
 if opt in (-d, --dir):
 skeltarget = os.path.abspath(os.path.expanduser(arg))
-if not skeltarget:
-usage(sys.stderr, dir must not be empty)
-sys.exit(2)
 if opt in (-s, --skelsrc):
 skelsrc = os.path.abspath(os.path.expanduser(arg))
-if not skelsrc:
-usage(sys.stderr, skelsrc must not be empty)
-sys.exit(2)
 if opt in (-p, --python):
 python = os.path.abspath(os.path.expanduser(arg))
 if not os.path.exists(python) and os.path.isfile(python):
@@ -73,9 +67,6 @@
 usage(sys.stdout)
 sys.exit()
 if opt in (-u, --user):
-if not arg:
-usage(sys.stderr, user must not be empty)
-sys.exit(2)
 if not : in arg:
 usage(sys.stderr, user must be specified as name:password)
 sys.exit(2)

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


Re: [Zope-Checkins] [Checkins] SVN: Zope/trunk/buildout.cfg Revert c98428, as it broke the nightly tests.

2009-04-13 Thread Baiju M
On Sat, Mar 28, 2009 at 7:21 AM, Hanno Schlichting pl...@hannosch.info wrote:
 Log message for revision 98431:
  Revert c98428, as it broke the nightly tests.


 Changed:
  U   Zope/trunk/buildout.cfg

Thanks for reverting it.  I looked at test failures:

  http://mail.zope.org/pipermail/zope-tests/2009-March/011353.html
  http://mail.zope.org/pipermail/zope-tests/2009-March/011354.html

I can see that we need to make change in 'alltests.cfg' also.

--- alltests.cfg(revision 98433)
+++ alltests.cfg(working copy)
@@ -8,7 +8,7 @@
 [alltests]
 recipe = zc.recipe.testrunner
 eggs =
-${buildout:eggs}
+Zope2
 Acquisition
 DateTime
 ExtensionClass

I am going to commit it all again, is it Ok ?

Regards,
Baiju M
___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py Move interpreter check to where it also catches auto-detected interpreters.

2009-04-13 Thread Stefan H. Holek
Log message for revision 99044:
  Move interpreter check to where it also catches auto-detected interpreters.

Changed:
  U   Zope/trunk/src/Zope2/utilities/mkzopeinstance.py

-=-
Modified: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py
===
--- Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 15:54:09 UTC 
(rev 99043)
+++ Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 15:55:49 UTC 
(rev 99044)
@@ -60,9 +60,6 @@
 skelsrc = os.path.abspath(os.path.expanduser(arg))
 if opt in (-p, --python):
 python = os.path.abspath(os.path.expanduser(arg))
-if not os.path.exists(python) and os.path.isfile(python):
-usage(sys.stderr, The Python interpreter does not exist.)
-sys.exit(2)
 if opt in (-h, --help):
 usage(sys.stdout)
 sys.exit()
@@ -72,6 +69,10 @@
 sys.exit(2)
 user, password = arg.split(:, 1)
 
+if python is not None and not os.path.isfile(python):
+usage(sys.stderr, The Python interpreter does not exist.)
+sys.exit(2)
+
 if not skeltarget:
 # interactively ask for skeltarget and initial user name/passwd.
 # cant set custom instancehome in interactive mode, we default

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py Reverted r99039 and r99044. This is not what I came here for.

2009-04-13 Thread Stefan H. Holek
Log message for revision 99061:
  Reverted r99039 and r99044. This is not what I came here for.
  

Changed:
  U   Zope/trunk/src/Zope2/utilities/mkzopeinstance.py

-=-
Modified: Zope/trunk/src/Zope2/utilities/mkzopeinstance.py
===
--- Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 17:05:57 UTC 
(rev 99060)
+++ Zope/trunk/src/Zope2/utilities/mkzopeinstance.py2009-04-09 20:45:16 UTC 
(rev 99061)
@@ -56,23 +56,31 @@
 for opt, arg in opts:
 if opt in (-d, --dir):
 skeltarget = os.path.abspath(os.path.expanduser(arg))
+if not skeltarget:
+usage(sys.stderr, dir must not be empty)
+sys.exit(2)
 if opt in (-s, --skelsrc):
 skelsrc = os.path.abspath(os.path.expanduser(arg))
+if not skelsrc:
+usage(sys.stderr, skelsrc must not be empty)
+sys.exit(2)
 if opt in (-p, --python):
 python = os.path.abspath(os.path.expanduser(arg))
+if not os.path.exists(python) and os.path.isfile(python):
+usage(sys.stderr, The Python interpreter does not exist.)
+sys.exit(2)
 if opt in (-h, --help):
 usage(sys.stdout)
 sys.exit()
 if opt in (-u, --user):
+if not arg:
+usage(sys.stderr, user must not be empty)
+sys.exit(2)
 if not : in arg:
 usage(sys.stderr, user must be specified as name:password)
 sys.exit(2)
 user, password = arg.split(:, 1)
 
-if python is not None and not os.path.isfile(python):
-usage(sys.stderr, The Python interpreter does not exist.)
-sys.exit(2)
-
 if not skeltarget:
 # interactively ask for skeltarget and initial user name/passwd.
 # cant set custom instancehome in interactive mode, we default

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/trunk/ Make the set_attributes and set_schema options to class ...require ... //class issue a warning rather than throw an exception. Whilst the concept doesn't make mu

2009-04-13 Thread Martin Aspeli
Log message for revision 99145:
  Make the set_attributes and set_schema options to class ...require ... 
//class issue a warning rather than throw an exception. Whilst the concept 
doesn't make much sense in Zope 2, it's desirable to be able to re-use existing 
packages that do declare such protection

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/Products/Five/metaconfigure.py
  U   Zope/trunk/src/Products/Five/tests/test_security.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2009-04-13 02:25:29 UTC (rev 99144)
+++ Zope/trunk/doc/CHANGES.rst  2009-04-13 10:15:12 UTC (rev 99145)
@@ -23,6 +23,11 @@
 Restructuring
 +
 
+- Using require set_schema=... / or require set_attributes=... / in
+  the class / directive now emits a warning rather than an error. The
+  concept of protecting attribute 'set' does not exist in Zope 2, but it
+  should be possible to re-use packages that do declare such protection.
+
 - Updated to DateTime 2.12.0.
 
 - Updated to ZODB 3.9.0a12.

Modified: Zope/trunk/src/Products/Five/metaconfigure.py
===
--- Zope/trunk/src/Products/Five/metaconfigure.py   2009-04-13 02:25:29 UTC 
(rev 99144)
+++ Zope/trunk/src/Products/Five/metaconfigure.py   2009-04-13 10:15:12 UTC 
(rev 99145)
@@ -16,12 +16,11 @@
 $Id$
 
 import warnings
-from zope.configuration.exceptions import ConfigurationError
-from zope.app.component import contentdirective
+from zope.security import metaconfigure
 from App.class_init import InitializeClass
 from Products.Five.security import protectName
 
-class ClassDirective(contentdirective.ClassDirective):
+class ClassDirective(metaconfigure.ClassDirective):
 
 def __protectName(self, name, permission_id):
 self.__context.action(
@@ -30,14 +29,17 @@
 args = (self.__class, name, permission_id)
 )
 
-def __protectSetAttributes(self, attributes, permissions):
-raise ConfigurationError('set_attributes parameter not supported.')
+def __protectSetAttributes(self, names, permission_id):
+warnings.warn(The set_attribute option of the require / directive 
is not supported in Zope 2.  + \
+  Ignored for %s % str(self.__class), stacklevel=3)
 
-def __proctectSetSchema(self, schema, permission):
-raise ConfigurationError('set_schema parameter not supported.')
+def __protectSetSchema(self, schema, permission):
+warnings.warn(The set_schema option of the require / directive is 
not supported in Zope 2.  + \
+  Ignored for %s % str(self.__class), stacklevel=3)
 
 def __mimic(self, _context, class_):
-raise ConfigurationError('like_class parameter not supported.')
+warnings.warn(The like_class option of the require / directive is 
not supported in Zope 2.  + \
+  Ignored for %s % str(self.__class), stacklevel=3)
 
 def __call__(self):
 return self.__context.action(

Modified: Zope/trunk/src/Products/Five/tests/test_security.py
===
--- Zope/trunk/src/Products/Five/tests/test_security.py 2009-04-13 02:25:29 UTC 
(rev 99144)
+++ Zope/trunk/src/Products/Five/tests/test_security.py 2009-04-13 10:15:12 UTC 
(rev 99145)
@@ -18,6 +18,7 @@
 
 from zope.interface import implements
 from zope.interface import Interface
+from zope.schema import TextLine
 from AccessControl.SecurityInfo import ClassSecurityInfo
 
 class ISuperDummy(Interface):
@@ -51,6 +52,16 @@
 security.declarePrivate('baz')
 security.declareProtected('View management screens', 'keg')
 
+class IDummy3(Interface):
+attr = TextLine(title=uAttribute)
+
+class Dummy3:
+implements(IDummy3)
+attr = None
+
+class Dummy4:
+foo = None
+
 def test_security_equivalence():
 This test demonstrates that the traditional declarative security of
 Zope 2 can be replaced by ZCML statements without any loss of
@@ -219,6 +230,56 @@
tearDown()
 
 
+def test_set_warnings():
+This test demonstrates that set_attributes and set_schema will result
+in warnings, not errors. This type of protection doesn't make sense in
+Zope 2, but we want to be able to re-use pure Zope 3 packages that use
+them without error.
+
+   from zope.app.testing.placelesssetup import setUp, tearDown
+   setUp()
+
+Before we can make security declarations through ZCML, we need to
+register the directive and the permission:
+
+   import Products.Five
+   from Products.Five import zcml
+   zcml.load_config('meta.zcml', Products.Five)
+   zcml.load_config('permissions.zcml', Products.Five)
+
+Now we provide some ZCML declarations for ``Dummy1``:
+
+   configure_zcml = '''
+  ... configure xmlns=http://namespaces.zope.org/zope;
+  ...
+  ...   class 

[Zope-Checkins] SVN: Zope/trunk/ Let the permission / directive auto-register permissions that don't exist already

2009-04-13 Thread Martin Aspeli
Log message for revision 99146:
  Let the permission / directive auto-register permissions that don't exist 
already

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/Products/Five/permissions.zcml
  U   Zope/trunk/src/Products/Five/security.py
  U   Zope/trunk/src/Products/Five/tests/test_security.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2009-04-13 10:15:12 UTC (rev 99145)
+++ Zope/trunk/doc/CHANGES.rst  2009-04-13 10:46:06 UTC (rev 99146)
@@ -23,6 +23,12 @@
 Restructuring
 +
 
+- If the permission / ZCML directive is used to declare a permission that
+  does not exist, the permission will now be created automatically, defaulting
+  to being granted to the Manager role only. This means it is possible to
+  create new permissions using ZCML only. The permission will Permissions that
+  already exist will not be changed.
+
 - Using require set_schema=... / or require set_attributes=... / in
   the class / directive now emits a warning rather than an error. The
   concept of protecting attribute 'set' does not exist in Zope 2, but it

Modified: Zope/trunk/src/Products/Five/permissions.zcml
===
--- Zope/trunk/src/Products/Five/permissions.zcml   2009-04-13 10:15:12 UTC 
(rev 99145)
+++ Zope/trunk/src/Products/Five/permissions.zcml   2009-04-13 10:46:06 UTC 
(rev 99146)
@@ -1,6 +1,13 @@
 configure xmlns=http://namespaces.zope.org/zope;
i18n_domain=Five
 
+  !-- Create permissions declared in ZCML if they don't exist already --
+  subscriber
+for=zope.security.interfaces.IPermission
+ zope.component.interfaces.IRegistered
+handler=.security.create_permission_from_permission_directive
+/
+
   permission
   id=five.ManageSite
   title=Manage Five local sites

Modified: Zope/trunk/src/Products/Five/security.py
===
--- Zope/trunk/src/Products/Five/security.py2009-04-13 10:15:12 UTC (rev 
99145)
+++ Zope/trunk/src/Products/Five/security.py2009-04-13 10:46:06 UTC (rev 
99146)
@@ -34,7 +34,13 @@
 
 from AccessControl.SecurityInfo import ClassSecurityInfo
 from AccessControl.SecurityManagement import getSecurityManager
+from AccessControl.Permission import _registeredPermissions
+from AccessControl.Permission import pname
 
+import Products
+
+from Globals import ApplicationDefaultPermissions
+
 CheckerPublicId = 'zope.Public'
 CheckerPrivateId = 'zope2.Private'
 
@@ -155,3 +161,21 @@
 # Zope 2 uses string, not unicode yet
 perm = str(permission.title)
 security.declareObjectProtected(perm)
+
+def create_permission_from_permission_directive(permission, event):
+When a new IPermission utility is registered (via the permission /
+directive), create the equivalent Zope2 style permission.
+
+
+global _registeredPermissions
+
+zope2_permission = permission.title
+roles = ('Manager',)
+
+if not _registeredPermissions.has_key(zope2_permission):
+_registeredPermissions[zope2_permission] = 1
+
+Products.__ac_permissions__ += ((zope2_permission, (), roles,),)
+
+mangled = pname(zope2_permission)
+setattr(ApplicationDefaultPermissions, mangled, roles)

Modified: Zope/trunk/src/Products/Five/tests/test_security.py
===
--- Zope/trunk/src/Products/Five/tests/test_security.py 2009-04-13 10:15:12 UTC 
(rev 99145)
+++ Zope/trunk/src/Products/Five/tests/test_security.py 2009-04-13 10:46:06 UTC 
(rev 99146)
@@ -374,6 +374,76 @@
tearDown()
 
 
+def test_register_permission():
+This test demonstrates that if the permission / directive is used
+to create a permission that does not already exist, it is created on 
+startup, with roles defaulting to Manager.
+
+   from zope.app.testing.placelesssetup import setUp, tearDown
+   setUp()
+
+First, we need to configure the relevant parts of Five.
+
+   import Products.Five
+   from Products.Five import zcml
+   zcml.load_config('meta.zcml', Products.Five)
+   zcml.load_config('permissions.zcml', Products.Five)
+
+We can now register a permission in ZCML:
+
+   configure_zcml = '''
+  ... configure xmlns=http://namespaces.zope.org/zope;
+  ...
+  ...   permission
+  ...   id=Products.Five.tests.DummyPermission
+  ...   title=Five: Dummy permission
+  ...   /
+  ...
+  ... /configure
+  ... '''
+   zcml.load_string(configure_zcml)
+  
+The permission will be made available globally, with default role set
+of ('Manager',).
+  
+   from pprint import pprint
+   pprint(self.app.rolesOfPermission('Five: Dummy permission'))
+  [{'name': 'Anonymous', 'selected': ''},
+  

[Zope-Checkins] SVN: Zope/trunk/src/Zope2/Startup/zopectl.py de-convolute-ize zopectl run and make providing the correct sys.argv to the run script more robust.

2009-04-13 Thread Chris Withers
Log message for revision 99160:
  de-convolute-ize zopectl run and make providing the correct sys.argv to the 
run script more robust.
  

Changed:
  U   Zope/trunk/src/Zope2/Startup/zopectl.py

-=-
Modified: Zope/trunk/src/Zope2/Startup/zopectl.py
===
--- Zope/trunk/src/Zope2/Startup/zopectl.py 2009-04-13 19:36:57 UTC (rev 
99159)
+++ Zope/trunk/src/Zope2/Startup/zopectl.py 2009-04-13 20:58:49 UTC (rev 
99160)
@@ -256,18 +256,16 @@
 print debug -- run the Zope debugger to inspect your database
 print  manually using a Python interactive shell
 
-def do_run(self, arg):
-tup = arg.split(' ')
-if not arg:
+def do_run(self, args):
+if not args:
 print usage: run script [args]
 return
-# remove -c and add script as sys.argv[0]
-script = tup[0]
-cmd = 'import sys; sys.argv.pop(); sys.argv.append(\'%s\');'  % script
-if len(tup)  1:
-argv = tup[1:]
-cmd += '[sys.argv.append(x) for x in %s];' % argv
-cmd += 'import Zope2; app=Zope2.app(); execfile(\'%s\')' % script
+# replace sys.argv
+script = args.split(' ')[0]
+cmd = (
+import sys; sys.argv[:]=%r.split(' ');
+import Zope2; app=Zope2.app(); execfile(%r)
+) % (args,script)
 cmdline = self.get_startup_cmd(self.options.python, cmd)
 self._exitstatus = os.system(cmdline)
 

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins