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
886b9557
Commit
886b9557
authored
Aug 31, 1999
by
Amos Latteier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some changes to resolve_url. Stop the URL madness!
parent
23009471
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
66 deletions
+28
-66
lib/python/Products/ZCatalog/ZCatalog.py
lib/python/Products/ZCatalog/ZCatalog.py
+28
-66
No files found.
lib/python/Products/ZCatalog/ZCatalog.py
View file @
886b9557
...
...
@@ -213,15 +213,9 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
""" index all Zope objects that 'urls' point to """
if
urls
:
for
url
in
urls
:
try
:
# if an error happens here, the catalog will be in
# an unstable state. If this happens, ignore the
# object.
obj
=
self
.
resolve_url
(
url
,
REQUEST
)
except
:
continue
self
.
catalog_object
(
obj
,
url
)
obj
=
self
.
resolve_url
(
url
,
REQUEST
)
if
obj
is
not
None
:
self
.
catalog_object
(
obj
,
url
)
message
=
"Objects Cataloged"
return
self
.
manage_main
(
self
,
REQUEST
,
...
...
@@ -232,11 +226,9 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
if
urls
:
for
url
in
urls
:
try
:
obj
=
self
.
resolve_url
(
url
,
REQUEST
)
except
:
continue
self
.
uncatalog_object
(
url
)
obj
=
self
.
resolve_url
(
url
,
REQUEST
)
if
obj
is
not
None
:
self
.
uncatalog_object
(
url
)
message
=
"Object UnCataloged"
return
self
.
manage_main
(
self
,
REQUEST
,
...
...
@@ -245,17 +237,15 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
def
manage_catalogReindex
(
self
,
REQUEST
):
""" clear the catalog, then re-index everything """
import
pdb
pdb
.
set_trace
()
#
import pdb
#
pdb.set_trace()
paths
=
tuple
(
self
.
_catalog
.
paths
.
values
())
self
.
manage_catalogClear
(
REQUEST
)
for
p
in
paths
:
try
:
obj
=
self
.
resolve_url
(
p
,
REQUEST
)
self
.
catalog_object
(
obj
,
p
)
except
:
pass
obj
=
self
.
resolve_url
(
p
,
REQUEST
)
if
obj
is
not
None
:
self
.
catalog_object
(
obj
,
p
)
message
=
"Catalog Reindexed"
return
self
.
manage_catalogView
(
self
,
REQUEST
,
...
...
@@ -361,11 +351,7 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
"""
if
REQUEST
is
None
:
REQUEST
=
self
.
REQUEST
try
:
obj
=
self
.
resolve_url
(
self
.
getpath
(
rid
),
REQUEST
)
except
:
return
None
return
obj
return
self
.
resolve_url
(
self
.
getpath
(
rid
),
REQUEST
)
def
schema
(
self
):
return
self
.
_catalog
.
schema
.
keys
()
...
...
@@ -447,46 +433,22 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
## Note: do not use, this method is depricated. Use 'getobject'
def
resolve_url
(
self
,
path
,
REQUEST
):
""" The use of this function is depricated. Use 'getobject' """
# Attempt to resolve a url into an object in the Zope
# namespace. The url must be a fully-qualified url. The
# method will return the requested object if it is found
# or raise the same HTTP error that would be raised in
# the case of a real web request. If the passed in url
# does not appear to describe an object in the system
# namespace (e.g. the host, port or script name dont
# match that of the current request), a ValueError will
# be raised.
while
path
and
path
[
0
]
==
'/'
:
path
=
path
[
1
:]
while
path
and
path
[
-
1
]
==
'/'
:
path
=
path
[:
-
1
]
req
=
REQUEST
.
clone
()
rsp
=
req
.
response
req
[
'PATH_INFO'
]
=
path
object
=
None
try
:
object
=
req
.
traverse
(
path
)
except
:
rsp
.
exception
(
0
)
if
object
is
not
None
:
# waaa - traversal may return a "default object"
# like an index_html document, though you really
# wanted to get a Folder back :(
if
hasattr
(
object
,
'id'
):
if
callable
(
object
.
id
):
name
=
object
.
id
()
else
:
name
=
object
.
id
elif
hasattr
(
object
,
'__name__'
):
name
=
object
.
__name__
else
:
name
=
''
if
name
!=
os
.
path
.
split
(
path
)[
-
1
]:
result
=
req
.
PARENTS
[
0
]
req
.
close
()
return
result
req
.
close
()
return
object
req
.
close
()
raise
rsp
.
errmsg
,
sys
.
exc_value
"""
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
)
print
"resolving"
,
path
try
:
return
REQUEST
.
resolve_url
(
path
)
except
:
print
"not found"
return
None
Globals
.
default__class_init__
(
ZCatalog
)
...
...
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