summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Fulton <jim@zope.com>2002-06-13 23:15:46 +0000
committerJim Fulton <jim@zope.com>2002-06-13 23:15:46 +0000
commitbaa7e23fcf0f0466277216aa167d7ede613de67a (patch)
tree5e6bb228d6e3b779dd550822d2e7c580a98c2956
parent9477e5b0825355d9bfe242b00e6b1a56060183f4 (diff)
downloadzope-traversing-baa7e23fcf0f0466277216aa167d7ede613de67a.tar.gz
Got icons working, and, along the way:
- Implemented the icon directive - Implemented http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/ResourcesProposal - Added a special view, named '', for service manager containers that allows resources to have URLs like: http://foo.com/@@/resourcename - Fixed some server code that caused HTTP response data to get promoted to unicode - Updated the folder contents page to display icons. - Ported icons for folder, file, image, and zptpage. Many more icons need to be ported or created.
-rw-r--r--GetResource.py36
-rw-r--r--PresentationNamespaces.py13
2 files changed, 46 insertions, 3 deletions
diff --git a/GetResource.py b/GetResource.py
new file mode 100644
index 0000000..bca4f9e
--- /dev/null
+++ b/GetResource.py
@@ -0,0 +1,36 @@
+##############################################################################
+#
+# Copyright (c) 2002 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.
+#
+##############################################################################
+"""
+
+$Id: GetResource.py,v 1.1 2002/06/13 23:15:44 jim Exp $
+"""
+
+from Zope.ComponentArchitecture import getService
+from Zope.Exceptions import NotFoundError
+from Zope.Proxy.ContextWrapper import ContextWrapper
+
+def getResource(ob, name, request):
+ resource = queryResource(ob, name, request)
+ if resource is None:
+ raise NotFoundError(ob, name)
+ return resource
+
+def queryResource(ob, name, request, default=None):
+ resource_service = getService(ob, 'Resources')
+ resource = resource_service.queryResource(ob, name, request)
+ if resource is None:
+ return default
+ return ContextWrapper(resource, resource_service, name=name)
+
+
diff --git a/PresentationNamespaces.py b/PresentationNamespaces.py
index 99dd451..f753209 100644
--- a/PresentationNamespaces.py
+++ b/PresentationNamespaces.py
@@ -13,13 +13,15 @@
##############################################################################
"""
-$Id: PresentationNamespaces.py,v 1.2 2002/06/10 23:28:17 jim Exp $
+$Id: PresentationNamespaces.py,v 1.3 2002/06/13 23:15:44 jim Exp $
"""
-from Zope.ComponentArchitecture import getView, getResource
+from Zope.ComponentArchitecture import getView
from Namespaces import provideNamespaceHandler
from Exceptions import UnexpectedParameters
from Zope.Exceptions import NotFoundError
+from Zope.Proxy.ContextWrapper import ContextWrapper
+from GetResource import queryResource
class NoRequest(NotFoundError):
"""Atempt to access a presentation component outside of a request context
@@ -39,7 +41,12 @@ def resource(name, parameters, pname, ob, request):
raise UnexpectedParameters(parameters)
if not request:
raise NoRequest(pname)
- return getResource(ob, name, request)
+
+ resource = queryResource(ob, name, request)
+ if resource is None:
+ raise NotFoundError(ob, pname)
+
+ return resource
provideNamespaceHandler('resource', resource)