[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/Browser - BrowserPayload.py:1.1.2.1 __init__.py:1.1.2.4.4.1

Stephan Richter srichter@cbu.edu
Sun, 3 Mar 2002 23:36:43 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/Browser
In directory cvs.zope.org:/tmp/cvs-serv30435/Browser

Modified Files:
      Tag: srichter-OFS_Formulator-branch
	__init__.py 
Added Files:
      Tag: srichter-OFS_Formulator-branch
	BrowserPayload.py 
Log Message:
Here are some of the changes made:

- Payload now keeps trakc of View Type

- Reimplementation of {set|get}ViewType in HTTPRequest, to overload the 
  standard BaseRequest one to look in the payload vor the View Type

- Implemented XMLRPCPayload

- Created IXMLRPCPublisher interface

- Implemenyed new Publisher interface in MethodPublisher

- Created xmlrpc ZCML namespace

- Move Payloads out of HTTP directory into Browser and XMLRPC


ToDo:

- Write and update tests. (nothing done yet)

- Update interfaces and create new ones

- Work on Authentication of XML-RPC

- Get rid of the 'Hacker' lines

- More refactoring needs to be done.



=== Added File Zope3/lib/python/Zope/Publisher/Browser/BrowserPayload.py === (550/650 lines abridged)
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors. 
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# 
##############################################################################
"""

$Id: BrowserPayload.py,v 1.1.2.1 2002/03/04 04:36:12 srichter Exp $
"""

import re
from types import ClassType, ListType, StringType
from cgi import FieldStorage, escape
from Zope.Publisher.HTTP.cgi_names import isCGI_NAME, hide_key

from Zope.Publisher.HTTP.IPayload import IRequestPayload, IResponsePayload
from Zope.Publisher.Converters import get_converter
from Zope.Publisher.Exceptions import Redirect, Unauthorized

from IBrowserPublisher import IBrowserPublisher 


latin1_alias_match = re.compile(
    r'text/html(\s*;\s*charset=((latin)|(latin[-_]?1)|'
    r'(cp1252)|(cp819)|(csISOLatin1)|(IBM819)|(iso-ir-100)|'
    r'(iso[-_]8859[-_]1(:1987)?)))?$',re.I).match

def is_text_html(content_type):
    return (content_type == 'text/html' or
            latin1_alias_match(content_type) is not None)


class BrowserRequestPayload:
    """
    Works with the body of a browser request.
    """

    __implements__ = IRequestPayload

    # XXX HACK!!!! This should be implemented via some nice
    #     methods and interface
    _viewtype = IBrowserPublisher

[-=- -=- -=- 550 lines omitted -=- -=- -=-]

        L1.sort()
        return ", ".join(
            map(lambda item: "%s: %s" % (item[0], repr(item[1])), L1)) 



# Flags
SEQUENCE=1
DEFAULT=2
RECORD=4
RECORDS=8
REC=RECORD|RECORDS
EMPTY=16
CONVERTED=32


def format_exception(etype,value,tb,limit=None):
    import traceback
    result=['Traceback (innermost last):']
    if limit is None:
        if hasattr(sys, 'tracebacklimit'):
            limit = sys.tracebacklimit
    n = 0
    while tb is not None and (limit is None or n < limit):
        f = tb.tb_frame
        lineno = tb.tb_lineno
        co = f.f_code
        filename = co.co_filename
        name = co.co_name
        locals = f.f_locals
        globals = f.f_globals
        modname = globals.get('__name__', filename)
        result.append('  Module %s, line %d, in %s'
                      % (modname,lineno,name))
        try: result.append('    (Object: %s)' %
                           locals[co.co_varnames[0]].__name__)
        except: pass
        try: result.append('    (Info: %s)' %
                           str(locals['__traceback_info__']))
        except: pass
        tb = tb.tb_next
        n = n+1
    result.append(' '.join(traceback.format_exception_only(etype, value)))
    return result


def traceback_string(t,v,tb):
    tb=format_exception(t,v,tb,200)
    return '\n'.join(tb)



=== Zope3/lib/python/Zope/Publisher/Browser/__init__.py 1.1.2.4 => 1.1.2.4.4.1 ===
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors. 
+# All Rights Reserved.
 # 
 # This software is subject to the provisions of the Zope Public License,
-# Version 1.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
+# FOR A PARTICULAR PURPOSE
+# 
+##############################################################################
+"""
+
+$Id$
+"""
 
 #from IBrowserPublisher import IBrowserPublisher