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
8cb512a3
Commit
8cb512a3
authored
Sep 26, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more
parent
6cf2ef8c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
112 deletions
+100
-112
lib/python/Shared/DC/ZRDB/Aqueduct.py
lib/python/Shared/DC/ZRDB/Aqueduct.py
+86
-105
lib/python/Shared/DC/ZRDB/DA.py
lib/python/Shared/DC/ZRDB/DA.py
+6
-4
lib/python/Shared/DC/ZRDB/RDB.py
lib/python/Shared/DC/ZRDB/RDB.py
+7
-2
lib/python/Shared/DC/ZRDB/edit.dtml
lib/python/Shared/DC/ZRDB/edit.dtml
+1
-1
No files found.
lib/python/Shared/DC/ZRDB/Aqueduct.py
View file @
8cb512a3
...
...
@@ -10,18 +10,22 @@
##############################################################################
__doc__
=
'''Shared Aqueduct classes and functions
$Id: Aqueduct.py,v 1.1
1 1997/09/25 22:33:01
jim Exp $'''
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
$Id: Aqueduct.py,v 1.1
2 1997/09/26 22:17:36
jim Exp $'''
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
from
Globals
import
HTMLFile
from
Globals
import
HTMLFile
,
Persistent
import
DocumentTemplate
,
DateTime
,
regex
,
regsub
,
string
,
urllib
,
rotor
import
binascii
import
binascii
,
Acquisition
DateTime
.
now
=
DateTime
.
DateTime
from
cStringIO
import
StringIO
from
OFS
import
SimpleItem
from
AccessControl.Role
import
RoleManager
from
DocumentTemplate
import
HTML
dtml_dir
=
"%s/lib/python/Aqueduct/"
%
SOFTWARE_HOME
class
BaseQuery
:
class
BaseQuery
(
Persistent
,
SimpleItem
.
Item
,
Acquisition
.
Implicit
,
RoleManager
):
def
query_year
(
self
):
return
self
.
query_date
.
year
()
def
query_month
(
self
):
return
self
.
query_date
.
month
()
def
query_day
(
self
):
return
self
.
query_date
.
day
()
...
...
@@ -33,70 +37,82 @@ class BaseQuery:
MissingArgumentError
=
'Bad Request'
def
_argdata
(
self
,
REQUEST
,
raw
=
0
,
return_missing_keys
=
0
):
def
_argdata
(
self
,
REQUEST
):
r
=
{}
args
=
self
.
_arg
argdata
=
{}
id
=
self
.
id
missing_keys
=
[]
for
arg
in
args
.
keys
():
a
=
arg
l
=
string
.
find
(
arg
,
':'
)
if
l
>
0
:
arg
=
arg
[:
l
]
v
=
REQUEST
missing
=
[]
for
name
in
args
.
keys
():
idname
=
"%s/%s"
%
(
id
,
name
)
try
:
try
:
v
=
REQUEST
[
arg
]
except
(
KeyError
,
AttributeError
):
pass
if
v
is
REQUEST
:
try
:
v
=
REQUEST
[
"%s.%s"
%
(
id
,
arg
)]
except
(
KeyError
,
AttributeError
):
pass
if
v
is
REQUEST
:
l
=
string
.
find
(
arg
,
'.'
)
if
l
>
0
and
raw
:
arg
=
arg
[
l
+
1
:]
try
:
v
=
REQUEST
[
arg
]
except
(
KeyError
,
AttributeError
):
pass
if
v
is
REQUEST
:
try
:
v
=
REQUEST
[
"%s.%s"
%
(
id
,
arg
)]
except
(
KeyError
,
AttributeError
):
pass
r
[
name
]
=
REQUEST
[
idname
]
except
:
# Hm, we got another error, must have been an invalid
# input.
raise
'Bad Request'
,
(
'The value entered for <em>%s</em> was invalid'
%
arg
)
if
v
is
REQUEST
:
try
:
v
=
args
[
a
][
'default'
]
except
:
v
=
None
if
v
is
None
:
if
hasattr
(
self
,
arg
):
v
=
getattr
(
self
,
arg
)
else
:
if
return_missing_keys
:
missing_keys
.
append
(
arg
)
else
:
raise
self
.
MissingArgumentError
,
(
'''The required value <em>%s</em> was
ommitted'''
%
arg
)
if
raw
:
argdata
[
a
]
=
v
else
:
argdata
[
arg
]
=
v
if
return_missing_keys
and
missing_keys
:
raise
self
.
MissingArgumentError
,
missing_keys
return
argdata
def
_query_string
(
self
,
argdata
,
query_method
=
'query'
):
return
"%s?%s"
%
(
query_method
,
string
.
joinfields
(
map
(
lambda
k
,
d
=
argdata
:
"%s=%s"
%
(
k
,
urllib
.
quote
(
str
(
d
[
k
])))
,
argdata
.
keys
())
)
)
try
:
r
[
name
]
=
REQUEST
[
name
]
except
:
arg
=
args
[
name
]
try
:
r
[
name
]
=
arg
[
'default'
]
except
:
try
:
if
not
arg
[
'optional'
]:
missing
.
append
(
name
)
except
:
missing
.
append
(
name
)
if
missing
:
raise
self
.
MissingArgumentError
,
missing
return
r
_col
=
None
_arg
=
{}
class
Searchable
(
BaseQuery
):
def
_searchable_arguments
(
self
):
return
self
.
_arg
def
_searchable_result_columns
(
self
):
return
self
.
_col
def
manage_testForm
(
self
,
REQUEST
):
"""Provide testing interface"""
input_src
=
default_input_form
(
self
.
title_or_id
(),
self
.
_arg
,
'manage_test'
)
return
HTML
(
input_src
)(
self
,
REQUEST
)
def
manage_test
(
self
,
REQUEST
):
'Perform an actual query'
result
=
self
(
REQUEST
)
report
=
HTML
(
custom_default_report
(
self
.
id
,
result
))
return
apply
(
report
,(
self
,
REQUEST
),{
self
.
id
:
result
})
def
index_html
(
self
,
PARENT_URL
):
" "
raise
'Redirect'
,
(
"%s/manage_testForm"
%
PARENT_URL
)
class
Composite
:
def
_getquery
(
self
,
id
):
o
=
self
i
=
0
while
1
:
__traceback_info__
=
o
q
=
getattr
(
o
,
id
)
try
:
if
hasattr
(
q
,
'_searchable_arguments'
):
try
:
q
=
q
.
__of__
(
self
.
aq_parent
)
except
:
pass
return
q
except
:
pass
if
i
>
100
:
raise
AttributeError
,
id
i
=
i
+
1
o
=
o
.
aq_parent
def
myQueryIds
(
self
):
return
map
(
lambda
k
,
queries
=
self
.
queries
:
{
'id'
:
k
,
'selected'
:
k
in
queries
},
self
.
aqueductQueryIds
())
def
default_input_form
(
id
,
arguments
,
action
=
'query'
):
if
arguments
:
...
...
@@ -114,7 +130,7 @@ def default_input_form(id,arguments,action='query'):
string
.
joinfields
(
map
(
lambda
a
:
(
'<tr>
\
t
<t
d><strong>%s</strong>:</td
>
\
n
'
(
'<tr>
\
t
<t
h>%s</th
>
\
n
'
'
\
t
<td><input name="%s" width=30 value="%s">'
'</td></tr>'
%
(
nicify
(
a
[
0
]),
...
...
@@ -128,7 +144,7 @@ def default_input_form(id,arguments,action='query'):
,
items
),
'
\
n
'
),
'
\
n
<tr><td
></td><td
>
\
n
'
'
\
n
<tr><td
colspan=2 align=center
>
\
n
'
'<input type="SUBMIT" name="SUBMIT" value="Submit Query">
\
n
'
'<!--#if HTTP_REFERER-->
\
n
'
' <input type="SUBMIT" name="SUBMIT" value="Cancel">
\
n
'
...
...
@@ -201,44 +217,6 @@ def decodestring(s):
decode
(
f
,
g
)
return
g
.
getvalue
()
def
parse
(
text
,
prefix
=
None
,
result
=
None
,
unparmre
=
regex
.
compile
(
'
\
([
\
0- ]*
\
([^
\
0- =
\
"
]+
\
)
\
)'
),
parmre
=
regex
.
compile
(
'
\
([
\
0- ]*
\
([^
\
0- =
\
"
]+
\
)=
\
([^
\
0
- =
\
"
]+
\
)
\
)'
),
qparmre
=
regex
.
compile
(
'
\
([
\
0- ]*
\
([^
\
0- =
\
"
]+
\
)=
"
\
([^
"
]+
\
)
\
"
\
)
'
),
):
if result is None: result = {}
__traceback_info__=text
if parmre.match(text) >= 0:
name=parmre.group(2)
value=parmre.group(3)
l=len(parmre.group(1))
elif qparmre.match(text) >= 0:
name=qparmre.group(2)
value=qparmre.group(3)
l=len(qparmre.group(1))
elif unparmre.match(text) >= 0:
name=unparmre.group(2)
l=len(unparmre.group(1))
if prefix: name="%s.%s" % (prefix,name)
result[name]=None
return parse(text[l:],prefix,result)
else:
if not text or not strip(text): return result
raise InvalidParameter, text
if prefix: name="%s.%s" % (prefix,name)
result[name]=value
return parse(text[l:],prefix,result)
def
parse
(
text
,
result
=
None
,
unparmre
=
regex
.
compile
(
...
...
@@ -365,6 +343,9 @@ def delimited_output(results,REQUEST,RESPONSE):
##############################################################################
#
# $Log: Aqueduct.py,v $
# Revision 1.12 1997/09/26 22:17:36 jim
# more
#
# Revision 1.11 1997/09/25 22:33:01 jim
# fixed argument handling bugs
#
...
...
lib/python/Shared/DC/ZRDB/DA.py
View file @
8cb512a3
...
...
@@ -11,8 +11,8 @@
__doc__
=
'''Generic Database adapter
$Id: DA.py,v 1.1
1 1997/09/25 21:11:52
jim Exp $'''
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
$Id: DA.py,v 1.1
2 1997/09/26 22:17:45
jim Exp $'''
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
import
string
,
OFS
.
Folder
,
Aqueduct
.
Aqueduct
,
Aqueduct
.
RDB
import
DocumentTemplate
,
marshal
,
md5
,
zlib
,
base64
,
DateTime
,
Acquisition
...
...
@@ -157,8 +157,7 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit):
except
:
raise
'Database Error'
,
(
'%s is not connected to a database'
%
self
.
id
)
argdata
=
self
.
_argdata
(
REQUEST
,
1
)
query_string
=
self
.
_query_string
(
argdata
,
'manage_test'
)
argdata
=
self
.
_argdata
(
REQUEST
)
query
=
self
.
template
(
self
,
argdata
)
result
=
DB__
.
query
(
query
)
result
=
Aqueduct
.
RDB
.
File
(
StringIO
(
result
))
...
...
@@ -210,6 +209,9 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit):
##############################################################################
#
# $Log: DA.py,v $
# Revision 1.12 1997/09/26 22:17:45 jim
# more
#
# Revision 1.11 1997/09/25 21:11:52 jim
# got rid of constructor
#
...
...
lib/python/Shared/DC/ZRDB/RDB.py
View file @
8cb512a3
...
...
@@ -11,8 +11,8 @@
__doc__
=
'''Class for reading RDB files
$Id: RDB.py,v 1.
4 1997/09/25 18:40:58
jim Exp $'''
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
$Id: RDB.py,v 1.
5 1997/09/26 22:17:37
jim Exp $'''
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
regex
,
regsub
from
string
import
split
,
strip
,
lower
,
atof
,
atoi
,
atol
...
...
@@ -101,6 +101,8 @@ class File:
# Create a record class to hold the records.
class r(Record): pass
r.__record_schema__=schema
for k in filter(lambda k: k[:2]=='
__
', Record.__dict__.keys()):
setattr(r,k,getattr(Record,k))
self._class=r
# OK, we'
ve
read
meta
data
,
now
get
line
indexes
...
...
@@ -157,6 +159,9 @@ class File:
##############################################################################
#
# $Log: RDB.py,v $
# Revision 1.5 1997/09/26 22:17:37 jim
# more
#
# Revision 1.4 1997/09/25 18:40:58 jim
# new interfaces and RDB
#
...
...
lib/python/Shared/DC/ZRDB/edit.dtml
View file @
8cb512a3
...
...
@@ -36,7 +36,7 @@ Edit
<td><input name="arguments" size="40" value="<!--#var arguments_src-->"></td>
</tr>
<tr> <td colspan=2><strong>Query template:</strong><br>
<textarea name="template" rows=10 cols=60>
<textarea name="template
:text
" rows=10 cols=60>
<!--#var quoted_src-->
</textarea></td></tr>
...
...
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