Commit cee6532e authored by Jim Fulton's avatar Jim Fulton

new copyright and detabification

parent 39adaf2e
database_type='Gadfly' ##############################################################################
###########################################################################
#
# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
# rights reserved.
# #
########################################################################### # Zope Public License (ZPL) Version 0.9.5
# ---------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Any use, including use of the Zope software to operate a website,
# must either comply with the terms described below under
# "Attribution" or alternatively secure a separate license from
# Digital Creations. Digital Creations will not unreasonably
# deny such a separate license in the event that the request
# explains in detail a valid reason for withholding attribution.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Attribution
#
# Individuals or organizations using this software as a web site must
# provide attribution by placing the accompanying "button" and a link
# to the accompanying "credits page" on the website's main entry
# point. In cases where this placement of attribution is not
# feasible, a separate arrangment must be concluded with Digital
# Creations. Those using the software for purposes other than web
# sites must provide a corresponding attribution in locations that
# include a copyright using a manner best suited to the application
# environment. Where attribution is not possible, or is considered
# to be onerous for some other reason, a request should be made to
# Digital Creations to waive this requirement in writing. As stated
# above, for valid requests, Digital Creations will not unreasonably
# deny such requests.
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
database_type='Gadfly'
__doc__='''%s Database Connection __doc__='''%s Database Connection
$Id: DA.py,v 1.4 1998/12/15 21:09:55 jim Exp $''' % database_type $Id: DA.py,v 1.5 1998/12/16 15:28:47 jim Exp $''' % database_type
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
from db import DB, manage_DataSources from db import DB, manage_DataSources
import sys, DABase, Globals import sys, DABase, Globals
...@@ -20,16 +107,16 @@ _connections={} ...@@ -20,16 +107,16 @@ _connections={}
def data_sources(): def data_sources():
return filter(lambda ds, used=_connections.has_key: not used(ds[0]), return filter(lambda ds, used=_connections.has_key: not used(ds[0]),
manage_DataSources()) manage_DataSources())
addConnectionForm=Globals.HTMLFile('connectionAdd',globals()) addConnectionForm=Globals.HTMLFile('connectionAdd',globals())
def manage_addZGadflyConnection( def manage_addZGadflyConnection(
self, id, title, connection, check=None, REQUEST=None): self, id, title, connection, check=None, REQUEST=None):
"""Add a DB connection to a folder""" """Add a DB connection to a folder"""
self._setObject(id, Connection( self._setObject(id, Connection(
id, title, connection, check)) id, title, connection, check))
if REQUEST is not None: return self.manage_main(self,REQUEST) if REQUEST is not None: return self.manage_main(self,REQUEST)
return self.manage_main(self,REQUEST) return self.manage_main(self,REQUEST)
class Connection(DABase.Connection): class Connection(DABase.Connection):
" " " "
...@@ -41,39 +128,22 @@ class Connection(DABase.Connection): ...@@ -41,39 +128,22 @@ class Connection(DABase.Connection):
def factory(self): return DB def factory(self): return DB
def connect(self,s): def connect(self,s):
c=_connections c=_connections
if c.has_key(s) and c[s] != self._p_oid: if c.has_key(s) and c[s] != self._p_oid:
raise 'In Use', ( raise 'In Use', (
'The database <em>%s</em> is in use.' % s) 'The database <em>%s</em> is in use.' % s)
c[s]=self._p_oid c[s]=self._p_oid
return Connection.inheritedAttribute('connect')(self, s) return Connection.inheritedAttribute('connect')(self, s)
def __del__(self): def __del__(self):
s=self.connection_string s=self.connection_string
c=_connections c=_connections
if c.has_key(s) and c[s] == self._p_oid: del c[s] if c.has_key(s) and c[s] == self._p_oid: del c[s]
def manage_close_connection(self, REQUEST): def manage_close_connection(self, REQUEST):
" " " "
s=self.connection_string s=self.connection_string
c=_connections c=_connections
if c.has_key(s) and c[s] == self._p_oid: del c[s] if c.has_key(s) and c[s] == self._p_oid: del c[s]
return Connection.inheritedAttribute('manage_close_connection')( return Connection.inheritedAttribute('manage_close_connection')(
self, REQUEST) self, REQUEST)
##############################################################################
#
# $Log: DA.py,v $
# Revision 1.4 1998/12/15 21:09:55 jim
# first Zope
#
# Revision 1.3 1998/12/02 12:11:48 jim
# new names, esp for Aqueduct
#
# Revision 1.2 1998/06/10 22:28:37 jim
# Added docstring to connection object so objects are publishable.
#
# Revision 1.1 1998/04/15 15:10:37 jim
# initial
#
This diff is collapsed.
############################################################################## ##############################################################################
# #
# Copyright # Zope Public License (ZPL) Version 0.9.5
# # ---------------------------------------
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne #
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All # Copyright (c) Digital Creations. All rights reserved.
# rights reserved. #
# # Redistribution and use in source and binary forms, with or without
############################################################################## # modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Any use, including use of the Zope software to operate a website,
# must either comply with the terms described below under
# "Attribution" or alternatively secure a separate license from
# Digital Creations. Digital Creations will not unreasonably
# deny such a separate license in the event that the request
# explains in detail a valid reason for withholding attribution.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Attribution
#
# Individuals or organizations using this software as a web site must
# provide attribution by placing the accompanying "button" and a link
# to the accompanying "credits page" on the website's main entry
# point. In cases where this placement of attribution is not
# feasible, a separate arrangment must be concluded with Digital
# Creations. Those using the software for purposes other than web
# sites must provide a corresponding attribution in locations that
# include a copyright using a manner best suited to the application
# environment. Where attribution is not possible, or is considered
# to be onerous for some other reason, a request should be made to
# Digital Creations to waive this requirement in writing. As stated
# above, for valid requests, Digital Creations will not unreasonably
# deny such requests.
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
__doc__='''Generic Database Adapter Package Registration __doc__='''Generic Database Adapter Package Registration
$Id: __init__.py,v 1.6 1998/12/16 15:04:00 jim Exp $''' $Id: __init__.py,v 1.7 1998/12/16 15:28:47 jim Exp $'''
__version__='$Revision: 1.6 $'[11:-2] __version__='$Revision: 1.7 $'[11:-2]
import Globals, ImageFile, os import Globals, ImageFile, os
...@@ -22,8 +109,8 @@ misc_={'conn': ...@@ -22,8 +109,8 @@ misc_={'conn':
for icon in ('table', 'view', 'stable', 'what', for icon in ('table', 'view', 'stable', 'what',
'field', 'text','bin','int','float', 'field', 'text','bin','int','float',
'date','time','datetime'): 'date','time','datetime'):
misc_[icon]=ImageFile.ImageFile('icons/%s.gif' % icon, globals()) misc_[icon]=ImageFile.ImageFile('icons/%s.gif' % icon, globals())
meta_types=( meta_types=(
...@@ -36,10 +123,10 @@ DA=None ...@@ -36,10 +123,10 @@ DA=None
def getDA(): def getDA():
global DA global DA
if DA is None: if DA is None:
home=Globals.package_home(globals()) home=Globals.package_home(globals())
from gadfly import sqlwhere from gadfly import sqlwhere
sqlwhere.filename="%s/gadfly/sql.mar" % home sqlwhere.filename="%s/gadfly/sql.mar" % home
import DA import DA
return DA return DA
getDA() getDA()
...@@ -48,15 +135,15 @@ def manage_addZGadflyConnectionForm(self, REQUEST, *args, **kw): ...@@ -48,15 +135,15 @@ def manage_addZGadflyConnectionForm(self, REQUEST, *args, **kw):
" " " "
DA=getDA() DA=getDA()
return DA.addConnectionForm( return DA.addConnectionForm(
self,REQUEST, self,REQUEST,
database_type=database_type, database_type=database_type,
data_sources=DA.data_sources) data_sources=DA.data_sources)
def manage_addZGadflyConnection( def manage_addZGadflyConnection(
self, id, title, connection, check=None, REQUEST=None): self, id, title, connection, check=None, REQUEST=None):
" " " "
return getDA().manage_addZGadflyConnection( return getDA().manage_addZGadflyConnection(
self, id, title, connection, check, REQUEST) self, id, title, connection, check, REQUEST)
methods={ methods={
'manage_addZGadflyConnection': 'manage_addZGadflyConnection':
......
This diff is collapsed.
#!/bin/env python ##############################################################################
##############################################################################
# #
# Copyright # Zope Public License (ZPL) Version 0.9.5
# # ---------------------------------------
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne #
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All # Copyright (c) Digital Creations. All rights reserved.
# rights reserved. #
# # Redistribution and use in source and binary forms, with or without
############################################################################## # modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Any use, including use of the Zope software to operate a website,
# must either comply with the terms described below under
# "Attribution" or alternatively secure a separate license from
# Digital Creations. Digital Creations will not unreasonably
# deny such a separate license in the event that the request
# explains in detail a valid reason for withholding attribution.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Attribution
#
# Individuals or organizations using this software as a web site must
# provide attribution by placing the accompanying "button" and a link
# to the accompanying "credits page" on the website's main entry
# point. In cases where this placement of attribution is not
# feasible, a separate arrangment must be concluded with Digital
# Creations. Those using the software for purposes other than web
# sites must provide a corresponding attribution in locations that
# include a copyright using a manner best suited to the application
# environment. Where attribution is not possible, or is considered
# to be onerous for some other reason, a request should be made to
# Digital Creations to waive this requirement in writing. As stated
# above, for valid requests, Digital Creations will not unreasonably
# deny such requests.
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
__doc__='''SQL Methods __doc__='''SQL Methods
$Id: SQL.py,v 1.7 1998/12/15 21:10:31 jim Exp $''' $Id: SQL.py,v 1.8 1998/12/16 15:29:22 jim Exp $'''
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
import Shared.DC.ZRDB.DA import Shared.DC.ZRDB.DA
from Globals import HTMLFile from Globals import HTMLFile
...@@ -27,18 +113,18 @@ def SQLConnectionIDs(self): ...@@ -27,18 +113,18 @@ def SQLConnectionIDs(self):
StringType=type('') StringType=type('')
while self is not None: while self is not None:
if hasattr(self, 'objectValues'): if hasattr(self, 'objectValues'):
for o in self.objectValues(): for o in self.objectValues():
if (hasattr(o,'_isAnSQLConnection') and o._isAnSQLConnection if (hasattr(o,'_isAnSQLConnection') and o._isAnSQLConnection
and hasattr(o,'id')): and hasattr(o,'id')):
id=o.id id=o.id
if type(id) is not StringType: id=id() if type(id) is not StringType: id=id()
if not have_id(id): if not have_id(id):
if hasattr(o,'title_and_id'): o=o.title_and_id() if hasattr(o,'title_and_id'): o=o.title_and_id()
else: o=id else: o=id
ids[id]=id ids[id]=id
if hasattr(self, 'aq_parent'): self=self.aq_parent if hasattr(self, 'aq_parent'): self=self.aq_parent
else: self=None else: self=None
ids=map(lambda item: (item[1], item[0]), ids.items()) ids=map(lambda item: (item[1], item[0]), ids.items())
ids.sort() ids.sort()
...@@ -46,8 +132,8 @@ def SQLConnectionIDs(self): ...@@ -46,8 +132,8 @@ def SQLConnectionIDs(self):
manage_addZSQLMethodForm=HTMLFile('add', globals()) manage_addZSQLMethodForm=HTMLFile('add', globals())
def manage_addZSQLMethod(self, id, title, def manage_addZSQLMethod(self, id, title,
connection_id, arguments, template, connection_id, arguments, template,
REQUEST=None): REQUEST=None):
"""Add an SQL Method """Add an SQL Method
The 'connection_id' argument is the id of a database connection The 'connection_id' argument is the id of a database connection
...@@ -73,9 +159,9 @@ class SQL(Shared.DC.ZRDB.DA.DA): ...@@ -73,9 +159,9 @@ class SQL(Shared.DC.ZRDB.DA.DA):
- Method - Method
SQL Methods behave like methods of the folders they are SQL Methods behave like methods of the folders they are
accessed in. In particular, they can be used from other accessed in. In particular, they can be used from other
methods, like Documents, ExternalMethods, and even other SQL methods, like Documents, ExternalMethods, and even other SQL
Methods. Methods.
- Searchability - Searchability
...@@ -85,8 +171,8 @@ class SQL(Shared.DC.ZRDB.DA.DA): ...@@ -85,8 +171,8 @@ class SQL(Shared.DC.ZRDB.DA.DA):
unions. They provide meta-data about their input parameters unions. They provide meta-data about their input parameters
and result data. and result data.
For more information, see the searchable-object interface For more information, see the searchable-object interface
specification. specification.
- Containment - Containment
...@@ -98,11 +184,11 @@ class SQL(Shared.DC.ZRDB.DA.DA): ...@@ -98,11 +184,11 @@ class SQL(Shared.DC.ZRDB.DA.DA):
folder). The 'service_record' method could be accessed with a folder). The 'service_record' method could be accessed with a
URL like:: URL like::
employees/employee_id/1234/service_record employees/employee_id/1234/service_record
""" """
meta_type='Z SQL Method' meta_type='Z SQL Method'
icon='misc_/ZSQLMethods/icon' icon='misc_/ZSQLMethods/icon'
manage_main=HTMLFile('edit', globals()) manage_main=HTMLFile('edit', globals())
#!/bin/env python ##############################################################################
##############################################################################
# #
# Copyright # Zope Public License (ZPL) Version 0.9.5
# # ---------------------------------------
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne #
# Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All # Copyright (c) Digital Creations. All rights reserved.
# rights reserved. #
# # Redistribution and use in source and binary forms, with or without
############################################################################## # modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Any use, including use of the Zope software to operate a website,
# must either comply with the terms described below under
# "Attribution" or alternatively secure a separate license from
# Digital Creations. Digital Creations will not unreasonably
# deny such a separate license in the event that the request
# explains in detail a valid reason for withholding attribution.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Attribution
#
# Individuals or organizations using this software as a web site must
# provide attribution by placing the accompanying "button" and a link
# to the accompanying "credits page" on the website's main entry
# point. In cases where this placement of attribution is not
# feasible, a separate arrangment must be concluded with Digital
# Creations. Those using the software for purposes other than web
# sites must provide a corresponding attribution in locations that
# include a copyright using a manner best suited to the application
# environment. Where attribution is not possible, or is considered
# to be onerous for some other reason, a request should be made to
# Digital Creations to waive this requirement in writing. As stated
# above, for valid requests, Digital Creations will not unreasonably
# deny such requests.
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
__doc__='''SQL Method Product __doc__='''SQL Method Product
$Id: __init__.py,v 1.8 1998/12/16 15:04:42 jim Exp $''' $Id: __init__.py,v 1.9 1998/12/16 15:29:22 jim Exp $'''
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
from ImageFile import ImageFile from ImageFile import ImageFile
import Shared.DC.ZRDB.Search, SQL import Shared.DC.ZRDB.Search, SQL
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
##############################################################################
#
# Zope Public License (ZPL) Version 0.9.5
# ---------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Any use, including use of the Zope software to operate a website,
# must either comply with the terms described below under
# "Attribution" or alternatively secure a separate license from
# Digital Creations. Digital Creations will not unreasonably
# deny such a separate license in the event that the request
# explains in detail a valid reason for withholding attribution.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Attribution
#
# Individuals or organizations using this software as a web site must
# provide attribution by placing the accompanying "button" and a link
# to the accompanying "credits page" on the website's main entry
# point. In cases where this placement of attribution is not
# feasible, a separate arrangment must be concluded with Digital
# Creations. Those using the software for purposes other than web
# sites must provide a corresponding attribution in locations that
# include a copyright using a manner best suited to the application
# environment. Where attribution is not possible, or is considered
# to be onerous for some other reason, a request should be made to
# Digital Creations to waive this requirement in writing. As stated
# above, for valid requests, Digital Creations will not unreasonably
# deny such requests.
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
import ExtensionClass import ExtensionClass
import string import string
from string import strip, lower, upper, join from string import strip, lower, upper, join
...@@ -21,60 +117,60 @@ class Results: ...@@ -21,60 +117,60 @@ class Results:
self._data=data self._data=data
self.__items__=items self.__items__=items
self._parent=parent self._parent=parent
self._names=names=[] self._names=names=[]
self._schema=schema={} self._schema=schema={}
self._data_dictionary=dd={} self._data_dictionary=dd={}
aliases=[] aliases=[]
i=0 i=0
for item in items: for item in items:
name=item['name'] name=item['name']
name=strip(name) name=strip(name)
if not name: if not name:
raise ValueError, 'Empty column name, %s' % name raise ValueError, 'Empty column name, %s' % name
if schema.has_key(name): if schema.has_key(name):
raise ValueError, 'Duplicate column name, %s' % name raise ValueError, 'Duplicate column name, %s' % name
schema[name]=i schema[name]=i
n=lower(name) n=lower(name)
if n != name: aliases.append((n, SQLAlias(name))) if n != name: aliases.append((n, SQLAlias(name)))
n=upper(name) n=upper(name)
if n != name: aliases.append((n, SQLAlias(name))) if n != name: aliases.append((n, SQLAlias(name)))
dd[name]=item dd[name]=item
names.append(name) names.append(name)
i=i+1 i=i+1
self._nv=nv=len(names) self._nv=nv=len(names)
# Create a record class to hold the records. # Create a record class to hold the records.
names=tuple(names) names=tuple(names)
if record_classes.has_key((names,brains)): if record_classes.has_key((names,brains)):
r=record_classes[names,brains] r=record_classes[names,brains]
else: else:
class r(Record, Implicit, brains): class r(Record, Implicit, brains):
'Result record class' 'Result record class'
r.__record_schema__=schema r.__record_schema__=schema
for k in filter(lambda k: k[:2]=='__', Record.__dict__.keys()): for k in filter(lambda k: k[:2]=='__', Record.__dict__.keys()):
setattr(r,k,getattr(Record,k)) setattr(r,k,getattr(Record,k))
record_classes[names,brains]=r record_classes[names,brains]=r
# Add SQL Aliases # Add SQL Aliases
d=r.__dict__ d=r.__dict__
for k, v in aliases: for k, v in aliases:
if not hasattr(r,k): d[k]=v if not hasattr(r,k): d[k]=v
if hasattr(brains, '__init__'): if hasattr(brains, '__init__'):
binit=brains.__init__ binit=brains.__init__
if hasattr(binit,'im_func'): binit=binit.im_func if hasattr(binit,'im_func'): binit=binit.im_func
def __init__(self, data, parent, binit=binit): def __init__(self, data, parent, binit=binit):
Record.__init__(self,data) Record.__init__(self,data)
binit(self.__of__(parent)) binit(self.__of__(parent))
r.__dict__['__init__']=__init__ r.__dict__['__init__']=__init__
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
def _searchable_result_columns(self): return self.__items__ def _searchable_result_columns(self): return self.__items__
def names(self): return self._names def names(self): return self._names
...@@ -83,13 +179,13 @@ class Results: ...@@ -83,13 +179,13 @@ class Results:
def __len__(self): return len(self._data) def __len__(self): return len(self._data)
def __getitem__(self,index): def __getitem__(self,index):
if index==self._index: return self._row if index==self._index: return self._row
parent=self._parent parent=self._parent
fields=self._class(self._data[index], parent) fields=self._class(self._data[index], parent)
self._index=index self._index=index
self._row=fields self._row=fields
if parent is None: return fields if parent is None: return fields
return fields.__of__(parent) return fields.__of__(parent)
def asRDB(self): # Waaaaa def asRDB(self): # Waaaaa
r=[] r=[]
......
This diff is collapsed.
##############################################################################
#
# Zope Public License (ZPL) Version 0.9.5
# ---------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Any use, including use of the Zope software to operate a website,
# must either comply with the terms described below under
# "Attribution" or alternatively secure a separate license from
# Digital Creations. Digital Creations will not unreasonably
# deny such a separate license in the event that the request
# explains in detail a valid reason for withholding attribution.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Attribution
#
# Individuals or organizations using this software as a web site must
# provide attribution by placing the accompanying "button" and a link
# to the accompanying "credits page" on the website's main entry
# point. In cases where this placement of attribution is not
# feasible, a separate arrangment must be concluded with Digital
# Creations. Those using the software for purposes other than web
# sites must provide a corresponding attribution in locations that
# include a copyright using a manner best suited to the application
# environment. Where attribution is not possible, or is considered
# to be onerous for some other reason, a request should be made to
# Digital Creations to waive this requirement in writing. As stated
# above, for valid requests, Digital Creations will not unreasonably
# deny such requests.
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
This diff is collapsed.
##############################################################################
#
# Zope Public License (ZPL) Version 0.9.5
# ---------------------------------------
#
# Copyright (c) Digital Creations. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions in source code must retain the above copyright
# notice, this list of conditions, and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. Any use, including use of the Zope software to operate a website,
# must either comply with the terms described below under
# "Attribution" or alternatively secure a separate license from
# Digital Creations. Digital Creations will not unreasonably
# deny such a separate license in the event that the request
# explains in detail a valid reason for withholding attribution.
#
# 4. All advertising materials and documentation mentioning
# features derived from or use of this software must display
# the following acknowledgement:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# In the event that the product being advertised includes an
# intact Zope distribution (with copyright and license included)
# then this clause is waived.
#
# 5. Names associated with Zope or Digital Creations must not be used to
# endorse or promote products derived from this software without
# prior written permission from Digital Creations.
#
# 6. Modified redistributions of any form whatsoever must retain
# the following acknowledgment:
#
# "This product includes software developed by Digital Creations
# for use in the Z Object Publishing Environment
# (http://www.zope.org/)."
#
# Intact (re-)distributions of any official Zope release do not
# require an external acknowledgement.
#
# 7. Modifications are encouraged but must be packaged separately as
# patches to official Zope releases. Distributions that do not
# clearly separate the patches from the original work must be clearly
# labeled as unofficial distributions. Modifications which do not
# carry the name Zope may be packaged in any form, as long as they
# conform to all of the clauses above.
#
#
# Disclaimer
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Attribution
#
# Individuals or organizations using this software as a web site must
# provide attribution by placing the accompanying "button" and a link
# to the accompanying "credits page" on the website's main entry
# point. In cases where this placement of attribution is not
# feasible, a separate arrangment must be concluded with Digital
# Creations. Those using the software for purposes other than web
# sites must provide a corresponding attribution in locations that
# include a copyright using a manner best suited to the application
# environment. Where attribution is not possible, or is considered
# to be onerous for some other reason, a request should be made to
# Digital Creations to waive this requirement in writing. As stated
# above, for valid requests, Digital Creations will not unreasonably
# deny such requests.
#
# This software consists of contributions made by Digital Creations and
# many individuals on behalf of Digital Creations. Specific
# attributions are listed in the accompanying credits file.
#
##############################################################################
'''Inserting optional tests with 'sqlgroup' '''Inserting optional tests with 'sqlgroup'
...@@ -26,17 +122,17 @@ ...@@ -26,17 +122,17 @@
<!--#sqltest name column=nick_name type=nb multiple optional--> <!--#sqltest name column=nick_name type=nb multiple optional-->
<!--#or--> <!--#or-->
<!--#sqltest name column=first_name type=nb multiple optional--> <!--#sqltest name column=first_name type=nb multiple optional-->
<!--#/sqlgroup--> <!--#/sqlgroup-->
<!--#and--> <!--#and-->
<!--#sqltest home_town type=nb optional--> <!--#sqltest home_town type=nb optional-->
<!--#and--> <!--#and-->
<!--#if minimum_age--> <!--#if minimum_age-->
age >= <!--#sqlvar minimum_age type=int--> age >= <!--#sqlvar minimum_age type=int-->
<!--#/if--> <!--#/if-->
<!--#and--> <!--#and-->
<!--#if maximum_age--> <!--#if maximum_age-->
age <= <!--#sqlvar maximum_age type=int--> age <= <!--#sqlvar maximum_age type=int-->
<!--#/if--> <!--#/if-->
<!--#/sqlgroup--> <!--#/sqlgroup-->
This example illustrates how groups can be nested to control This example illustrates how groups can be nested to control
...@@ -57,8 +153,8 @@ ...@@ -57,8 +153,8 @@
# rights reserved. # rights reserved.
# #
############################################################################ ############################################################################
__rcs_id__='$Id: sqlgroup.py,v 1.4 1998/09/04 20:45:02 jim Exp $' __rcs_id__='$Id: sqlgroup.py,v 1.5 1998/12/16 15:25:49 jim Exp $'
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
from DocumentTemplate.DT_Util import parse_params from DocumentTemplate.DT_Util import parse_params
str=__builtins__['str'] str=__builtins__['str']
...@@ -73,50 +169,33 @@ class SQLGroup: ...@@ -73,50 +169,33 @@ class SQLGroup:
def __init__(self, blocks): def __init__(self, blocks):
self.blocks=blocks self.blocks=blocks
tname, args, section = blocks[0] tname, args, section = blocks[0]
self.__name__="%s %s" % (tname, args) self.__name__="%s %s" % (tname, args)
args = parse_params(args, required=1, where=1) args = parse_params(args, required=1, where=1)
if args.has_key(''): args[args['']]=1 if args.has_key(''): args[args['']]=1
if args.has_key('required'): self.required=args['required'] if args.has_key('required'): self.required=args['required']
if args.has_key('where'): self.where=args['where'] if args.has_key('where'): self.where=args['where']
def render(self,md): def render(self,md):
r=[] r=[]
for tname, args, section in self.blocks: for tname, args, section in self.blocks:
__traceback_info__=tname __traceback_info__=tname
s=strip(section(None, md)) s=strip(section(None, md))
if s: if s:
if r: r.append(tname) if r: r.append(tname)
r.append("%s\n" % s) r.append("%s\n" % s)
if r: if r:
if len(r) > 1: r="(%s)\n" % join(r,' ') if len(r) > 1: r="(%s)\n" % join(r,' ')
else: r=r[0] else: r=r[0]
if self.where: r="where\n"+r if self.where: r="where\n"+r
return r return r
if self.required: if self.required:
raise 'Input Error', 'Not enough input was provided!<p>' raise 'Input Error', 'Not enough input was provided!<p>'
return '' return ''
__call__=render __call__=render
##########################################################################
#
# $Log: sqlgroup.py,v $
# Revision 1.4 1998/09/04 20:45:02 jim
# fixed namespace screw up due to from DT_Util import *
#
# Revision 1.3 1998/04/02 21:33:38 jim
# Added where attribute.
#
# Revision 1.2 1998/03/18 23:25:55 jim
# Added 'required' attribute (and fixed doc).
#
# Revision 1.1 1998/03/17 19:31:22 jim
# added new sql tags
#
#
This diff is collapsed.
This diff is collapsed.
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