Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
7865c58d
Commit
7865c58d
authored
Jan 23, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMFCategory: add support for ZODB indexing of related documents
parent
a47a9bbd
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
503 additions
and
43 deletions
+503
-43
product/CMFCategory/CategoryTool.py
product/CMFCategory/CategoryTool.py
+190
-35
product/CMFCategory/tests/testCMFCategory.py
product/CMFCategory/tests/testCMFCategory.py
+57
-1
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+2
-1
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseCategory_validateRelatedLocallyIndexed.xml
.../erp5_core/BaseCategory_validateRelatedLocallyIndexed.xml
+69
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseCategory_view.xml
...TemplateItem/portal_skins/erp5_core/BaseCategory_view.xml
+1
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseCategory_view/my_related_locally_indexed.xml
...rp5_core/BaseCategory_view/my_related_locally_indexed.xml
+124
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_zSearchRelatedObjectsByCategoryList.xml
...ns/erp5_core/Base_zSearchRelatedObjectsByCategoryList.xml
+2
-6
product/ERP5/bootstrap/erp5_property_sheets/PropertySheetTemplateItem/portal_property_sheets/BaseCategory/related_locally_indexed_property.xml
..._sheets/BaseCategory/related_locally_indexed_property.xml
+58
-0
No files found.
product/CMFCategory/CategoryTool.py
View file @
7865c58d
This diff is collapsed.
Click to expand it.
product/CMFCategory/tests/testCMFCategory.py
View file @
7865c58d
...
@@ -60,6 +60,11 @@ class TestCMFCategory(ERP5TypeTestCase):
...
@@ -60,6 +60,11 @@ class TestCMFCategory(ERP5TypeTestCase):
),
),
resource
=
dict
(
resource
=
dict
(
),
),
test0
=
dict
(
),
test1
=
dict
(
contents
=
(
'a'
,
(
'ab'
,
'ac'
,
(
'acd'
,))),
),
)
)
def
getTitle
(
self
):
def
getTitle
(
self
):
...
@@ -104,7 +109,8 @@ class TestCMFCategory(ERP5TypeTestCase):
...
@@ -104,7 +109,8 @@ class TestCMFCategory(ERP5TypeTestCase):
acquisition_copy_value
=
0
,
acquisition_copy_value
=
0
,
acquisition_append_value
=
0
,
acquisition_append_value
=
0
,
acquisition_mask_value
=
0
,
acquisition_mask_value
=
0
,
acquisition_portal_type_list
=
"python: []"
)
acquisition_portal_type_list
=
"python: []"
,
related_locally_indexed
=
0
)
edit_kw
.
update
(
kw
)
edit_kw
.
update
(
kw
)
queue
=
deque
(((
bc
,
edit_kw
.
pop
(
'contents'
,
())),))
queue
=
deque
(((
bc
,
edit_kw
.
pop
(
'contents'
,
())),))
bc
.
edit
(
**
edit_kw
)
bc
.
edit
(
**
edit_kw
)
...
@@ -129,6 +135,7 @@ class TestCMFCategory(ERP5TypeTestCase):
...
@@ -129,6 +135,7 @@ class TestCMFCategory(ERP5TypeTestCase):
ti
=
self
.
getTypesTool
().
getTypeInfo
(
portal_type
)
ti
=
self
.
getTypesTool
().
getTypeInfo
(
portal_type
)
ti
.
filter_content_types
=
0
ti
.
filter_content_types
=
0
self
.
_original_categories
[
portal_type
]
=
x
=
ti
.
getTypeBaseCategoryList
()
self
.
_original_categories
[
portal_type
]
=
x
=
ti
.
getTypeBaseCategoryList
()
x
+=
'test0'
,
'test1'
ti
.
_setTypeBaseCategoryList
(
x
+
categories
)
ti
.
_setTypeBaseCategoryList
(
x
+
categories
)
# Make persons.
# Make persons.
...
@@ -1094,6 +1101,55 @@ class TestCMFCategory(ERP5TypeTestCase):
...
@@ -1094,6 +1101,55 @@ class TestCMFCategory(ERP5TypeTestCase):
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'bab'
))
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'bab'
))
_set
(
bc
.
id
,
())
_set
(
bc
.
id
,
())
def
test_relatedIndex
(
self
):
category_tool
=
self
.
getCategoriesTool
()
newOrganisation
=
self
.
getOrganisationModule
().
newContent
organisation
=
newOrganisation
()
other_organisation
=
newOrganisation
(
destination_value
=
organisation
)
person
=
self
.
getPersonModule
().
newContent
(
test0_value
=
organisation
,
test1
=
'a/ac/acd'
)
self
.
tic
()
get
=
organisation
.
getTest0RelatedValueList
a
=
category_tool
.
test1
.
a
def
check
():
self
.
assertEqual
([
person
,
other_organisation
],
category_tool
.
getRelatedValueList
(
organisation
))
self
.
assertEqual
([
person
],
get
())
self
.
assertEqual
([
person
],
get
(
portal_type
=
'Person'
))
self
.
assertEqual
([],
get
(
portal_type
=
'Organisation'
))
self
.
assertEqual
([
person
],
a
.
getTest1RelatedValueList
(
portal_type
=
'Person'
))
self
.
assertEqual
([
a
],
a
.
getTest1RelatedValueList
(
strict_membership
=
True
))
self
.
assertEqual
([
person
],
a
.
ac
.
acd
.
getTest1RelatedValueList
(
portal_type
=
'Person'
,
strict_membership
=
True
))
category_tool
.
test0
.
_setRelatedLocallyIndexed
(
True
)
category_tool
.
test1
.
_setRelatedLocallyIndexed
(
True
)
check
()
related_list
=
sorted
(
a
.
getTest1RelatedList
())
self
.
assertTrue
(
person
.
getRelativeUrl
()
in
related_list
)
self
.
assertEqual
(
related_list
,
sorted
(
x
.
getRelativeUrl
()
for
x
in
self
.
portal
.
portal_catalog
(
test1_uid
=
a
.
getUid
())))
related
=
organisation
.
_related_index
self
.
assertTrue
(
related
)
self
.
assertEqual
([
person
.
getRelativeUrl
()],
list
(
related
.
test0
))
person
.
unindexObject
()
self
.
tic
()
category_tool
.
test0
.
_setRelatedLocallyIndexed
(
False
)
self
.
assertEqual
([],
get
())
category_tool
.
test0
.
_setRelatedLocallyIndexed
(
True
)
check
()
person
.
categories
=
tuple
(
x
for
x
in
person
.
categories
if
not
x
.
startswith
(
'test0/'
))
self
.
assertEqual
([],
get
())
self
.
assertFalse
(
related
)
self
.
assertEqual
([],
list
(
related
.
test0
))
related
=
a
.
ac
.
acd
.
_related_index
.
test1
self
.
assertEqual
(
list
(
related
),
[
person
.
getRelativeUrl
()])
person
.
_setTest1Value
(
a
)
self
.
assertEqual
(
list
(
related
),
[])
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestCMFCategory
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestCMFCategory
))
...
...
product/ERP5/Document/BusinessTemplate.py
View file @
7865c58d
...
@@ -544,7 +544,8 @@ class BaseTemplateItem(Implicit, Persistent):
...
@@ -544,7 +544,8 @@ class BaseTemplateItem(Implicit, Persistent):
klass
=
obj
.
__class__
klass
=
obj
.
__class__
classname
=
klass
.
__name__
classname
=
klass
.
__name__
attr_set
=
set
((
'_dav_writelocks'
,
'_filepath'
,
'_owner'
,
'last_id'
,
'uid'
,
attr_set
=
set
((
'_dav_writelocks'
,
'_filepath'
,
'_owner'
,
'_related_index'
,
'last_id'
,
'uid'
,
'__ac_local_roles__'
,
'__ac_local_roles_group_id_dict__'
))
'__ac_local_roles__'
,
'__ac_local_roles_group_id_dict__'
))
if
export
:
if
export
:
if
not
keep_workflow_history
:
if
not
keep_workflow_history
:
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseCategory_validateRelatedLocallyIndexed.xml
0 → 100644
View file @
7865c58d
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
return not (value and (\n
request.other[\'field_my_acquisition_object_id_list\'] or\n
request.other[\'field_my_acquisition_base_category_list\']))\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
value, request
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
BaseCategory_validateRelatedLocallyIndexed
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseCategory_view.xml
View file @
7865c58d
...
@@ -105,6 +105,7 @@
...
@@ -105,6 +105,7 @@
<key>
<string>
right
</string>
</key>
<key>
<string>
right
</string>
</key>
<value>
<value>
<list>
<list>
<string>
my_related_locally_indexed
</string>
<string>
my_acquisition_copy_value
</string>
<string>
my_acquisition_copy_value
</string>
<string>
my_acquisition_mask_value
</string>
<string>
my_acquisition_mask_value
</string>
<string>
my_acquisition_append_value
</string>
<string>
my_acquisition_append_value
</string>
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/BaseCategory_view/my_related_locally_indexed.xml
0 → 100644
View file @
7865c58d
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ProxyField"
module=
"Products.ERP5Form.ProxyField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
delegated_list
</string>
</key>
<value>
<list>
<string>
external_validator
</string>
<string>
title
</string>
</list>
</value>
</item>
<item>
<key>
<string>
delegated_message_list
</string>
</key>
<value>
<list>
<string>
external_validator_failed
</string>
</list>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
my_related_locally_indexed
</string>
</value>
</item>
<item>
<key>
<string>
message_values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
external_validator_failed
</string>
</key>
<value>
<string>
Local index is incompatible with category acquision.
</string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
overrides
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
target
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
tales
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
target
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
external_validator
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string>
my_checkbox
</string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string>
Base_viewFieldLibrary
</string>
</value>
</item>
<item>
<key>
<string>
target
</string>
</key>
<value>
<string>
Click to edit the target
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Index Related Documents Locally
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Method"
module=
"Products.Formulator.MethodField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
method_name
</string>
</key>
<value>
<string>
BaseCategory_validateRelatedLocallyIndexed
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_zSearchRelatedObjectsByCategoryList.xml
View file @
7865c58d
...
@@ -58,15 +58,11 @@ order_by_expression</string> </value>
...
@@ -58,15 +58,11 @@ order_by_expression</string> </value>
<key>
<string>
src
</string>
</key>
<key>
<string>
src
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
<value>
<string
encoding=
"cdata"
>
<![CDATA[
SELECT DISTINCT catalog.uid,
catalog.path
, portal_type\n
SELECT DISTINCT catalog.uid,
path, relative_url
, portal_type\n
FROM catalog, category\n
FROM catalog, category\n
WHERE catalog.uid = category.uid\n
WHERE catalog.uid = category.uid\n
<dtml-if portal_type>
\n
<dtml-if portal_type>
\n
AND\n
AND
<dtml-sqltest
portal_type
type=
"string"
multiple
>
\n
(
<dtml-in
portal_type
>
\n
<dtml-unless
sequence-start
>
OR
</dtml-unless>
\n
catalog.portal_type=\'
<dtml-var
sequence-item
>
\'\n
</dtml-in>
)\n
</dtml-if>
\n
</dtml-if>
\n
AND (
<dtml-var
"portal_categories.buildSQLSelector(category_list)"
>
)\n
AND (
<dtml-var
"portal_categories.buildSQLSelector(category_list)"
>
)\n
<dtml-if
strict_membership
>
\n
<dtml-if
strict_membership
>
\n
...
...
product/ERP5/bootstrap/erp5_property_sheets/PropertySheetTemplateItem/portal_property_sheets/BaseCategory/related_locally_indexed_property.xml
0 → 100644
View file @
7865c58d
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Standard Property"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_local_properties
</string>
</key>
<value>
<tuple>
<dictionary>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
mode
</string>
</value>
</item>
<item>
<key>
<string>
type
</string>
</key>
<value>
<string>
string
</string>
</value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
elementary_type/boolean
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string>
Determines if related values should be indexed on target documents (i.e. in ZODB) in addition to catalog.\n
This is incompatible with category acquisition.
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
related_locally_indexed_property
</string>
</value>
</item>
<item>
<key>
<string>
mode
</string>
</key>
<value>
<string>
w
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Standard Property
</string>
</value>
</item>
<item>
<key>
<string>
property_default
</string>
</key>
<value>
<string>
python: 0
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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