[Checkins] SVN: z3c.jsontree/trunk/ - Fix: use imports from newest packages e.g. zope.site.folder.Folder

Roger Ineichen roger at projekt01.ch
Mon Mar 9 23:13:44 EDT 2009


Log message for revision 97773:
  - Fix: use imports from newest packages e.g. zope.site.folder.Folder
  - Fix: be smart to NotFound error objects. NotFound errors are not locatable.
  - update tests, added missing IAbsoluteURL adapter which is gone by default

Changed:
  U   z3c.jsontree/trunk/CHANGES.txt
  U   z3c.jsontree/trunk/src/z3c/jsontree/README.txt
  U   z3c.jsontree/trunk/src/z3c/jsontree/browser/tests/test_view.py
  U   z3c.jsontree/trunk/src/z3c/jsontree/util.py

-=-
Modified: z3c.jsontree/trunk/CHANGES.txt
===================================================================
--- z3c.jsontree/trunk/CHANGES.txt	2009-03-10 02:17:30 UTC (rev 97772)
+++ z3c.jsontree/trunk/CHANGES.txt	2009-03-10 03:13:43 UTC (rev 97773)
@@ -5,12 +5,14 @@
 Version 0.5.1dev (unreleased)
 -----------------------------
 
-- ...
+- Fix: use imports from newest packages e.g. zope.site.folder.Folder
 
+- Fix: be smart to NotFound error objects. NotFound errors are not locatable.
+
 Version 0.5.0 (2008-04-16)
 --------------------------
 
-- bugfix: adjust ITreeItems adapter. Added additional discriminator which 
+- Fix: adjust ITreeItems adapter. Added additional discriminator which 
   prevents to get missused as /@@/ adapter if configured with base registry
 
 - implemented ITreeItems adapter which is responsible for list all items listed

Modified: z3c.jsontree/trunk/src/z3c/jsontree/README.txt
===================================================================
--- z3c.jsontree/trunk/src/z3c/jsontree/README.txt	2009-03-10 02:17:30 UTC (rev 97772)
+++ z3c.jsontree/trunk/src/z3c/jsontree/README.txt	2009-03-10 03:13:43 UTC (rev 97773)
@@ -23,12 +23,30 @@
 
 Now we will setup some content structure based on the default zope folder class:
 
-  >>> from zope.app.folder.folder import Folder
+  >>> from zope.site.folder import Folder
   >>> site  = getRootFolder()
   >>> content = Folder()
   >>> site['content'] = content
 
+And we need to be able to get an absoluteURL for the form:
 
+  >>> import zope.interface
+  >>> import zope.component
+  >>> from zope.location.interfaces import ILocation
+  >>> from zope.traversing.browser.interfaces import IAbsoluteURL
+  >>> class FakeURL(object):
+  ...     zope.interface.implements(IAbsoluteURL)
+  ...     zope.component.adapts(ILocation, zope.interface.Interface)
+  ...     def __init__(self, context, request):
+  ...         pass
+  ...     def __str__(self):
+  ...         return u'http://fake/url'
+  ...     def __call__(self):
+  ...         return str(self)
+
+  >>> zope.component.provideAdapter(FakeURL)
+
+
 JSON-RPC proxy
 --------------
 
@@ -46,10 +64,12 @@
   >>> proxy.loadJSONTreeItems('z3cJSONTree')
   {u'treeChilds': {u'childs':
   [{u'hasChilds': False,
-    u'contextURL': u'http://localhost/++skin++JSONRPCTestSkin/content',
-    u'url': u'http://localhost/++skin++JSONRPCTestSkin/content/@@SelectedManagementView.html',
-    u'linkHandler': u'', u'content': u'content', u'iconURL': u'', u'id':
-    u'z3cJSONTree.::content'}],
+    u'contextURL': u'http://fake/url',
+    u'url': u'http://fake/url/@@SelectedManagementView.html',
+    u'linkHandler': u'',
+    u'content': u'content',
+    u'iconURL': u'',
+    u'id': u'z3cJSONTree.::content'}],
     u'id': u'z3cJSONTree'}}
 
 The content object has no items and returns some empty JSON data:

Modified: z3c.jsontree/trunk/src/z3c/jsontree/browser/tests/test_view.py
===================================================================
--- z3c.jsontree/trunk/src/z3c/jsontree/browser/tests/test_view.py	2009-03-10 02:17:30 UTC (rev 97772)
+++ z3c.jsontree/trunk/src/z3c/jsontree/browser/tests/test_view.py	2009-03-10 03:13:43 UTC (rev 97773)
@@ -25,7 +25,7 @@
 from zope.pagetemplate.tests.util import check_xml
 from zope.publisher.browser import TestRequest
 from zope.app.component import testing
-from zope.app.folder import Folder
+from zope.site.folder import Folder
 
 from z3c.testing import TestCase
 from z3c.jsontree.browser.tests import util

Modified: z3c.jsontree/trunk/src/z3c/jsontree/util.py
===================================================================
--- z3c.jsontree/trunk/src/z3c/jsontree/util.py	2009-03-10 02:17:30 UTC (rev 97772)
+++ z3c.jsontree/trunk/src/z3c/jsontree/util.py	2009-03-10 03:13:43 UTC (rev 97773)
@@ -35,12 +35,15 @@
 
 def isChildOf(child, parent):
     """Check if object is a child of the parent."""
-    if parent in api.getParents(child):
-        return True
-    else:
+    try:
+        if parent in api.getParents(child):
+            return True
+        else:
+            return False
+    except TypeError, e:
+        # could be a not locatable NotFound object
         return False
 
-
 def getParentsFromContextToObject(context, obj):
     """Returns a list starting with the given context's parent followed by
     each of its parents till we reach the object.



More information about the Checkins mailing list