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
Show 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 @@
...
@@ -10,18 +10,22 @@
##############################################################################
##############################################################################
__doc__
=
'''Shared Aqueduct classes and functions
__doc__
=
'''Shared Aqueduct classes and functions
$Id: Aqueduct.py,v 1.1
1 1997/09/25 22:33:01
jim Exp $'''
$Id: Aqueduct.py,v 1.1
2 1997/09/26 22:17:36
jim Exp $'''
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
__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
DocumentTemplate
,
DateTime
,
regex
,
regsub
,
string
,
urllib
,
rotor
import
binascii
import
binascii
,
Acquisition
DateTime
.
now
=
DateTime
.
DateTime
DateTime
.
now
=
DateTime
.
DateTime
from
cStringIO
import
StringIO
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
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_year
(
self
):
return
self
.
query_date
.
year
()
def
query_month
(
self
):
return
self
.
query_date
.
month
()
def
query_month
(
self
):
return
self
.
query_date
.
month
()
def
query_day
(
self
):
return
self
.
query_date
.
day
()
def
query_day
(
self
):
return
self
.
query_date
.
day
()
...
@@ -33,70 +37,82 @@ class BaseQuery:
...
@@ -33,70 +37,82 @@ class BaseQuery:
MissingArgumentError
=
'Bad Request'
MissingArgumentError
=
'Bad Request'
def
_argdata
(
self
,
REQUEST
,
raw
=
0
,
return_missing_keys
=
0
):
def
_argdata
(
self
,
REQUEST
):
r
=
{}
args
=
self
.
_arg
args
=
self
.
_arg
argdata
=
{}
id
=
self
.
id
id
=
self
.
id
missing_keys
=
[]
missing
=
[]
for
arg
in
args
.
keys
():
a
=
arg
for
name
in
args
.
keys
():
l
=
string
.
find
(
arg
,
':'
)
idname
=
"%s/%s"
%
(
id
,
name
)
if
l
>
0
:
arg
=
arg
[:
l
]
v
=
REQUEST
try
:
try
:
try
:
v
=
REQUEST
[
arg
]
r
[
name
]
=
REQUEST
[
idname
]
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
except
:
except
:
# Hm, we got another error, must have been an invalid
try
:
r
[
name
]
=
REQUEST
[
name
]
# input.
except
:
raise
'Bad Request'
,
(
arg
=
args
[
name
]
'The value entered for <em>%s</em> was invalid'
%
arg
)
try
:
r
[
name
]
=
arg
[
'default'
]
except
:
if
v
is
REQUEST
:
try
:
try
:
v
=
args
[
a
][
'default'
]
if
not
arg
[
'optional'
]:
missing
.
append
(
name
)
except
:
v
=
None
except
:
missing
.
append
(
name
)
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
:
if
missing
:
argdata
[
a
]
=
v
raise
self
.
MissingArgumentError
,
missing
else
:
argdata
[
arg
]
=
v
if
return_missing_keys
and
missing_keys
:
return
r
raise
self
.
MissingArgumentError
,
missing_keys
return
argdata
_col
=
None
_arg
=
{}
def
_query_string
(
self
,
argdata
,
query_method
=
'query'
):
class
Searchable
(
BaseQuery
):
return
"%s?%s"
%
(
query_method
,
def
_searchable_arguments
(
self
):
return
self
.
_arg
string
.
joinfields
(
map
(
lambda
k
,
d
=
argdata
:
"%s=%s"
%
(
k
,
urllib
.
quote
(
str
(
d
[
k
])))
,
argdata
.
keys
())
)
)
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'
):
def
default_input_form
(
id
,
arguments
,
action
=
'query'
):
if
arguments
:
if
arguments
:
...
@@ -114,7 +130,7 @@ def default_input_form(id,arguments,action='query'):
...
@@ -114,7 +130,7 @@ def default_input_form(id,arguments,action='query'):
string
.
joinfields
(
string
.
joinfields
(
map
(
map
(
lambda
a
:
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">'
'
\
t
<td><input name="%s" width=30 value="%s">'
'</td></tr>'
'</td></tr>'
%
(
nicify
(
a
[
0
]),
%
(
nicify
(
a
[
0
]),
...
@@ -128,7 +144,7 @@ def default_input_form(id,arguments,action='query'):
...
@@ -128,7 +144,7 @@ def default_input_form(id,arguments,action='query'):
,
items
,
items
),
),
'
\
n
'
),
'
\
n
'
),
'
\
n
<tr><td
></td><td
>
\
n
'
'
\
n
<tr><td
colspan=2 align=center
>
\
n
'
'<input type="SUBMIT" name="SUBMIT" value="Submit Query">
\
n
'
'<input type="SUBMIT" name="SUBMIT" value="Submit Query">
\
n
'
'<!--#if HTTP_REFERER-->
\
n
'
'<!--#if HTTP_REFERER-->
\
n
'
' <input type="SUBMIT" name="SUBMIT" value="Cancel">
\
n
'
' <input type="SUBMIT" name="SUBMIT" value="Cancel">
\
n
'
...
@@ -201,44 +217,6 @@ def decodestring(s):
...
@@ -201,44 +217,6 @@ def decodestring(s):
decode
(
f
,
g
)
decode
(
f
,
g
)
return
g
.
getvalue
()
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
,
def
parse
(
text
,
result
=
None
,
result
=
None
,
unparmre
=
regex
.
compile
(
unparmre
=
regex
.
compile
(
...
@@ -365,6 +343,9 @@ def delimited_output(results,REQUEST,RESPONSE):
...
@@ -365,6 +343,9 @@ def delimited_output(results,REQUEST,RESPONSE):
##############################################################################
##############################################################################
#
#
# $Log: Aqueduct.py,v $
# $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
# Revision 1.11 1997/09/25 22:33:01 jim
# fixed argument handling bugs
# fixed argument handling bugs
#
#
...
...
lib/python/Shared/DC/ZRDB/DA.py
View file @
8cb512a3
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
__doc__
=
'''Generic Database adapter
__doc__
=
'''Generic Database adapter
$Id: DA.py,v 1.1
1 1997/09/25 21:11:52
jim Exp $'''
$Id: DA.py,v 1.1
2 1997/09/26 22:17:45
jim Exp $'''
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
2
$'
[
11
:
-
2
]
import
string
,
OFS
.
Folder
,
Aqueduct
.
Aqueduct
,
Aqueduct
.
RDB
import
string
,
OFS
.
Folder
,
Aqueduct
.
Aqueduct
,
Aqueduct
.
RDB
import
DocumentTemplate
,
marshal
,
md5
,
zlib
,
base64
,
DateTime
,
Acquisition
import
DocumentTemplate
,
marshal
,
md5
,
zlib
,
base64
,
DateTime
,
Acquisition
...
@@ -157,8 +157,7 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit):
...
@@ -157,8 +157,7 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit):
except
:
raise
'Database Error'
,
(
except
:
raise
'Database Error'
,
(
'%s is not connected to a database'
%
self
.
id
)
'%s is not connected to a database'
%
self
.
id
)
argdata
=
self
.
_argdata
(
REQUEST
,
1
)
argdata
=
self
.
_argdata
(
REQUEST
)
query_string
=
self
.
_query_string
(
argdata
,
'manage_test'
)
query
=
self
.
template
(
self
,
argdata
)
query
=
self
.
template
(
self
,
argdata
)
result
=
DB__
.
query
(
query
)
result
=
DB__
.
query
(
query
)
result
=
Aqueduct
.
RDB
.
File
(
StringIO
(
result
))
result
=
Aqueduct
.
RDB
.
File
(
StringIO
(
result
))
...
@@ -210,6 +209,9 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit):
...
@@ -210,6 +209,9 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit):
##############################################################################
##############################################################################
#
#
# $Log: DA.py,v $
# $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
# Revision 1.11 1997/09/25 21:11:52 jim
# got rid of constructor
# got rid of constructor
#
#
...
...
lib/python/Shared/DC/ZRDB/RDB.py
View file @
8cb512a3
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
__doc__
=
'''Class for reading RDB files
__doc__
=
'''Class for reading RDB files
$Id: RDB.py,v 1.
4 1997/09/25 18:40:58
jim Exp $'''
$Id: RDB.py,v 1.
5 1997/09/26 22:17:37
jim Exp $'''
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
regex
,
regsub
import
regex
,
regsub
from
string
import
split
,
strip
,
lower
,
atof
,
atoi
,
atol
from
string
import
split
,
strip
,
lower
,
atof
,
atoi
,
atol
...
@@ -101,6 +101,8 @@ class File:
...
@@ -101,6 +101,8 @@ class File:
# Create a record class to hold the records.
# Create a record class to hold the records.
class r(Record): pass
class r(Record): pass
r.__record_schema__=schema
r.__record_schema__=schema
for k in filter(lambda k: k[:2]=='
__
', Record.__dict__.keys()):
setattr(r,k,getattr(Record,k))
self._class=r
self._class=r
# OK, we'
ve
read
meta
data
,
now
get
line
indexes
# OK, we'
ve
read
meta
data
,
now
get
line
indexes
...
@@ -157,6 +159,9 @@ class File:
...
@@ -157,6 +159,9 @@ class File:
##############################################################################
##############################################################################
#
#
# $Log: RDB.py,v $
# $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
# Revision 1.4 1997/09/25 18:40:58 jim
# new interfaces and RDB
# new interfaces and RDB
#
#
...
...
lib/python/Shared/DC/ZRDB/edit.dtml
View file @
8cb512a3
...
@@ -36,7 +36,7 @@ Edit
...
@@ -36,7 +36,7 @@ Edit
<td><input name="arguments" size="40" value="<!--#var arguments_src-->"></td>
<td><input name="arguments" size="40" value="<!--#var arguments_src-->"></td>
</tr>
</tr>
<tr> <td colspan=2><strong>Query template:</strong><br>
<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-->
<!--#var quoted_src-->
</textarea></td></tr>
</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