Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 97

Show
Ignore:
Timestamp:
12/29/04 14:03:24
Author:
rboerma
Message:

patched xmlrpcfilter so debug msgs will not appear, added standard cherrypyteam header, added to changelog

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog.txt

    r96 r97  
    112004/12-29: 
    22        * CherryPY-2.0-beta released 
     3    * xmlrpcfilter added (Remco) 
    34        * cpg.response.body is now always an iterable type - ticket #59 (Carlos) 
    45        * Allowed default session functions to be accessed by other modules - 
  • trunk/cherrypy/lib/filter/xmlrpcfilter.py

    r95 r97  
     1""" 
     2Copyright (c) 2004, CherryPy Team (team@cherrypy.org) 
     3All rights reserved. 
     4 
     5Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
     6 
     7    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
     8    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
     9    * Neither the name of the CherryPy Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
     10 
     11THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     12""" 
    113########################################################################## 
    2 ##  
    3 ## xmlrpcfilter is as open as it can be. Do whatever you like, 
    4 ## but understand that i take no responsibility for the code itself, 
    5 ## nor for wat it does and especially any derivatives and when you use 
    6 ## it, keep a copyright somewhere of me, or make notice of CherryPy 
    7 ## 
    814## Remco Boerma 
    915## 
    1016## History: 
     17## 1.0.0   : 2004-12-29 Released with CP2 
    1118## 0.0.9   : 2004-12-23 made it CP2 #59 compatible (returns an iterable) 
    1219##           Please note: as the xmlrpc doesn't know what you would want to return 
     
    5360## EXAMPLE CODE FOR THE SERVER: 
    5461##    from cherrypy import cpg 
    55 ##    import xmlrpcfilter 
     62##    import cherrypy.lib.xmlrpcfilter as xmlrpcfilter 
    5663##    class Root: 
    57 ##        _cpFilterList = [xmlrpcfilter.XmlRpcFilter(mimeTypeList = ['text/xml'])]  
     64##        _cpFilterList = [xmlrpcfilter.XmlRpcFilter()]  
    5865## 
    5966##        def test(self): 
     
    8390    PLEASE NOTE: 
    8491 
    85  
    86     --  IN CASE TICKET #28 IS NOT RESOLVED 
    87         ANY XMLRPC FUNCTION NEEDS TO RETURN A PYTHON SOURCE STRING 
    88             use 
    89               return `result` 
    90             insted of 
    91               return result 
    92             .  
    93  
    94     --  AS ALL REQUESTS MUST RETURN A STRING (UNTIL THE FIX IS THERE) 
    95         ALL METHODS ARE CALLABLE USING A REGULAR WEBBROWSER AS WELL!! 
    96  
    9792    afterRequestHeader: 
    9893        Unmarshalls the posted data to a methodname and parameters. 
     
    117112    def afterRequestHeader(self): 
    118113        """ Called after the request header has been read/parsed""" 
    119 ##        try: 
    120 ##            x = cpg.request.isRPC # should fail! 
    121 ##            print "error: afterRequestHeader is called twice!" 
    122 ##            return  
    123 ##        except: 
    124 ##            pass 
    125114        cpg.request.isRPC = self.testValidityOfRequest() 
    126115        if not cpg.request.isRPC:  
    127             print 'not a valid xmlrpc call' 
     116            # used for debugging or more info 
     117            # print 'not a valid xmlrpc call' 
    128118            return # break this if it's not for this filter!! 
    129         print "xmlrpcmethod...", 
     119        # used for debugging, or more info: 
     120        # print "xmlrpcmethod...", 
    130121        cpg.request.parsePostData = 0 
    131122        dataLength = int(cpg.request.headerMap.get('Content-Length',0)) 
    132         # ought to be true: 
    133         # if cpg.request.method == 'POST': 
    134         # if not, it's probabely a webbrowser requesting the url 
    135123        data = cpg.request.rfile.read(dataLength) 
    136         #else: 
    137         #    data = None 
    138  
    139         # for testing: an exception may be raised as well. . an xmlrpc 'Fault' would be better though. 
    140124        try: 
    141125            params, method = xmlrpclib.loads(data) 
     
    153137        cpg.request.path+=str(method).replace('.','/') 
    154138        cpg.request.paramList = list(params) 
    155         print "XMLRPC Filter: calling '%s' with args: '%s' " % (cpg.request.path,params) 
     139        # used for debugging and more info 
     140        # print "XMLRPC Filter: calling '%s' with args: '%s' " % (cpg.request.path,params) 
    156141 
    157142    def beforeResponse(self): 
     
    160145            return # it's not an RPC call, so just let it go with the normal flow 
    161146        try: 
    162             print 'beforeResponse: cpg.response.body ==',`cpg.response.body`  
     147            # use this for debugging and more info: 
     148            # print 'beforeResponse: cpg.response.body ==',`cpg.response.body`  
    163149            cpg.response.body = xmlrpclib.dumps((cpg.response.body[0],), methodresponse=1,allow_none=1) 
    164150        except xmlrpclib.Fault,fault: 

Hosted by WebFaction

Log in as guest/cpguest to create tickets