Commit 1132c94a authored by Jim Fulton's avatar Jim Fulton

new interfaces

parent 9e603ad7
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
__doc__='''Generic Database adapter __doc__='''Generic Database adapter
$Id: DA.py,v 1.8 1997/09/25 17:35:30 jim Exp $''' $Id: DA.py,v 1.9 1997/09/25 18:41:20 jim Exp $'''
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[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
...@@ -23,6 +23,7 @@ from Globals import Persistent, HTMLFile, MessageDialog ...@@ -23,6 +23,7 @@ from Globals import Persistent, HTMLFile, MessageDialog
from cStringIO import StringIO from cStringIO import StringIO
log_file=None log_file=None
import sys, traceback import sys, traceback
from DocumentTemplate import HTML
class Folder(OFS.Folder.Folder): class Folder(OFS.Folder.Folder):
icon ='AqueductDA/DBAdapterFolder_icon.gif' icon ='AqueductDA/DBAdapterFolder_icon.gif'
...@@ -106,51 +107,55 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit): ...@@ -106,51 +107,55 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit):
icon ='AqueductDA/DBAdapter_icon.gif' icon ='AqueductDA/DBAdapter_icon.gif'
meta_type='Aqueduct Database Adapter' meta_type='Aqueduct Database Adapter'
hasAqueductClientInterface=1 hasAqueductClientInterface=1
_col=None
manage=HTMLFile('AqueductDA/edit') manage=HTMLFile('AqueductDA/edit')
def __init__(self,id='',key='',arguments='',template='',title=''): def __init__(self,id='',key='',arguments='',template='',title=''):
if not id: return if not id: return
self.id=id self.id=id
self.report_src=default_report_src
self.manage_edit(key,title,arguments,template) self.manage_edit(key,title,arguments,template)
def quoted_src(self): return quotedHTML(self.src) def quoted_src(self): return quotedHTML(self.src)
def manage_edit(self,key,title,arguments,template,URL2=''): def manage_edit(self,key,title,arguments,template,REQUEST=None):
'change query properties' 'change query properties'
self.title=title self.title=title
self.key=key self.key=key
self.rotor=Rotor(key) self.rotor=Rotor(key)
self.arguments_src=arguments self.arguments_src=arguments
self.arguments=parse(arguments) self._arg=parse(arguments)
self.src=template self.src=template
self.template=DocumentTemplate.HTML(template) self.template=DocumentTemplate.HTML(template)
self.manage_testForm=DocumentTemplate.HTML( if REQUEST:
default_input_form(self.id,self.arguments,
action='manage_test'),
__name__='test input form')
if URL2:
return MessageDialog( return MessageDialog(
title=self.id+' changed', title=self.id+' changed',
message=self.id+' has been changed sucessfully.', message=self.id+' has been changed sucessfully.',
action=URL2+'/manage_main', action=REQUEST['URL2']+'/manage_main',
) )
def query_data(self,REQUEST):
try: DB__=self.database_connection()
except: raise 'Database Error', (
'%s is not connected to a database' % self.id)
argdata=self._argdata(REQUEST,1) def manage_testForm(self, REQUEST):
query_string=self._query_string(argdata,'manage_test') """Provide testing interface"""
query=self.template(self,argdata) input_src=default_input_form(self.title_or_id(),
result=DB__.query(query) self._arg, 'manage_test')
result=Aqueduct.RDB.RDB(StringIO(result)) return HTML(input_src)(self, REQUEST)
return result
def manage_test(self, REQUEST):
'Perform an actual query'
def manage_test(self,REQUEST): result=self(REQUEST)
'Provide a simple interface for testing a query' 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)
def _searchable_arguments(self): return self._arg
def _searchable_result_columns(self): return self._col
def __call__(self,REQUEST):
try: DB__=self.database_connection() try: DB__=self.database_connection()
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)
...@@ -159,20 +164,10 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit): ...@@ -159,20 +164,10 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit):
query_string=self._query_string(argdata,'manage_test') 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.RDB(StringIO(result)) result=Aqueduct.RDB.File(StringIO(result))
result_names=result.names() columns=result._searchable_result_columns()
report_src=custom_default_report(result,action='/manage_testForm') if columns != self._col: self._col=columns
return result
if result_names != self.result_names or report_src != self.report_src:
self.result_names=names
self.report_src=report_src
report=DocumentTemplate.HTML(report_src)
return report(self,REQUEST,
query_results=result,
query_string=query_string,
)
def query(self,REQUEST,RESPONSE): def query(self,REQUEST,RESPONSE):
' ' ' '
...@@ -218,6 +213,9 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit): ...@@ -218,6 +213,9 @@ class Query(Aqueduct.Aqueduct.BaseQuery,Persistent,Acquisition.Implicit):
############################################################################## ##############################################################################
# #
# $Log: DA.py,v $ # $Log: DA.py,v $
# Revision 1.9 1997/09/25 18:41:20 jim
# new interfaces
#
# Revision 1.8 1997/09/25 17:35:30 jim # Revision 1.8 1997/09/25 17:35:30 jim
# Made some corrections for network behavior. # Made some corrections for network behavior.
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment