Commit 4a31baf4 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Products.ERP5Type: Remove modules never used since their introduction many years ago.

parent 04d33bdf
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@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 Acquisition import aq_base
from Products.ERP5Type.Globals import InitializeClass
from Products.ERP5Type.Base import TempBase
from zLOG import LOG
def newContext(context=None, REQUEST=None, **kw):
# Create context object
context_obj = Context(context=context, REQUEST=REQUEST, **kw)
# Wrap the context
if context is not None:
return context_obj.asContext(context = context)
else:
return context_obj
class Context(TempBase):
"""
Context objects are used all over ERP5 in so-called context
dependent function. Examples of context dependent methods
include:
- price methods (price depends on the context: customer,
quantity, etc.)
- BOM methods
"""
def __init__(self, context=None, REQUEST=None, **kw):
"""
context -- The
REQUEST -- the request object
kw -- user specified parameters
"""
# Copy REQUEST properties to self
if REQUEST is not None:
self.__dict__.update(REQUEST)
# Define local properties
if kw is not None: self.__dict__.update(kw)
def asContext(self, context=None, REQUEST=None, **kw):
"""
Update args of context
"""
# Copy REQUEST properties to self
if REQUEST is not None:
aq_base(self).__dict__.update(REQUEST)
# Define local properties
if kw is not None: aq_base(self).__dict__.update(kw)
# Wrap context
if context is not None:
return self.__of__(context)
else:
return self
InitializeClass(Context)
......@@ -18,15 +18,6 @@ class DeferredCatalogError(Exception):
self.field_id = context.getRelativeUrl()
class SSHConnectionError(Exception):
def __init__(self, message):
Exception.__init__(self, message)
self.message = message
def __str__(self):
return self.message
class UnsupportedWorkflowMethod(WorkflowException):
def __init__(self, instance, workflow_id, transition_id):
......@@ -48,7 +39,6 @@ class SimulationError(Exception):pass
allow_class(DeferredCatalogError)
allow_class(SSHConnectionError)
allow_class(ImmobilisationValidityError)
allow_class(ImmobilisationCalculationError)
allow_class(WorkflowException)
......
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Lucas Carvalho Teixeira <lucas@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 Products.ERP5Type.Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5Type.Errors import SSHConnectionError
from zLOG import LOG, WARNING
try:
import paramiko
from paramiko.ssh_exception import SSHException
except ImportError:
LOG(WARNING, 0, 'The SSHConnection can not be used because Paramiko '
'is not installed!')
import os
class SSHConnection(object):
"""
Holds an SHH connection to a remote SSH server.
"""
security = ClassSecurityInfo()
def __init__(self, username, host, port, key_path):
self.username = username
self.host = host
self.port = port
if os.path.exists(key_path):
self.key_path = key_path
else:
raise ValueError, 'key_path does not exist: %s' % key_path
security.declarePublic(Permissions.ManagePortal, 'connect')
def connect(self):
"""
Get a handle to a remote connection.
"""
self.transport = paramiko.Transport((self.host, int(self.port)))
rsa_key = paramiko.RSAKey.from_private_key_file(self.key_path)
try:
self.transport.connect(username=self.username, pkey=rsa_key)
except SSHException, e:
self.transport.close()
raise SSHConnectionError(str(e))
else:
self.sftp = paramiko.SFTPClient.from_transport(self.transport)
security.declarePublic(Permissions.ManagePortal, 'close')
def close(self):
"""
It must close the sftp and transport connection.
"""
self.sftp.close()
self.transport.close()
InitializeClass(SSHConnection)
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