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
$Id: DA.py,v 1.4 1998/12/15 21:09:55 jim Exp $''' % database_type
__version__='$Revision: 1.4 $'[11:-2]
$Id: DA.py,v 1.5 1998/12/16 15:28:47 jim Exp $''' % database_type
__version__='$Revision: 1.5 $'[11:-2]
from db import DB, manage_DataSources
import sys, DABase, Globals
......@@ -20,16 +107,16 @@ _connections={}
def data_sources():
return filter(lambda ds, used=_connections.has_key: not used(ds[0]),
manage_DataSources())
manage_DataSources())
addConnectionForm=Globals.HTMLFile('connectionAdd',globals())
def manage_addZGadflyConnection(
self, id, title, connection, check=None, REQUEST=None):
"""Add a DB connection to a folder"""
self._setObject(id, Connection(
id, title, connection, check))
id, title, connection, check))
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):
" "
......@@ -41,39 +128,22 @@ class Connection(DABase.Connection):
def factory(self): return DB
def connect(self,s):
c=_connections
if c.has_key(s) and c[s] != self._p_oid:
raise 'In Use', (
'The database <em>%s</em> is in use.' % s)
c[s]=self._p_oid
return Connection.inheritedAttribute('connect')(self, s)
c=_connections
if c.has_key(s) and c[s] != self._p_oid:
raise 'In Use', (
'The database <em>%s</em> is in use.' % s)
c[s]=self._p_oid
return Connection.inheritedAttribute('connect')(self, s)
def __del__(self):
s=self.connection_string
c=_connections
if c.has_key(s) and c[s] == self._p_oid: del c[s]
s=self.connection_string
c=_connections
if c.has_key(s) and c[s] == self._p_oid: del c[s]
def manage_close_connection(self, REQUEST):
" "
s=self.connection_string
c=_connections
if c.has_key(s) and c[s] == self._p_oid: del c[s]
return Connection.inheritedAttribute('manage_close_connection')(
" "
s=self.connection_string
c=_connections
if c.has_key(s) and c[s] == self._p_oid: del c[s]
return Connection.inheritedAttribute('manage_close_connection')(
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
#
# 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.
#
##############################################################################
__doc__='''Generic Database Adapter Package Registration
$Id: __init__.py,v 1.6 1998/12/16 15:04:00 jim Exp $'''
__version__='$Revision: 1.6 $'[11:-2]
$Id: __init__.py,v 1.7 1998/12/16 15:28:47 jim Exp $'''
__version__='$Revision: 1.7 $'[11:-2]
import Globals, ImageFile, os
......@@ -22,8 +109,8 @@ misc_={'conn':
for icon in ('table', 'view', 'stable', 'what',
'field', 'text','bin','int','float',
'date','time','datetime'):
'field', 'text','bin','int','float',
'date','time','datetime'):
misc_[icon]=ImageFile.ImageFile('icons/%s.gif' % icon, globals())
meta_types=(
......@@ -36,10 +123,10 @@ DA=None
def getDA():
global DA
if DA is None:
home=Globals.package_home(globals())
from gadfly import sqlwhere
sqlwhere.filename="%s/gadfly/sql.mar" % home
import DA
home=Globals.package_home(globals())
from gadfly import sqlwhere
sqlwhere.filename="%s/gadfly/sql.mar" % home
import DA
return DA
getDA()
......@@ -48,15 +135,15 @@ def manage_addZGadflyConnectionForm(self, REQUEST, *args, **kw):
" "
DA=getDA()
return DA.addConnectionForm(
self,REQUEST,
database_type=database_type,
data_sources=DA.data_sources)
self,REQUEST,
database_type=database_type,
data_sources=DA.data_sources)
def manage_addZGadflyConnection(
self, id, title, connection, check=None, REQUEST=None):
" "
return getDA().manage_addZGadflyConnection(
self, id, title, connection, check, REQUEST)
self, id, title, connection, check, REQUEST)
methods={
'manage_addZGadflyConnection':
......
This diff is collapsed.
#!/bin/env python
##############################################################################
##############################################################################
#
# 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.
#
##############################################################################
__doc__='''SQL Methods
$Id: SQL.py,v 1.7 1998/12/15 21:10:31 jim Exp $'''
__version__='$Revision: 1.7 $'[11:-2]
$Id: SQL.py,v 1.8 1998/12/16 15:29:22 jim Exp $'''
__version__='$Revision: 1.8 $'[11:-2]
import Shared.DC.ZRDB.DA
from Globals import HTMLFile
......@@ -27,18 +113,18 @@ def SQLConnectionIDs(self):
StringType=type('')
while self is not None:
if hasattr(self, 'objectValues'):
for o in self.objectValues():
if (hasattr(o,'_isAnSQLConnection') and o._isAnSQLConnection
and hasattr(o,'id')):
id=o.id
if type(id) is not StringType: id=id()
if not have_id(id):
if hasattr(o,'title_and_id'): o=o.title_and_id()
else: o=id
ids[id]=id
if hasattr(self, 'aq_parent'): self=self.aq_parent
else: self=None
if hasattr(self, 'objectValues'):
for o in self.objectValues():
if (hasattr(o,'_isAnSQLConnection') and o._isAnSQLConnection
and hasattr(o,'id')):
id=o.id
if type(id) is not StringType: id=id()
if not have_id(id):
if hasattr(o,'title_and_id'): o=o.title_and_id()
else: o=id
ids[id]=id
if hasattr(self, 'aq_parent'): self=self.aq_parent
else: self=None
ids=map(lambda item: (item[1], item[0]), ids.items())
ids.sort()
......@@ -46,8 +132,8 @@ def SQLConnectionIDs(self):
manage_addZSQLMethodForm=HTMLFile('add', globals())
def manage_addZSQLMethod(self, id, title,
connection_id, arguments, template,
REQUEST=None):
connection_id, arguments, template,
REQUEST=None):
"""Add an SQL Method
The 'connection_id' argument is the id of a database connection
......@@ -73,9 +159,9 @@ class SQL(Shared.DC.ZRDB.DA.DA):
- Method
SQL Methods behave like methods of the folders they are
accessed in. In particular, they can be used from other
methods, like Documents, ExternalMethods, and even other SQL
Methods.
accessed in. In particular, they can be used from other
methods, like Documents, ExternalMethods, and even other SQL
Methods.
- Searchability
......@@ -85,8 +171,8 @@ class SQL(Shared.DC.ZRDB.DA.DA):
unions. They provide meta-data about their input parameters
and result data.
For more information, see the searchable-object interface
specification.
For more information, see the searchable-object interface
specification.
- Containment
......@@ -98,11 +184,11 @@ class SQL(Shared.DC.ZRDB.DA.DA):
folder). The 'service_record' method could be accessed with a
URL like::
employees/employee_id/1234/service_record
employees/employee_id/1234/service_record
"""
meta_type='Z SQL Method'
icon='misc_/ZSQLMethods/icon'
manage_main=HTMLFile('edit', globals())
#!/bin/env python
##############################################################################
##############################################################################
#
# 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.
#
##############################################################################
__doc__='''SQL Method Product
$Id: __init__.py,v 1.8 1998/12/16 15:04:42 jim Exp $'''
__version__='$Revision: 1.8 $'[11:-2]
$Id: __init__.py,v 1.9 1998/12/16 15:29:22 jim Exp $'''
__version__='$Revision: 1.9 $'[11:-2]
from ImageFile import ImageFile
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 string
from string import strip, lower, upper, join
......@@ -21,60 +117,60 @@ class Results:
self._data=data
self.__items__=items
self._parent=parent
self._parent=parent
self._names=names=[]
self._schema=schema={}
self._schema=schema={}
self._data_dictionary=dd={}
aliases=[]
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
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
n=lower(name)
if n != name: aliases.append((n, SQLAlias(name)))
n=upper(name)
if n != name: aliases.append((n, SQLAlias(name)))
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
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
# Add SQL Aliases
d=r.__dict__
for k, v in aliases:
if not hasattr(r,k): d[k]=v
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))
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
r.__dict__['__init__']=__init__
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 names(self): return self._names
......@@ -83,13 +179,13 @@ class Results:
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)
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)
def asRDB(self): # Waaaaa
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'
......@@ -26,17 +122,17 @@
<!--#sqltest name column=nick_name type=nb multiple optional-->
<!--#or-->
<!--#sqltest name column=first_name type=nb multiple optional-->
<!--#/sqlgroup-->
<!--#/sqlgroup-->
<!--#and-->
<!--#sqltest home_town type=nb optional-->
<!--#sqltest home_town type=nb optional-->
<!--#and-->
<!--#if minimum_age-->
age >= <!--#sqlvar minimum_age type=int-->
<!--#/if-->
age >= <!--#sqlvar minimum_age type=int-->
<!--#/if-->
<!--#and-->
<!--#if maximum_age-->
age <= <!--#sqlvar maximum_age type=int-->
<!--#/if-->
age <= <!--#sqlvar maximum_age type=int-->
<!--#/if-->
<!--#/sqlgroup-->
This example illustrates how groups can be nested to control
......@@ -57,8 +153,8 @@
# rights reserved.
#
############################################################################
__rcs_id__='$Id: sqlgroup.py,v 1.4 1998/09/04 20:45:02 jim Exp $'
__version__='$Revision: 1.4 $'[11:-2]
__rcs_id__='$Id: sqlgroup.py,v 1.5 1998/12/16 15:25:49 jim Exp $'
__version__='$Revision: 1.5 $'[11:-2]
from DocumentTemplate.DT_Util import parse_params
str=__builtins__['str']
......@@ -73,50 +169,33 @@ class SQLGroup:
def __init__(self, blocks):
self.blocks=blocks
tname, args, section = blocks[0]
self.__name__="%s %s" % (tname, args)
args = parse_params(args, required=1, where=1)
if args.has_key(''): args[args['']]=1
if args.has_key('required'): self.required=args['required']
if args.has_key('where'): self.where=args['where']
self.blocks=blocks
tname, args, section = blocks[0]
self.__name__="%s %s" % (tname, args)
args = parse_params(args, required=1, where=1)
if args.has_key(''): args[args['']]=1
if args.has_key('required'): self.required=args['required']
if args.has_key('where'): self.where=args['where']
def render(self,md):
r=[]
for tname, args, section in self.blocks:
__traceback_info__=tname
s=strip(section(None, md))
if s:
if r: r.append(tname)
r.append("%s\n" % s)
if r:
if len(r) > 1: r="(%s)\n" % join(r,' ')
else: r=r[0]
if self.where: r="where\n"+r
return r
if self.required:
raise 'Input Error', 'Not enough input was provided!<p>'
return ''
r=[]
for tname, args, section in self.blocks:
__traceback_info__=tname
s=strip(section(None, md))
if s:
if r: r.append(tname)
r.append("%s\n" % s)
if r:
if len(r) > 1: r="(%s)\n" % join(r,' ')
else: r=r[0]
if self.where: r="where\n"+r
return r
if self.required:
raise 'Input Error', 'Not enough input was provided!<p>'
return ''
__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