Commit 3167be81 authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Add dtml file for adding ERP5 SQL Methods

parent c5b2d827
...@@ -28,23 +28,22 @@ ...@@ -28,23 +28,22 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Globals import InitializeClass from Products.ERP5Type.Globals import DTMLFile
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from App.special_dtml import HTMLFile from App.special_dtml import HTMLFile
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.PythonScripts.PythonScript import \ from Products.PythonScripts.PythonScript import \
PythonScript as ZopePythonScript PythonScript as ZopePythonScript
from Products.ZSQLMethods.SQL import SQL as ZSQL from Products.ZSQLMethods.SQL import SQL as ZSQL
from Products.ZSQLMethods.SQL import manage_addZSQLMethodForm
# Migration function # Migration function
def migrateSQLMethodToERP5Object(self, id, title=''): def migrateSQLMethodToERP5Object(self, id, title=''):
pass pass
manage_addSQLMethodForm = manage_addZSQLMethodForm manage_addSQLMethodForm = DTMLFile('../dtml/addSQLMethod.dtml', globals())
# New ZSQLMethod addition function # New ZSQLMethod addition function
def addSQLMethod(self, id, title='', def manage_addSQLMethod(self, id, title='',
REQUEST=None, REQUEST=None,
*args, *args,
**kw): **kw):
...@@ -73,8 +72,10 @@ class SQLMethod(XMLObject, ZSQL): ...@@ -73,8 +72,10 @@ class SQLMethod(XMLObject, ZSQL):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
constructors = (manage_addSQLMethodForm, addSQLMethod) # Add constructor methods
#View content list, Force /view, Standart option in python scripts constructors = (manage_addSQLMethodForm, manage_addSQLMethod)
# View content list, Force /view, Standart option in python scripts
manage_options = ( XMLObject.manage_options[0], manage_options = ( XMLObject.manage_options[0],
{'icon':'', 'label':'View','action':'view'}) \ {'icon':'', 'label':'View','action':'view'}) \
+ ZSQL.manage_options + ZSQL.manage_options
...@@ -93,5 +94,3 @@ class SQLMethod(XMLObject, ZSQL): ...@@ -93,5 +94,3 @@ class SQLMethod(XMLObject, ZSQL):
""" """
XMLObject.__init__(self, *args, **kw) XMLObject.__init__(self, *args, **kw)
ZSQL.__init__(self, *args, **kw) ZSQL.__init__(self, *args, **kw)
#InitializeClass(SQLMethod)
\ No newline at end of file
<dtml-var manage_page_header>
<dtml-var "manage_form_title(this(), _,
form_title='Add ERP5 SQL Method',
help_product='SQLMethods',
)">
<dtml-if SQLConnectionIDs>
<p class="form-help">
A SQL Method allows you to access a SQL database. For more information see
the <a href="http://www.zope.org/Documentation/Guides/ZSQL">Z SQL Methods
User's Guide</a>.
</p>
<p class="form-help">
In the form below <EM>connection id</EM> is the name of the SQL Database
Connection to use. <EM>Arguments</EM> is a list of variables which the
SQL Method accepts. <EM>Query template</EM> is a template of the SQL
statement which the SQL Method will execute.
</p>
<form action="manage_addSQLMethod" method="post">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
<div class="form-label">
Id
</div>
</td>
<td align="left" valign="top">
<input type="text" name="id" size="40" value="" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-optional">
Title
</div>
</td>
<td align="left" valign="top">
<input type="text" name="title" size="40" />
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Connection Id
</div>
</td>
<td align="left" valign="top">
<div class="form-element">
<select name="connection_id">
<dtml-in SQLConnectionIDs>
<option value="&dtml-sequence-item;">
&dtml-sequence-key;</option>
</dtml-in>
</select>
</div>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-optional">
Arguments
</div>
</td>
<td align="left" valign="top">
<textarea name="arguments" cols="40" rows="4"></textarea>
</td>
</tr>
<tr>
<td align="left" valign="top" colspan="2">
<span class="form-label">Query Template</span>
<br />
<div style="width: 100%;">
<textarea style="width: 100%;" name="template:text" rows="9" cols="60"
wrap="off">select * from data</textarea></div>
</td>
</tr>
<tr>
<td align="left" valign="top" colspan="2">
<div class="form-element">
<input class="form-element" type="submit" name="submit"
value=" Add " />
<input class="form-element" type="submit" name="submit"
value=" Add and Edit " />
<input class="form-element" type="submit" name="submit"
value=" Add and Test " />
</div>
</td>
</tr>
</table>
</form>
<dtml-else>
<p class="form-text">
There are no SQL database connections. You need to add a Zope
SQL database connection before you can create a Zope SQL Method.
</p>
</dtml-if>
<dtml-var manage_page_footer>
\ No newline at end of file
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