Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
d60ce904
Commit
d60ce904
authored
Mar 27, 2007
by
Martijn Pieters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark ZCatalog catalog brains with an interface
parent
20110cf2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/Products/ZCatalog/CatalogBrains.py
lib/python/Products/ZCatalog/CatalogBrains.py
+6
-0
lib/python/Products/ZCatalog/interfaces.py
lib/python/Products/ZCatalog/interfaces.py
+34
-0
No files found.
doc/CHANGES.txt
View file @
d60ce904
...
@@ -51,6 +51,9 @@ Zope Changes
...
@@ -51,6 +51,9 @@ Zope Changes
Features added
Features added
- ZCatalog result objects (catalog brains) now have an interface,
ZCatalog.interfaces.ICatalogBrain.
- A new module, AccessControl.requestmethod, provides a decorator
- A new module, AccessControl.requestmethod, provides a decorator
factory that limits decorated methods to one request method only.
factory that limits decorated methods to one request method only.
For example, marking a method with @requestmethod('POST') limits
For example, marking a method with @requestmethod('POST') limits
...
...
lib/python/Products/ZCatalog/CatalogBrains.py
View file @
d60ce904
...
@@ -13,9 +13,13 @@
...
@@ -13,9 +13,13 @@
__version__
=
"$Revision$"
[
11
:
-
2
]
__version__
=
"$Revision$"
[
11
:
-
2
]
from
zope.interface
import
implements
import
Acquisition
,
Record
import
Acquisition
,
Record
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
interfaces
import
ICatalogBrain
# Switch for new behavior, raise exception instead of returning None.
# Switch for new behavior, raise exception instead of returning None.
# Use 'catalog-getObject-raises off' in zope.conf to restore old behavior.
# Use 'catalog-getObject-raises off' in zope.conf to restore old behavior.
GETOBJECT_RAISES
=
True
GETOBJECT_RAISES
=
True
...
@@ -25,6 +29,8 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit):
...
@@ -25,6 +29,8 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit):
required, and provides just enough smarts to let us get the URL, path,
required, and provides just enough smarts to let us get the URL, path,
and cataloged object without having to ask the catalog directly.
and cataloged object without having to ask the catalog directly.
"""
"""
implements
(
ICatalogBrain
)
def
has_key
(
self
,
key
):
def
has_key
(
self
,
key
):
return
self
.
__record_schema__
.
has_key
(
key
)
return
self
.
__record_schema__
.
has_key
(
key
)
...
...
lib/python/Products/ZCatalog/interfaces.py
View file @
d60ce904
...
@@ -246,3 +246,37 @@ class IZCatalog(Interface):
...
@@ -246,3 +246,37 @@ class IZCatalog(Interface):
pghandler -- optional Progresshandler as defined in ProgressHandler.py
pghandler -- optional Progresshandler as defined in ProgressHandler.py
(see also README.txt)
(see also README.txt)
"""
"""
# XXX This should inherit from an IRecord interface, if there ever is one.
class
ICatalogBrain
(
Interface
):
"""Catalog brain that handles looking up attributes as
required, and provides just enough smarts to let us get the URL, path,
and cataloged object without having to ask the catalog directly.
"""
def
has_key
(
key
):
"""Record has this field"""
def
getPath
():
"""Get the physical path for this record"""
def
getURL
(
relative
=
0
):
"""Generate a URL for this record"""
def
_unrestrictedGetObject
():
"""Return the object for this record
Same as getObject, but does not do security checks.
"""
def
getObject
():
"""Return the object for this record
Will return None if the object cannot be found via its cataloged path
(i.e., it was deleted or moved without recataloging), or if the user is
not authorized to access the object.
"""
def
getRID
():
"""Return the record ID for this object."""
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment