[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/SQLScript - SSQLScript.py:1.1 ISQLScript.py:1.2 SQLScript.py:1.4 configure.zcml:1.2
Stephan Richter
srichter@cbu.edu
Fri, 19 Jul 2002 09:13:03 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/SQLScript
In directory cvs.zope.org:/tmp/cvs-serv24805/lib/python/Zope/App/OFS/Content/SQLScript
Modified Files:
ISQLScript.py SQLScript.py configure.zcml
Added Files:
SSQLScript.py
Log Message:
Okay, I finished the Forms work. Schema and Forms completely replace the
old Formulator code now. I have switched all the Content objects to using
Schema + Forms; especially the SQL Script has an interesting demo on how
to write your custom fields.
However, I am not satisfied with all my design decisions. There is still
a lot of work to be done in Converters and Widgets. Please contact Martijn
and/or me if you would like to help.
=== Added File Zope3/lib/python/Zope/App/OFS/Content/SQLScript/SSQLScript.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: SSQLScript.py,v 1.1 2002/07/19 13:12:32 srichter Exp $
"""
import Schema
from Zope.ComponentArchitecture import getService
from Zope.App.Traversing import getParent
from Zope.ContextWrapper import ContextMethod
class SQLArguments(Schema.Str):
"""Arguments"""
class SQLConnectionName(Schema.Str):
"""SQL Connection Name"""
def items(self):
"""Note that this method works only if the Field is context wrapped."""
connection_service = getService(self, "Connections")
connections = connection_service.getAvailableConnections()
return connections
items = ContextMethod(items)
class SSQLScript(Schema.Schema):
connectionName = SQLConnectionName(
id="connectionName",
title="Connection Name",
description="""The Connection Name for the connection to be used.""",
required=1)
arguments = SQLArguments(
id="arguments",
title="Arguments",
description='A set of attributes that can be used during the DTML '
'rendering process to provide dynamic data.',
required=1)
source = Schema.Str(
id="source",
title="Source",
description="""The source od the page template.""",
required=1)
=== Zope3/lib/python/Zope/App/OFS/Content/SQLScript/ISQLScript.py 1.1 => 1.2 ===
#
##############################################################################
"""
-
$Id$
"""
-
from Zope.App.RDB.ISQLCommand import ISQLCommand
from Interface.Attribute import Attribute
class ISQLScript(ISQLCommand):
- """ """
+ """A persistent script that can execute SQL."""
arguments = Attribute('''A set of attributes that can be used during
the DTML rendering process to provide dynamic
@@ -40,21 +38,16 @@
"""This method returns the arguments string."""
def setSource(source):
- """Save the source of the page template.
- """
+ """Save the source of the page template."""
def getSource():
- """Get the source of the page template.
- """
+ """Get the source of the page template."""
def getTemplate():
- """Get the SQL DTML Template object.
- """
+ """Get the SQL DTML Template object."""
def setConnectionName(name):
- """Save the connection name for this SQL Script.
- """
+ """Save the connection name for this SQL Script."""
def getConnectionName():
- """Get the connection name for this SQL Script.
- """
+ """Get the connection name for this SQL Script."""
=== Zope3/lib/python/Zope/App/OFS/Content/SQLScript/SQLScript.py 1.3 => 1.4 ===
#
##############################################################################
"""
-
$Id$
"""
from types import StringTypes
@@ -28,6 +27,7 @@
from Zope.App.OFS.Content.IFileContent import IFileContent
from Zope.App.OFS.Content.SQLScript.ISQLScript import ISQLScript
+from Zope.App.OFS.Content.SQLScript.SSQLScript import SSQLScript
from Zope.App.OFS.Content.SQLScript.Arguments import parseArguments
from DT_SQLVar import SQLVar
@@ -51,29 +51,24 @@
class SQLScript(SQLCommand, Persistent):
- __implements__ = ISQLScript, IFileContent
+ __implements__ = ISQLScript, SSQLScript, IFileContent
def __init__(self, connectionName='', source='', arguments=''):
self.template = SQLDTML(source)
- self.connectionName = connectionName
+ self.setConnectionName(connectionName)
# In our case arguments should be a string that is parsed
self.setArguments(arguments)
-
- ############################################################
- # Implementation methods for interface
- # Zope.App.OFS.Content.SQLScript.ISQLScript.
-
def setArguments(self, arguments):
'See Zope.App.OFS.Content.SQLScript.ISQLScript.ISQLScript'
assert isinstance(arguments, StringTypes), \
'"arguments" argument of setArguments() must be a string'
self._arg_string = arguments
- self.arguments = parseArguments(arguments)
+ self._arguments = parseArguments(arguments)
def getArguments(self):
'See Zope.App.OFS.Content.SQLScript.ISQLScript.ISQLScript'
- return self.arguments
+ return self._arguments
def getArgumentsString(self):
'See Zope.App.OFS.Content.SQLScript.ISQLScript.ISQLScript'
@@ -93,14 +88,11 @@
def setConnectionName(self, name):
'See Zope.App.OFS.Content.SQLScript.ISQLScript.ISQLScript'
- self.connectionName = name
+ self._connectionName = name
def getConnectionName(self):
'See Zope.App.OFS.Content.SQLScript.ISQLScript.ISQLScript'
- return self.connectionName
-
- ######################################
- # from: Zope.App.RDB.ISQLCommand.ISQLCommand
+ return self._connectionName
def getConnection(self):
'See Zope.App.RDB.ISQLCommand.ISQLCommand'
@@ -116,14 +108,14 @@
# Try to resolve arguments
arg_values = {}
missing = []
- for name in self.arguments.keys():
+ for name in self._arguments.keys():
name = name.encode('UTF-8')
try:
# Try to find argument in keywords
arg_values[name] = kw[name]
except:
# Okay, the first try failed, so let's try to find the default
- arg = self.arguments[name]
+ arg = self._arguments[name]
try:
arg_values[name] = arg['default']
except:
@@ -151,5 +143,12 @@
__call__ = ContextMethod(__call__)
- #
- ############################################################
+
+ # See Zope.App.OFS.Content.SQLScript.ISQLScript.ISQLScript
+ arguments = property(getArgumentsString, setArguments, None,
+ "Set the arguments that are used for the SQL Script.")
+ source = property(getSource, setSource, None,
+ "Set the SQL template source.")
+ connectionName = property(getConnectionName, setConnectionName, None,
+ "Connection Name for the SQL scripts.")
+
=== Zope3/lib/python/Zope/App/OFS/Content/SQLScript/configure.zcml 1.1 => 1.2 ===
permission="Zope.ManageContent"
interface=".ISQLScript." />
<require
+ permission="Zope.View"
+ interface=".SSQLScript." />
+ <require
permission="Zope.ManageContent"
interface="Zope.App.OFS.Content.IFileContent." />
</content>