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
39f2cf5b
Commit
39f2cf5b
authored
Aug 18, 2005
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Collector #1871: Applied patch to support lists with records using
ZTUtils.make_query()
parent
94ef40ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
2 deletions
+69
-2
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/ZTUtils/Zope.py
lib/python/ZTUtils/Zope.py
+8
-2
lib/python/ZTUtils/tests/testZope.py
lib/python/ZTUtils/tests/testZope.py
+58
-0
No files found.
doc/CHANGES.txt
View file @
39f2cf5b
...
...
@@ -49,6 +49,9 @@ Zope Changes
Bugs fixed
- Collector #1871: Applied patch to support lists with records using
ZTUtils.make_query()
- ZCatalog: refreshCatalog() could not be called safely from a ZEO
client script
...
...
lib/python/ZTUtils/Zope.py
View file @
39f2cf5b
...
...
@@ -235,8 +235,14 @@ def complex_marshal(pairs):
elif
hasattr
(
v
,
'items'
):
sublist
=
[]
for
sk
,
sv
in
v
.
items
():
sm
=
simple_marshal
(
sv
)
sublist
.
append
((
'%s.%s'
%
(
k
,
sk
),
'%s:record'
%
sm
,
sv
))
if
isinstance
(
sv
,
list
):
for
ssv
in
sv
:
sm
=
simple_marshal
(
ssv
)
sublist
.
append
((
'%s.%s'
%
(
k
,
sk
),
'%s:list:record'
%
sm
,
ssv
))
else
:
sm
=
simple_marshal
(
sv
)
sublist
.
append
((
'%s.%s'
%
(
k
,
sk
),
'%s:record'
%
sm
,
sv
))
elif
isinstance
(
v
,
list
):
sublist
=
[]
for
sv
in
v
:
...
...
lib/python/ZTUtils/tests/testZope.py
0 → 100644
View file @
39f2cf5b
import
os
,
sys
from
unittest
import
TestCase
,
makeSuite
,
main
import
string
import
urllib
from
ZTUtils.Zope
import
make_query
,
complex_marshal
from
DateTime
import
DateTime
class
QueryTests
(
TestCase
):
def
testMarshallLists
(
self
):
'''Test marshalling lists'''
test_date
=
DateTime
()
list_
=
[
1
,
test_date
,
'str'
]
result
=
complex_marshal
([(
'list'
,
list_
),])
assert
result
==
[(
'list'
,
':int:list'
,
1
),
(
'list'
,
':date:list'
,
test_date
),
(
'list'
,
':list'
,
'str'
)]
def
testMarshallRecords
(
self
):
'''Test marshalling records'''
test_date
=
DateTime
()
record
=
{
'arg1'
:
1
,
'arg2'
:
test_date
,
'arg3'
:
'str'
}
result
=
complex_marshal
([(
'record'
,
record
),])
assert
result
==
[(
'record.arg1'
,
':int:record'
,
1
),
(
'record.arg2'
,
':date:record'
,
test_date
),
(
'record.arg3'
,
':record'
,
'str'
)]
def
testMarshallListsInRecords
(
self
):
'''Test marshalling lists inside of records'''
test_date
=
DateTime
()
record
=
{
'arg1'
:
[
1
,
test_date
,
'str'
],
'arg2'
:
1
}
result
=
complex_marshal
([(
'record'
,
record
),])
assert
result
==
[(
'record.arg1'
,
':int:list:record'
,
1
),
(
'record.arg1'
,
':date:list:record'
,
test_date
),
(
'record.arg1'
,
':list:record'
,
'str'
),
(
'record.arg2'
,
':int:record'
,
1
)]
def
testMakeComplexQuery
(
self
):
'''Test that make_query returns sane results'''
test_date
=
DateTime
()
quote_date
=
urllib
.
quote
(
str
(
test_date
))
record
=
{
'arg1'
:
[
1
,
test_date
,
'str'
],
'arg2'
:
1
}
list_
=
[
1
,
test_date
,
'str'
]
date
=
test_date
int_
=
1
str_
=
'str'
query
=
make_query
(
date
=
test_date
,
integer
=
int_
,
listing
=
list_
,
record
=
record
,
string
=
str_
)
assert
query
==
'date:date=%s&integer:int=1&listing:int:list=1&listing:date:list=%s&listing:list=str&string=str&record.arg1:int:list:record=1&record.arg1:date:list:record=%s&record.arg1:list:record=str&record.arg2:int:record=1'
%
(
quote_date
,
quote_date
,
quote_date
)
def
test_suite
():
return
makeSuite
(
QueryTests
)
if
__name__
==
'__main__'
:
main
()
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