[Erp5-report] r10692 - in /erp5/trunk/products/ZSQLCatalog: ./ Extensions/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Oct 13 11:31:43 CEST 2006
Author: yo
Date: Fri Oct 13 11:31:42 2006
New Revision: 10692
URL: http://svn.erp5.org?rev=10692&view=rev
Log:
Move zsqlbrain to Extensions, so that we do not have to use the top-level Extensions directory.
Added:
erp5/trunk/products/ZSQLCatalog/Extensions/
erp5/trunk/products/ZSQLCatalog/Extensions/__init__.py
erp5/trunk/products/ZSQLCatalog/Extensions/zsqlbrain.py
Modified:
erp5/trunk/products/ZSQLCatalog/zsqlbrain.py
Added: erp5/trunk/products/ZSQLCatalog/Extensions/__init__.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/Extensions/__init__.py?rev=10692&view=auto
==============================================================================
(empty)
Added: erp5/trunk/products/ZSQLCatalog/Extensions/zsqlbrain.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/Extensions/zsqlbrain.py?rev=10692&view=auto
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/Extensions/zsqlbrain.py (added)
+++ erp5/trunk/products/ZSQLCatalog/Extensions/zsqlbrain.py Fri Oct 13 11:31:42 2006
@@ -1,0 +1,107 @@
+##############################################################################
+#
+# Copyright (c) 2002 Nexedi SARL. All Rights Reserved.
+# Copyright (c) 2001 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 string
+import Acquisition
+import sys
+from ZODB.POSException import ConflictError
+
+from AccessControl import ClassSecurityInfo
+from AccessControl.SecurityInfo import allow_class
+
+from zLOG import LOG
+
+class ZSQLBrain(Acquisition.Implicit):
+ security = ClassSecurityInfo()
+ security.declareObjectPublic()
+
+ def _aq_dynamic(self, name):
+ """Acquire an attribute from a real object.
+ """
+ if name.startswith('__') :
+ return None
+ o = self.getObject()
+ return getattr(o, name, None)
+
+ def getURL(self):
+ return self.path
+
+ def getUrl(self):
+ return self.path
+
+ def getPath(self):
+ return self.path
+
+ def getUid(self):
+ return self.uid
+
+ getRID = getUid
+
+ def getObject(self, REQUEST=None):
+ """Try to return the object for this record"""
+ if 'path' not in dir(self) and 'PATH' not in dir(self):
+ raise ValueError, "Unable to getObject from ZSQLBrain if ZSQL Method "\
+ "does not retrieves the `path` column from catalog table."
+ try:
+ obj = self.aq_parent.unrestrictedTraverse(self.getPath())
+ if obj is None:
+ if REQUEST is None:
+ REQUEST = self.REQUEST
+ obj = self.aq_parent.portal_catalog.resolve_url(
+ self.getPath(), REQUEST)
+ return obj
+ except ConflictError:
+ raise
+ except:
+ LOG("ZCatalog WARNING", 0,
+ "Could not access object path %s" % self.getPath(),
+ error=sys.exc_info() )
+ return None
+
+ def absolute_url(self, relative=0):
+ """
+ Default method used to return the path stored in the Catalog.
+ However, if virtual hosting is implemented, we must return
+ a value which is compatible with the standard absolute_url
+ behaviour
+
+ And if absolute_url is invoked within a Web Site,
+ additional Web Site behaviour is required
+
+ Implementation of absolute_url therefore consists in using
+ physicalPathToURL defined in the REQUEST so that absolute_url
+ is consistent with HTTPRequest implementation.
+ """
+ return self.REQUEST.physicalPathToURL(self.path, relative=relative)
+
+ def resolve_url(self, path, REQUEST):
+ """
+ Taken from ZCatalog
+
+ Attempt to resolve a url into an object in the Zope
+ namespace. The url may be absolute or a catalog path
+ style url. If no object is found, None is returned.
+ No exceptions are raised.
+ """
+ script=REQUEST.script
+ if string.find(path, script) != 0:
+ path='%s/%s' % (script, path)
+ try:
+ return REQUEST.resolve_url(path)
+ except ConflictError:
+ raise
+ except:
+ pass
+
+allow_class(ZSQLBrain)
Modified: erp5/trunk/products/ZSQLCatalog/zsqlbrain.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/zsqlbrain.py?rev=10692&r1=10691&r2=10692&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/zsqlbrain.py (original)
+++ erp5/trunk/products/ZSQLCatalog/zsqlbrain.py Fri Oct 13 11:31:42 2006
@@ -1,7 +1,6 @@
##############################################################################
#
-# Copyright (c) 2002 Nexedi SARL. All Rights Reserved.
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+# Copyright (c) 2006 Nexedi SARL. 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.
@@ -12,96 +11,8 @@
#
##############################################################################
-import string
-import Acquisition
-import sys
-from ZODB.POSException import ConflictError
+# This file is only for backward compatibility. Now the zsqlbrain.py resides
+# in the directory Extensions, but the class ZSQLBrain is referred to based on
+# the Product directory from other Products.
-from AccessControl import ClassSecurityInfo
-from AccessControl.SecurityInfo import allow_class
-
-from zLOG import LOG
-
-class ZSQLBrain(Acquisition.Implicit):
- security = ClassSecurityInfo()
- security.declareObjectPublic()
-
- def _aq_dynamic(self, name):
- """Acquire an attribute from a real object.
- """
- if name.startswith('__') :
- return None
- o = self.getObject()
- return getattr(o, name, None)
-
- def getURL(self):
- return self.path
-
- def getUrl(self):
- return self.path
-
- def getPath(self):
- return self.path
-
- def getUid(self):
- return self.uid
-
- getRID = getUid
-
- def getObject(self, REQUEST=None):
- """Try to return the object for this record"""
- if 'path' not in dir(self) and 'PATH' not in dir(self):
- raise ValueError, "Unable to getObject from ZSQLBrain if ZSQL Method "\
- "does not retrieves the `path` column from catalog table."
- try:
- obj = self.aq_parent.unrestrictedTraverse(self.getPath())
- if obj is None:
- if REQUEST is None:
- REQUEST = self.REQUEST
- obj = self.aq_parent.portal_catalog.resolve_url(
- self.getPath(), REQUEST)
- return obj
- except ConflictError:
- raise
- except:
- LOG("ZCatalog WARNING", 0,
- "Could not access object path %s" % self.getPath(),
- error=sys.exc_info() )
- return None
-
- def absolute_url(self, relative=0):
- """
- Default method used to return the path stored in the Catalog.
- However, if virtual hosting is implemented, we must return
- a value which is compatible with the standard absolute_url
- behaviour
-
- And if absolute_url is invoked within a Web Site,
- additional Web Site behaviour is required
-
- Implementation of absolute_url therefore consists in using
- physicalPathToURL defined in the REQUEST so that absolute_url
- is consistent with HTTPRequest implementation.
- """
- return self.REQUEST.physicalPathToURL(self.path, relative=relative)
-
- def resolve_url(self, path, REQUEST):
- """
- Taken from ZCatalog
-
- Attempt to resolve a url into an object in the Zope
- namespace. The url may be absolute or a catalog path
- style url. If no object is found, None is returned.
- No exceptions are raised.
- """
- script=REQUEST.script
- if string.find(path, script) != 0:
- path='%s/%s' % (script, path)
- try:
- return REQUEST.resolve_url(path)
- except ConflictError:
- raise
- except:
- pass
-
-allow_class(ZSQLBrain)
+from Products.ZSQLCatalog.Extensions.zsqlbrain import ZSQLBrain
More information about the Erp5-report
mailing list