Ejemplo n.º 1
0
class ZSQLNode(ZopeNode):
    Model = ZopeEditorModels.ZopeSQLMethodModel
    defaultViews = (ZopeViews.ZopeHTMLSourceView, )
    additionalViews = (ZopeViews.ZopeSecurityView, ZopeViews.ZopeUndoView)

    def getParams(self, data):
        return data.split('<params>')[1].split('</params>')[0]

    def getBody(self, data):
        return data.split('</params>')[1].lstrip()

    def save(self, filename, data, mode='wb'):
        """ Saves contents of data to Zope """
        props = self.getResource().zoa.props.SQLMethod()
        try:
            title = props['title']
            connection_id = props['connection_id']
            arguments = self.getParams(data)
            template = self.getBody(data)
            self.getResource().manage_edit(title, connection_id, arguments,
                                           template)
        except xmlrpclib.ProtocolError, error:
            # Getting a zero content warning is not an error
            if error.errcode != 204:
                raise ExplorerNodes.TransportSaveError(error, filename)
        except Exception, error:
            raise ExplorerNodes.TransportSaveError(error, filename)
Ejemplo n.º 2
0
 def save(self, overwriteNewer=False):
     """ This is perhaps not the best style, but here all exceptions
         on saving are caught and transformed to TransportSaveErrors.
         To much maintenance for every Node type to add exceptions
     """
     from ExternalLib.xmlrpclib import Fault
     try:
         EditorModels.BasePersistentModel.save(self, overwriteNewer)
     except Fault, err:
         from Explorers import ExplorerNodes
         raise ExplorerNodes.TransportSaveError(
             Utils.html2txt(err.faultString), self.transport.resourcepath)
Ejemplo n.º 3
0
 def save(self, filename, data, mode='wb'):
     """ Saves contents of data to Zope """
     props = self.getResource().zoa.props.SQLMethod()
     try:
         title = props['title']
         connection_id = props['connection_id']
         arguments = self.getParams(data)
         template = self.getBody(data)
         self.getResource().manage_edit(title, connection_id, arguments,
                                        template)
     except xmlrpclib.ProtocolError, error:
         # Getting a zero content warning is not an error
         if error.errcode != 204:
             raise ExplorerNodes.TransportSaveError(error, filename)