[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ Collector #2157: Expose name of broken class in SystemError raised from

2006-07-23 Thread Tres Seaver
Log message for revision 69242:
  Collector #2157: Expose name of broken class in SystemError raised from
  '__getstate__' of a broken instance.
  
  

Changed:
  U   Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
  U   Zope/branches/Zope-2_8-branch/lib/python/OFS/Uninstalled.py
  A   Zope/branches/Zope-2_8-branch/lib/python/OFS/tests/test_Uninstalled.py

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2006-07-22 13:08:46 UTC 
(rev 69241)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2006-07-24 00:43:14 UTC 
(rev 69242)
@@ -4,6 +4,13 @@
   Change information for previous versions of Zope can be found in the
   file HISTORY.txt.
 
+  After Zope 2.8.8
+
+Bugs fixed
+
+  - Collector #2157: Expose name of broken class in SystemError raised
+from '__getstate__' of a broken instance.
+
   Zope 2.8.8 (2006/07/14)
 
 Bugs fixed

Modified: Zope/branches/Zope-2_8-branch/lib/python/OFS/Uninstalled.py
===
--- Zope/branches/Zope-2_8-branch/lib/python/OFS/Uninstalled.py 2006-07-22 
13:08:46 UTC (rev 69241)
+++ Zope/branches/Zope-2_8-branch/lib/python/OFS/Uninstalled.py 2006-07-24 
00:43:14 UTC (rev 69242)
@@ -38,7 +38,7 @@
 raise SystemError, (
 This object was originally created by a product that
 is no longer installed.  It cannot be updated.
-)
+(%s) % repr(self))
 
 def __getattr__(self, name):
 if name[:3]=='_p_':

Added: Zope/branches/Zope-2_8-branch/lib/python/OFS/tests/test_Uninstalled.py
===
--- Zope/branches/Zope-2_8-branch/lib/python/OFS/tests/test_Uninstalled.py  
2006-07-22 13:08:46 UTC (rev 69241)
+++ Zope/branches/Zope-2_8-branch/lib/python/OFS/tests/test_Uninstalled.py  
2006-07-24 00:43:14 UTC (rev 69242)
@@ -0,0 +1,132 @@
+##
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+#
+##
+
+import unittest
+
+class TestsOfBroken(unittest.TestCase):
+Tests for the factory for broken classes.
+
+
+def setUp(self):
+from OFS.Uninstalled import broken_klasses
+from OFS.Uninstalled import broken_klasses_lock
+self.broken_klasses_OLD = {}
+broken_klasses_lock.acquire()
+try:
+self.broken_klasses_OLD.update(broken_klasses)
+broken_klasses.clear()
+finally:
+broken_klasses_lock.release()
+
+def tearDown(self):
+from OFS.Uninstalled import broken_klasses
+from OFS.Uninstalled import broken_klasses_lock
+broken_klasses_lock.acquire()
+try:
+broken_klasses.clear()
+broken_klasses.update(self.broken_klasses_OLD)
+finally:
+broken_klasses_lock.release()
+
+def test_Broken_non_product_no_oid_yields_class_derived_from_Broken(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+
+klass = Broken(self, None, ('some.python.module', 'MyClass'))
+
+self.failUnless(issubclass(klass, BrokenClass))
+self.assertEqual(klass.__name__, 'MyClass')
+self.assertEqual(klass.__module__, 'some.python.module')
+self.assertEqual(klass.product_name, 'unknown')
+
+def test_Broken_product_no_oid_yields_class_derived_from_Broken(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+
+klass = Broken(self, None, ('Products.MyProduct.MyClass', 'MyClass'))
+
+self.failUnless(issubclass(klass, BrokenClass))
+self.assertEqual(klass.__name__, 'MyClass')
+self.assertEqual(klass.__module__, 'Products.MyProduct.MyClass')
+self.assertEqual(klass.product_name, 'MyProduct')
+
+def test_Broken_product_with_oid_yields_instance_derived_from_Broken(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+OID = '\x01' * 8
+
+inst = Broken(self, OID, ('Products.MyProduct.MyClass', 'MyClass'))
+
+self.failUnless(isinstance(inst, BrokenClass))
+self.failUnless(inst._p_jar is self)
+self.assertEqual(inst._p_oid, OID)
+
+klass = inst.__class__
+self.assertEqual(klass.__name__, 

[Zope-Checkins] SVN: Zope/branches/2.9/ Forward-port fix and tests for issue #2157 from 2.8 branch.

2006-07-23 Thread Tres Seaver
Log message for revision 69243:
  Forward-port fix and tests for issue #2157 from 2.8 branch.

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/OFS/Uninstalled.py

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2006-07-24 00:43:14 UTC (rev 69242)
+++ Zope/branches/2.9/doc/CHANGES.txt   2006-07-24 00:47:26 UTC (rev 69243)
@@ -18,6 +18,9 @@
 
Bugs fixed
 
+  - Collector #2157: Expose name of broken class in SystemError raised
+from '__getstate__' of a broken instance.
+
   - Usage of 'urljoin' in 'webdav.davcmds' could lead to wrongly
 constructed urls.
 

Modified: Zope/branches/2.9/lib/python/OFS/Uninstalled.py
===
--- Zope/branches/2.9/lib/python/OFS/Uninstalled.py 2006-07-24 00:43:14 UTC 
(rev 69242)
+++ Zope/branches/2.9/lib/python/OFS/Uninstalled.py 2006-07-24 00:47:26 UTC 
(rev 69243)
@@ -40,7 +40,7 @@
 raise SystemError, (
 This object was originally created by a product that
 is no longer installed.  It cannot be updated.
-)
+(%s) % repr(self))
 
 def __getattr__(self, name):
 if name[:3]=='_p_':

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


[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/OFS/tests/test_Uninstalled.py Omitted test module for issue #2157.

2006-07-23 Thread Tres Seaver
Log message for revision 69244:
  Omitted test module for issue #2157.

Changed:
  A   Zope/branches/2.9/lib/python/OFS/tests/test_Uninstalled.py

-=-
Added: Zope/branches/2.9/lib/python/OFS/tests/test_Uninstalled.py
===
--- Zope/branches/2.9/lib/python/OFS/tests/test_Uninstalled.py  2006-07-24 
00:47:26 UTC (rev 69243)
+++ Zope/branches/2.9/lib/python/OFS/tests/test_Uninstalled.py  2006-07-24 
00:50:17 UTC (rev 69244)
@@ -0,0 +1,132 @@
+##
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+#
+##
+
+import unittest
+
+class TestsOfBroken(unittest.TestCase):
+Tests for the factory for broken classes.
+
+
+def setUp(self):
+from OFS.Uninstalled import broken_klasses
+from OFS.Uninstalled import broken_klasses_lock
+self.broken_klasses_OLD = {}
+broken_klasses_lock.acquire()
+try:
+self.broken_klasses_OLD.update(broken_klasses)
+broken_klasses.clear()
+finally:
+broken_klasses_lock.release()
+
+def tearDown(self):
+from OFS.Uninstalled import broken_klasses
+from OFS.Uninstalled import broken_klasses_lock
+broken_klasses_lock.acquire()
+try:
+broken_klasses.clear()
+broken_klasses.update(self.broken_klasses_OLD)
+finally:
+broken_klasses_lock.release()
+
+def test_Broken_non_product_no_oid_yields_class_derived_from_Broken(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+
+klass = Broken(self, None, ('some.python.module', 'MyClass'))
+
+self.failUnless(issubclass(klass, BrokenClass))
+self.assertEqual(klass.__name__, 'MyClass')
+self.assertEqual(klass.__module__, 'some.python.module')
+self.assertEqual(klass.product_name, 'unknown')
+
+def test_Broken_product_no_oid_yields_class_derived_from_Broken(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+
+klass = Broken(self, None, ('Products.MyProduct.MyClass', 'MyClass'))
+
+self.failUnless(issubclass(klass, BrokenClass))
+self.assertEqual(klass.__name__, 'MyClass')
+self.assertEqual(klass.__module__, 'Products.MyProduct.MyClass')
+self.assertEqual(klass.product_name, 'MyProduct')
+
+def test_Broken_product_with_oid_yields_instance_derived_from_Broken(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+OID = '\x01' * 8
+
+inst = Broken(self, OID, ('Products.MyProduct.MyClass', 'MyClass'))
+
+self.failUnless(isinstance(inst, BrokenClass))
+self.failUnless(inst._p_jar is self)
+self.assertEqual(inst._p_oid, OID)
+
+klass = inst.__class__
+self.assertEqual(klass.__name__, 'MyClass')
+self.assertEqual(klass.__module__, 'Products.MyProduct.MyClass')
+self.assertEqual(klass.product_name, 'MyProduct')
+
+def test_Broken_instance___getstate___raises_useful_exception(self):
+# see http://www.zope.org/Collectors/Zope/2157
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+OID = '\x01' * 8
+
+inst = Broken(self, OID, ('Products.MyProduct.MyClass', 'MyClass'))
+
+try:
+dict = inst.__getstate__()
+except SystemError, e:
+self.failUnless('MyClass' in str(e), str(e))
+else:
+self.fail('__getstate__' didn't raise SystemError!)
+
+def test_Broken_instance___getattr___allows_persistence_attrs(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+OID = '\x01' * 8
+PERSISTENCE_ATTRS = [_p_changed,
+ _p_jar,
+ _p_mtime,
+ _p_oid,
+ _p_serial,
+ _p_state,
+]
+PERSISTENCE_METHODS = [_p_deactivate,
+   _p_activate,
+   _p_invalidate,
+   _p_getattr,
+   _p_setattr,
+   _p_delattr,
+  ]
+
+inst = Broken(self, OID, 

[Zope-Checkins] SVN: Zope/trunk/ Forward-port fix and tests for issue #2157 from 2.8 branch.

2006-07-23 Thread Tres Seaver
Log message for revision 69246:
  Forward-port fix and tests for issue #2157 from 2.8 branch.

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/OFS/Uninstalled.py
  A   Zope/trunk/lib/python/OFS/tests/test_Uninstalled.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2006-07-24 01:00:22 UTC (rev 69245)
+++ Zope/trunk/doc/CHANGES.txt  2006-07-24 01:27:17 UTC (rev 69246)
@@ -39,6 +39,9 @@
 
 Bugs Fixed
 
+  - Collector #2157: Expose name of broken class in SystemError raised
+from '__getstate__' of a broken instance.
+
   - Usage of 'urljoin' in 'webdav.davcmds' could lead to wrongly
 constructed urls.
 

Modified: Zope/trunk/lib/python/OFS/Uninstalled.py
===
--- Zope/trunk/lib/python/OFS/Uninstalled.py2006-07-24 01:00:22 UTC (rev 
69245)
+++ Zope/trunk/lib/python/OFS/Uninstalled.py2006-07-24 01:27:17 UTC (rev 
69246)
@@ -40,7 +40,7 @@
 raise SystemError, (
 This object was originally created by a product that
 is no longer installed.  It cannot be updated.
-)
+(%s) % repr(self))
 
 def __getattr__(self, name):
 if name[:3]=='_p_':

Added: Zope/trunk/lib/python/OFS/tests/test_Uninstalled.py
===
--- Zope/trunk/lib/python/OFS/tests/test_Uninstalled.py 2006-07-24 01:00:22 UTC 
(rev 69245)
+++ Zope/trunk/lib/python/OFS/tests/test_Uninstalled.py 2006-07-24 01:27:17 UTC 
(rev 69246)
@@ -0,0 +1,132 @@
+##
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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.
+#
+##
+
+import unittest
+
+class TestsOfBroken(unittest.TestCase):
+Tests for the factory for broken classes.
+
+
+def setUp(self):
+from OFS.Uninstalled import broken_klasses
+from OFS.Uninstalled import broken_klasses_lock
+self.broken_klasses_OLD = {}
+broken_klasses_lock.acquire()
+try:
+self.broken_klasses_OLD.update(broken_klasses)
+broken_klasses.clear()
+finally:
+broken_klasses_lock.release()
+
+def tearDown(self):
+from OFS.Uninstalled import broken_klasses
+from OFS.Uninstalled import broken_klasses_lock
+broken_klasses_lock.acquire()
+try:
+broken_klasses.clear()
+broken_klasses.update(self.broken_klasses_OLD)
+finally:
+broken_klasses_lock.release()
+
+def test_Broken_non_product_no_oid_yields_class_derived_from_Broken(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+
+klass = Broken(self, None, ('some.python.module', 'MyClass'))
+
+self.failUnless(issubclass(klass, BrokenClass))
+self.assertEqual(klass.__name__, 'MyClass')
+self.assertEqual(klass.__module__, 'some.python.module')
+self.assertEqual(klass.product_name, 'unknown')
+
+def test_Broken_product_no_oid_yields_class_derived_from_Broken(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+
+klass = Broken(self, None, ('Products.MyProduct.MyClass', 'MyClass'))
+
+self.failUnless(issubclass(klass, BrokenClass))
+self.assertEqual(klass.__name__, 'MyClass')
+self.assertEqual(klass.__module__, 'Products.MyProduct.MyClass')
+self.assertEqual(klass.product_name, 'MyProduct')
+
+def test_Broken_product_with_oid_yields_instance_derived_from_Broken(self):
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import BrokenClass
+OID = '\x01' * 8
+
+inst = Broken(self, OID, ('Products.MyProduct.MyClass', 'MyClass'))
+
+self.failUnless(isinstance(inst, BrokenClass))
+self.failUnless(inst._p_jar is self)
+self.assertEqual(inst._p_oid, OID)
+
+klass = inst.__class__
+self.assertEqual(klass.__name__, 'MyClass')
+self.assertEqual(klass.__module__, 'Products.MyProduct.MyClass')
+self.assertEqual(klass.product_name, 'MyProduct')
+
+def test_Broken_instance___getstate___raises_useful_exception(self):
+# see http://www.zope.org/Collectors/Zope/2157
+from OFS.Uninstalled import Broken
+from OFS.Uninstalled import 

[Zope-dev] buildbot failure in Zope trunk 2.4 Windows 2000 zc-bbwin6

2006-07-23 Thread buildbot
The Buildbot has detected a failed build of Zope trunk 2.4 Windows 2000 
zc-bbwin6.

Buildbot URL: http://buildbot.zope.org/

Build Reason: changes
Build Source Stamp: 6737
Blamelist: 
baijum,benji,benji_york,ctheune,dobe,frerich,hdima,rocky,sidnei,tseaver,yuppie

BUILD FAILED: failed compile

sincerely,
 -The Buildbot

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope] accessing object from a list constructed in __init__.py

2006-07-23 Thread Alexis Roda

En/na kevin7kal ha escrit:

Ok, thank you for that.
I can create the list of objects from the __of__(self) attribute without 
the wrapper error now,

but I still cannot access that attribute through zope.
Here is my code again, along with my zope content.


Another thing I've missed, class1 isn't persistent, but you store 
instances in Zclass2.attribute1a. This can explain the can't pickle error.




HTH
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] accessing object from a list constructed in __init__.py

2006-07-23 Thread kevin7kal
I've changed my code a bit, adding the docstring, Persistent to all 
classes and
__allow_access_to_unprotected_attributes__ = 1 to all classes.  Still, I 
recieve the same error.


I have changed the code so _attribute1a is a single instance of class1 
instead of a list of  containing multiple instances of class1 and I can 
access the attributes of the object without issue.
Are the objects automatically unwrapped when added to a list?  is there 
a way around this?

I can send the code again if need be.

so here is the code again, this time with only the single object in 
attribute1a.

--myClass.py--
import Acquisition
from persistent import Persistent

class class1(Acquisition.Explicit,Persistent):
   ''' a simple class with some attributes and methods'''
   __allow_access_to_unprotected_attributes__ = 1
   attribute1 = 'attribute 1'
   attribute2 = 'attribute 2'
   _number = ''
   def __init__(self,number2):
   '''simple init for the class'''
   self._number=number2*3
  
   def method1(self):

   '''return a string methd1'''
   mthd1 =  'methd1'
   return mthd1
   def method2(self):
   ''' return a string methd2'''
   mthd2 = 'method2'
   return mthd2
   def _get_number(self):
   return self._number
   number = property(fget=_get_number)

class class2(Acquisition.Explicit,Persistent):

   ''' a second simple class with some attributes and methods'''
   __allow_access_to_unprotected_attributes__ = 1
   _attribute1a = []
   attribute2a = []
   def __init__(self):
   '''create a list of class1 objects in attribute1a'''
   #i=1
   #while i  5:
   #obj = class1(i)
   #self._attribute1a.append(obj)
   #i=i+1
   self._attribute1a = class1(5)
   def method1a(self):
   '''instantiate class1 as object and return object usable by zope'''
   obj = class1(5)
   return obj.__of__(self)
   def method2a(self):
   '''returns class1.method1()'''
   c1m1 = class1.method1()
   return c1m1
   def get_attribute1a(self):
   #if self._attribute1a != []:
   #i = len(self._attribute1a)
   #j = 0
   #while j != i-1:
   #self._attribute1a[j] = self._attribute1a[j].__of__(self)
   #j = j+1
   #else:
   obj = self._attribute1a
   return obj.__of__(self)
   attribute1a = property(fget=get_attribute1a)
   attribute1b = property(fget=method1a)
   attribute2b = property(fget=method2a)



Alexis Roda wrote:

En/na kevin7kal ha escrit:

Ok, thank you for that.
I can create the list of objects from the __of__(self) attribute 
without the wrapper error now,

but I still cannot access that attribute through zope.
Here is my code again, along with my zope content.


Another thing I've missed, class1 isn't persistent, but you store 
instances in Zclass2.attribute1a. This can explain the can't pickle 
error.




HTH
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] accessing object from a list constructed in __init__.py

2006-07-23 Thread kevin7kal

The traceback and 'offending' code.
Traceback (innermost last):
 Module ZPublisher.Publish, line 115, in publish
 Module ZPublisher.mapply, line 88, in mapply
 Module ZPublisher.Publish, line 41, in call_object
 Module Shared.DC.Scripts.Bindings, line 311, in __call__
 Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
 Module Products.PythonScripts.PythonScript, line 323, in _exec
 Module None, line 7, in AMyZClass2
  - PythonScript at /AMyZClass2
  - Line 7
Unauthorized: You are not allowed to access 'number' in this context

--Script(Python)--
MZ = context.Zclass2.myZclass()
M2 = MZ.attribute1a
print MZ
print M2[0].number
return printed

kevin7kal wrote:
I've changed my code a bit, adding the docstring, Persistent to all 
classes and
__allow_access_to_unprotected_attributes__ = 1 to all classes.  Still, 
I recieve the same error.


I have changed the code so _attribute1a is a single instance of class1 
instead of a list of  containing multiple instances of class1 and I 
can access the attributes of the object without issue.
Are the objects automatically unwrapped when added to a list?  is 
there a way around this?

I can send the code again if need be.

so here is the code again, this time with only the single object in 
attribute1a.

--myClass.py--
import Acquisition
from persistent import Persistent

class class1(Acquisition.Explicit,Persistent):
   ''' a simple class with some attributes and methods'''
   __allow_access_to_unprotected_attributes__ = 1
   attribute1 = 'attribute 1'
   attribute2 = 'attribute 2'
   _number = ''
   def __init__(self,number2):
   '''simple init for the class'''
   self._number=number2*3
 def method1(self):
   '''return a string methd1'''
   mthd1 =  'methd1'
   return mthd1
   def method2(self):
   ''' return a string methd2'''
   mthd2 = 'method2'
   return mthd2
   def _get_number(self):
   return self._number
   number = property(fget=_get_number)
class class2(Acquisition.Explicit,Persistent):
   ''' a second simple class with some attributes and methods'''
   __allow_access_to_unprotected_attributes__ = 1
   _attribute1a = []
   attribute2a = []
   def __init__(self):
   '''create a list of class1 objects in attribute1a'''
   #i=1
   #while i  5:
   #obj = class1(i)
   #self._attribute1a.append(obj)
   #i=i+1
   self._attribute1a = class1(5)
   def method1a(self):
   '''instantiate class1 as object and return object usable by 
zope'''

   obj = class1(5)
   return obj.__of__(self)
   def method2a(self):
   '''returns class1.method1()'''
   c1m1 = class1.method1()
   return c1m1
   def get_attribute1a(self):
   #if self._attribute1a != []:
   #i = len(self._attribute1a)
   #j = 0
   #while j != i-1:
   #self._attribute1a[j] = self._attribute1a[j].__of__(self)
   #j = j+1
   #else:
   obj = self._attribute1a
   return obj.__of__(self)
   attribute1a = property(fget=get_attribute1a)
   attribute1b = property(fget=method1a)
   attribute2b = property(fget=method2a)



Alexis Roda wrote:

En/na kevin7kal ha escrit:

Ok, thank you for that.
I can create the list of objects from the __of__(self) attribute 
without the wrapper error now,

but I still cannot access that attribute through zope.
Here is my code again, along with my zope content.


Another thing I've missed, class1 isn't persistent, but you store 
instances in Zclass2.attribute1a. This can explain the can't pickle 
error.




HTH
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] accessing object from a list constructed in __init__.py

2006-07-23 Thread Alexis Roda

En/na kevin7kal ha escrit:
I've changed my code a bit, adding the docstring, Persistent to all 
classes and
__allow_access_to_unprotected_attributes__ = 1 to all classes.  Still, I 
recieve the same error.


Sorry, my fault, should be __allow_access_to_unprotected_subobjects__. 
If it does work then add the security declarations.




HTH
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] accessing object from a list constructed in __init__.py

2006-07-23 Thread kevin7kal

That did not work for me either.
It was also suggested that I try inheriting from folder rather than
re-inventing folder.
Still no dice.
I think there is something that I don't understand about acquisition and
context.  Why can an object be placed into context if it is stored as a
simple attribute of another object, but not if it is an element in a
list?  Or what must be done differently when the objects are elements in
a list?



Alexis Roda wrote:

En/na kevin7kal ha escrit:
I've changed my code a bit, adding the docstring, Persistent to all 
classes and
__allow_access_to_unprotected_attributes__ = 1 to all classes.  
Still, I recieve the same error.


Sorry, my fault, should be __allow_access_to_unprotected_subobjects__. 
If it does work then add the security declarations.




HTH
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: accessing object from a list constructed in __init__.py

2006-07-23 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

kevin7kal wrote:
 That did not work for me either.
 It was also suggested that I try inheriting from folder rather than
 re-inventing folder.
 Still no dice.
 I think there is something that I don't understand about acquisition and
 context.  Why can an object be placed into context if it is stored as a
 simple attribute of another object, but not if it is an element in a
 list?  Or what must be done differently when the objects are elements in
 a list?

The piece of the picture you are missing is that the magic of
acquisition happens in the 'getattr' hook:  acquisition-aware objects
create the wrapper (via '__of__') for objects fetched from them via
attribute access.

Containers which want to provide the same semantics for 'getitem' access
have to call '__of__' directly themselves.  For objects derived from
OFS.ObjectManager, that responsibility is delegated to the '_getOb'
method.  Standard folders store their items as attributes, and so their
'_getOb' doesn't have to do anything special::

def _getOb(self, id, default=_marker):
if id[:1] != '_' and hasattr(aq_base(self), id):
return getattr(self, id)
if default is _marker:
raise AttributeError, id
return default

A BTreeFolder, however, does not store items as attributes;  its
'_getOb' looks like::

def _getOb(self, id, default=_marker):
Return the named object from the folder.

tree = self._tree
if default is _marker:
ob = tree[id]
return ob.__of__(self)
else:
ob = tree.get(id, _marker)
if ob is _marker:
return default
else:
return ob.__of__(self)


Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   Excellence by Designhttp://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFExAHA+gerLs4ltQ4RAhl5AJwJkRws7ISOvGUt0XP3++opMp3H9ACgiCGQ
n41bgMeDpOE/VCI/EBJ/j3M=
=ZmGA
-END PGP SIGNATURE-

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


RE: [Zope] Script execute with every request

2006-07-23 Thread Joshua Burvill








Ok, so I could put a dtml-call   into
my standard_html_header, and any redirects do them with a call to Dieters
script (which may not work with future zope versions) to make sure I am keeping
the original request.



Hmm, is there a better solution anyone knows of? 



Basically I just want to do an insert into a database
of some stuff from each request.



Josh











From: David H [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 19 July 2006
11:27 AM
To: Joshua Burvill
Cc: zope@zope.org
Subject: Re: [Zope] Script execute
with every request





Joshua Burvill wrote: 

Hi,



Id like to log certain parts of each request
into a database table for every request to provide an audit trail.



I thought of inserting a dtml-call xxx
into the standard_html_header, but when there is a RESPONSE.redirect, it will
not be the original request that gets logged.



Can anyone offer any suggestions?



Thanks, Josh



Dieter wrote this 

http://www.dieter.handshake.de/pyprojects/zope/emulateRedirect.py

Maybe that helps. 








--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.1/391 - Release Date: 18/07/2006
 

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.3/395 - Release Date: 21/07/2006
 
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )