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
c12872d4
Commit
c12872d4
authored
Jul 12, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
parent
23898809
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
0 deletions
+81
-0
lib/python/Shared/DC/ZRDB/Results.py
lib/python/Shared/DC/ZRDB/Results.py
+81
-0
No files found.
lib/python/Shared/DC/ZRDB/Results.py
0 → 100644
View file @
c12872d4
from
string
import
strip
,
lower
,
upper
from
Acquisition
import
Implicit
from
Record
import
Record
record_classes
=
{}
class
NoBrains
:
pass
class
Results
:
"""Class for providing a nice interface to DBI result data
"""
_index
=
None
def
__init__
(
self
,(
items
,
data
),
brains
=
NoBrains
,
parent
=
None
):
self
.
_data
=
data
self
.
__items__
=
items
self
.
_parent
=
parent
self
.
_names
=
names
=
[]
self
.
_schema
=
schema
=
{}
self
.
_data_dictionary
=
dd
=
{}
i
=
0
for
item
in
items
:
name
=
item
[
'name'
]
name
=
strip
(
name
)
if
not
name
:
raise
ValueError
,
'Empty column name, %s'
%
name
if
schema
.
has_key
(
name
):
raise
ValueError
,
'Duplicate column name, %s'
%
name
schema
[
name
]
=
i
schema
[
lower
(
name
)]
=
i
schema
[
upper
(
name
)]
=
i
dd
[
name
]
=
item
names
.
append
(
name
)
i
=
i
+
1
self
.
_nv
=
nv
=
len
(
names
)
# Create a record class to hold the records.
names
=
tuple
(
names
)
if
record_classes
.
has_key
((
names
,
brains
)):
r
=
record_classes
[
names
,
brains
]
else
:
class
r
(
Record
,
Implicit
,
brains
):
'Result record class'
r
.
__record_schema__
=
schema
for
k
in
filter
(
lambda
k
:
k
[:
2
]
==
'__'
,
Record
.
__dict__
.
keys
()):
setattr
(
r
,
k
,
getattr
(
Record
,
k
))
record_classes
[
names
,
brains
]
=
r
if
hasattr
(
brains
,
'__init__'
):
binit
=
brains
.
__init__
if
hasattr
(
binit
,
'im_func'
):
binit
=
binit
.
im_func
def
__init__
(
self
,
data
,
parent
,
binit
=
binit
):
Record
.
__init__
(
self
,
data
)
binit
(
self
.
__of__
(
parent
))
r
.
__dict__
[
'__init__'
]
=
__init__
self
.
_class
=
r
# OK, we've read meta data, now get line indexes
def
_searchable_result_columns
(
self
):
return
self
.
__items__
def
names
(
self
):
return
self
.
_names
def
data_dictionary
(
self
):
return
self
.
_data_dictionary
def
__len__
(
self
):
return
len
(
self
.
_data
)
def
__getitem__
(
self
,
index
):
if
index
==
self
.
_index
:
return
self
.
_row
parent
=
self
.
_parent
fields
=
self
.
_class
(
self
.
_data
[
index
],
parent
)
self
.
_index
=
index
self
.
_row
=
fields
if
parent
is
None
:
return
fields
return
fields
.
__of__
(
parent
)
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