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
70fa6426
Commit
70fa6426
authored
May 07, 1999
by
Michel Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cvs rules.
parent
0c9696d8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
466 additions
and
0 deletions
+466
-0
lib/python/Products/ZCatalog/CHANGES.txt
lib/python/Products/ZCatalog/CHANGES.txt
+23
-0
lib/python/Products/ZCatalog/Catalog.gif
lib/python/Products/ZCatalog/Catalog.gif
+0
-0
lib/python/Products/ZCatalog/Catalog.py
lib/python/Products/ZCatalog/Catalog.py
+267
-0
lib/python/Products/ZCatalog/README.txt
lib/python/Products/ZCatalog/README.txt
+81
-0
lib/python/Products/ZCatalog/__init__.py
lib/python/Products/ZCatalog/__init__.py
+94
-0
lib/python/Products/ZCatalog/version.txt
lib/python/Products/ZCatalog/version.txt
+1
-0
No files found.
lib/python/Products/ZCatalog/CHANGES.txt
0 → 100644
View file @
70fa6426
Catalog Changes
TODO
Convert most columns (except url) to Computed Attributes.
Add authorization checks to searching in order to limit returned records
returned to ones for which the current user has authorization.
Catalog 0.4.1
New Features
Now the 'getCatalogObject' method provides access from DTML to Cataloged
objects.
Bugs Fixed
Reindented with spaces instead of tabs
Catalog 0.4.0
Initial Catalog checked into CVS
\ No newline at end of file
lib/python/Products/ZCatalog/Catalog.gif
0 → 100644
View file @
70fa6426
181 Bytes
lib/python/Products/ZCatalog/Catalog.py
0 → 100644
View file @
70fa6426
##############################################################################
#
# Zope Public License (ZPL) Version 1.0
# -------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
"""Catalog
A Catalog object provides an inteface to index objects.
"""
from
Globals
import
HTMLFile
,
MessageDialog
from
OFS.SimpleItem
import
Item
from
Products.ZTablesCore
import
ZTablesCore
from
SearchIndex
import
Query
import
string
,
regex
,
urlparse
class
Catalog
(
Item
):
"""Catalog object"""
meta_type
=
"Catalog"
__ac_permissions__
=
(
(
'Manage Catalog Entries'
,
[
'indexObject'
,
'unindexObject'
,
'indexAddColumn'
],
[
'Manager'
]),
(
'Search SiteIndex'
,
[
'searchResults'
,
'__call__'
],[
'Anonymous'
,
'Manager'
]),
)
def
__init__
(
self
,
id
,
title
=
None
):
self
.
id
=
id
self
.
title
=
title
self
.
_ztable
=
ZTablesCore
.
ZTable
(
id
)
# create a static set of table contents and indexes to go with
# them
schema
=
[(
'id'
,
'FieldIndex'
,
's'
),
(
'url'
,
'FieldIndex'
,
's'
),
(
'title'
,
'TextIndex'
,
's'
),
(
'meta_type'
,
'FieldIndex'
,
's'
),
(
'last_modified'
,
'TextIndex'
,
'd'
),
(
'subject'
,
'TextIndex'
,
's'
),
(
'description'
,
'TextIndex'
,
's'
),
(
'date'
,
'TextIndex'
,
'd'
),
(
'reviewed'
,
'FieldIndex'
,
'i'
),
]
uindex
=
[]
utype
=
[]
for
name
,
index
,
type
in
schema
:
self
.
_ztable
.
addColumn
(
name
)
uindex
.
append
(
index
)
utype
.
append
(
type
)
# create an orphan index for text_content. A table row will
# not get created but an index will.
self
.
_ztable
.
_data
.
setOrphanIndex
(
'text_content'
,
'TextIndex'
,
call_methods
=
1
)
self
.
_ztable
.
update_database_schema
(
uindex
,
utype
)
def
searchResults
(
self
,
REQUEST
=
None
,
used
=
None
,
query_map
=
{
type
(
regex
.
compile
(
''
)):
Query
.
Regex
,
type
([]):
ZTablesCore
.
orify
,
type
(
''
):
Query
.
String
,
},
**
kw
):
"""
Search the catalog according to the ZTables search interface.
Search terms can be passed in the REQUEST or as keyword
arguments.
"""
return
apply
(
self
.
_ztable
.
searchResults
,(
REQUEST
,
used
,
query_map
),
kw
)
__call__
=
searchResults
def
data_column_names
(
self
):
"""
Returns a list of all column names
"""
return
(
list
(
self
.
_ztable
.
_data
.
_names
)
+
self
.
_ztable
.
_data
.
_computed_fields
)
def
indexObject
(
self
,
obj
,
REQUEST
=
None
):
"""
Indexes a single object, either by creating new record, or
by updating an existing index for the object
"""
# r_id is the record id in the table, *not* the object's 'id'.
r
=
self
.
_get_record
(
obj
)
r_id
=
self
.
_obj2id
(
obj
)
if
r_id
is
not
None
:
self
.
_ztable
.
editRecord
(
r_id
,
r
,
obj
)
else
:
self
.
_ztable
.
addRecord
(
r
,
obj
)
if
REQUEST
is
not
None
:
return
MessageDialog
(
title
=
'Object Indexed'
,
message
=
'The object has been indexed.'
,
action
=
'manage_main'
)
def
unindexObject
(
self
,
obj
,
REQUEST
=
None
):
"""Remove object from the Catalog.
"""
r_id
=
self
.
_obj2id
(
obj
)
print
'unindexObject: r_id is %s'
%
r_id
if
r_id
is
not
None
:
print
'unindexObject: removing'
self
.
_ztable
.
deleteRecord
(
r_id
,
obj
)
else
:
print
'unindexObject: didnt remove'
if
REQUEST
is
not
None
:
return
MessageDialog
(
title
=
'Catalog records deleted'
,
message
=
'%s catalog records deleted.'
%
num
,
action
=
'manage_main'
)
def
indexAddColumn
(
self
,
name
,
type
=
's'
,
index_type
=
'FieldIndex'
):
"""
Adds an column and index to the catalog.
'type' is a type code ['s'|'t'|'i'|'f'|'d'|'b']
'index_type' is index type code:
['FieldIndex'|'TextIndex'|'KeywordIndex']
Note: KeywordIndex is not yet supported in the ZTable Core
"""
self
.
_ztable
.
addColumn
(
name
,
type
)
self
.
_ztable
.
_getDataSet
().
setOneIndex
(
name
,
index_type
)
def
_obj2id
(
self
,
obj
):
print
'obj2id: obj.url is %s'
%
obj
.
url
()
results
=
self
.
_ztable
.
searchResults
(
url
=
obj
.
url
())
if
results
:
return
results
[
0
].
data_record_id_
def
_get_record
(
self
,
obj
):
"""
return a catalog record to be stored in the table for 'obj'.
"""
record
=
{}
record
[
'id'
]
=
callable
(
obj
.
id
)
and
obj
.
id
()
or
obj
.
id
record
[
'url'
]
=
obj
.
url
()
record
[
'title'
]
=
obj
.
title
record
[
'last_modified'
]
=
obj
.
bobobase_modification_time
()
record
[
'meta_type'
]
=
obj
.
meta_type
if
obj
.
meta_type
in
[
'Document'
,
'DTML Document'
,
'DTML Method'
]:
record
[
'text_content'
]
=
obj
.
read_raw
()
record
[
'subject'
]
=
obj
.
subject
record
[
'description'
]
=
obj
.
description
record
[
'summary'
]
=
obj
.
summary
record
[
'reviewed'
]
=
obj
.
reviewed
print
'_get_record: %s'
%
record
return
record
lib/python/Products/ZCatalog/README.txt
0 → 100644
View file @
70fa6426
Site Index
A Site Index collects information about Zope objects. It allows
indexes of Zope objects to be searched.
To search a site index, use the same conventions as a Tabula. Use
either 'DP_Search_Results' or '__call__' with REQUEST and/or kw
arguments.
Basic indexed meta data includes
id -- The object's id
url -- A url for the object, eg '/MyFolder/MyDoc'
title -- The object's title
meta_type -- The object's meta type
last_modified -- The object's bobobase_lastmodification_time
text_content -- Text of DTML Documents and Methods
All indexes are FieldIndexes, except text_content which is a TextIndex.
How to Use the Catalog
To use a Catalog, create a Catalog object and add items to the catalog.
You can use a Find like interface to search for interesting objects
to add. The catalog does not detect changes to indexed objects, so you
should periodically update the catalog index.
To search the catalog, first create a report form by selecting the 'Report'
for the product add list. After you create your report you can test it by
viewing it.
Next create a search form by selecting 'Search Form' form the product add
list. The wizard will allow you to tailor the search form in a number of
ways. You should indicate that the search form is to use the report that
you previously created.
Now you can search your Zope site by viewing the search page and filling
out the search form.
Cataloging Interface
Zope objects can define additional attributes to be cataloged. When
an object is added to the catalog that specifies additional cataloging
information, additional columns and indexes will be added to the catalog
as needed.
To define additinal cataloging data use the 'ZopeCatalogAttributes'
method. The method should return a tuple or list of dictionaries which
describe the cataloged attributes::
{'name': name, 'attr': attr, 'type': type, 'index': indexType}
Where
'name' is the name of the index.
'attr' is the name of a method or attribute to query.
'type' is a type code ['s'|'t'|'i'|'f'|'d'|'b']
'index' is the index type ['FieldIndex'|'TextIndex'|'KeywordIndex']
Note that problems can occurr if an object tries to define an index that
already exists, but is of a different type or index type. Be careful.
Note: This interface is provisional and subject to change.
lib/python/Products/ZCatalog/__init__.py
0 → 100644
View file @
70fa6426
##############################################################################
#
# Zope Public License (ZPL) Version 0.9.7
# ---------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# This license has been certified as Open Source(tm).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Digital Creations requests that attribution be given to Zope
# in any manner possible. Zope includes a "Powered by Zope"
# button that is installed by default. While it is not a license
# violation to remove this button, it is requested that the
# attribution remain. A significant investment has been put
# into Zope, and this effort will continue if the Zope community
# continues to grow. This is one way to assure that growth.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
"""Site Index product"""
import
Catalog
def
initialize
(
context
):
context
.
registerBaseClass
(
Catalog
.
Catalog
)
lib/python/Products/ZCatalog/version.txt
0 → 100644
View file @
70fa6426
Catalog-0-6-0
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