Commit f6a5dd6c authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_catalog: Add ERP5 SQL Method objects

parent c4a4ee2a
##############################################################################
#
# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
from Products.PythonScripts.PythonScript import \
PythonScript as ZopePythonScript
from Products.ZSQLMethods.SQL import SQL as ZSQL
# New ZSQLMethod addition function
def manage_addSQLMethod(self, id, title='',
connection_id = '',
arguments = '',
template = '',
REQUEST=None,
*args,
**kw):
"""
Add ERP5 SQL Method to the folder
"""
id = str(id)
title = str(title)
# Create SQLMethod object container
c = SQLMethod(id, title, connection_id, arguments, template, self)
self._setObject(id, c)
c = self._getOb(id)
if REQUEST is not None:
REQUEST['RESPONSE'].redirect( 'manage_main' )
return c
class SQLMethod(XMLObject, ZSQL):
"""SQLMethod for ERP5.
"""
meta_type = 'ERP5 SQL Method'
portal_type = 'SQL Method'
icon = None
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Add constructor methods
constructors = (manage_addSQLMethod,)
# Override manage and manage_main with ZSQL manage and manage_main respectively
manage = manage_main = ZSQL.manage
# View content list, Force /view, Standard option in SQLMethod
manage_options = ({'icon':'', 'label':'View','action':'view'},) \
+ ZSQL.manage_options
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.SQLMethod
, PropertySheet.CatalogFilter
)
# Inheritence conflicts solved
__call__ = ZSQL.__call__
__getitem__ = ZSQL.__getitem__
PUT = ZSQL.PUT
index_html = ZSQL.index_html
manage_FTPget = ZSQL.manage_FTPget
dav__init = ZSQL.dav__init
def __init__(self, id, title='',
connection_id = '',
arguments = '',
template = ''
):
"""
Assign attributes to this class and override ZSQL init method to have
consistency with manage_edit(as ZSQL init also creates manage_edit)
"""
# Add the properties as the attributes for the SQL Method objects
# Useful while migrating data from ZSQLMethods to ERP5 SQLMethod objects
self.id = id
# Do we really need to initialize XMLObject class ?
#XMLObject.__init__(self, *args, **kw)
# Initializing ZSQL class object is important as this will call manage_edit
# which will change database method properties
ZSQL.__init__(self, id, title, connection_id, arguments, template)
def _setArgument(self, value):
"""
We need to override this so as to generate _arg attribute for SQL Method.
"""
self._baseSetArgument(value)
title = self.getTitle()
arguments = self.getArgument()
src = self.getSrc()
connection_id = self.getConnectionId()
self.manage_edit(title, connection_id, arguments, src)
def _edit(self, **kw):
XMLObject._edit(self, **kw)
src = self.getSrc()
title = self.title
if title is None:
title = ''
connection_id = self.getConnectionId()
self.manage_edit(title, connection_id, self.arguments, src)
...@@ -53,9 +53,10 @@ from Tool import CategoryTool, SimulationTool, RuleTool, IdTool, TemplateTool,\ ...@@ -53,9 +53,10 @@ from Tool import CategoryTool, SimulationTool, RuleTool, IdTool, TemplateTool,\
ConversionTool, RoundingTool, UrlRegistryTool, InterfaceTool,\ ConversionTool, RoundingTool, UrlRegistryTool, InterfaceTool,\
CertificateAuthorityTool, InotifyTool, TaskDistributionTool CertificateAuthorityTool, InotifyTool, TaskDistributionTool
import ERP5Site import ERP5Site
from Document import PythonScript from Document import PythonScript, SQLMethod
object_classes = ( ERP5Site.ERP5Site, object_classes = ( ERP5Site.ERP5Site,
PythonScript.PythonScriptThroughZMI, PythonScript.PythonScriptThroughZMI,
SQLMethod.SQLMethod,
) )
portal_tools = ( CategoryTool.CategoryTool, portal_tools = ( CategoryTool.CategoryTool,
SimulationTool.SimulationTool, SimulationTool.SimulationTool,
......
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