[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/Browser - Debug.py:1.1.2.1

Jim Fulton jim@zope.com
Sun, 2 Jun 2002 10:34:56 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/Browser
In directory cvs.zope.org:/tmp/cvs-serv29793/lib/python/Zope/App/ZopePublication/Browser

Added Files:
      Tag: Zope3InWonderland-branch
	Debug.py 
Log Message:
- Added template attribute to allow views to be created from a
  template source file.

- Added beginnings of a Zope debugger. This required seperating site
  and server configuration.

- Added the ability to specify a config file package in the
  zopeConfigure directive. Made "config.zcml" a default for the file
  attribute in the include directive.

- Fixed mapply to unwrap proxied objects. This was necessary once
  views became wrapped in proxies. We need to investigate why they
  weren't being wrapped before. 

- I updated enough system page templates and zcml directives so that:

  - Zope now starts. :)

  - The root folder contents listing can be viewed.

  Many more templates and zcml files need to be updated to reflect the
  way views are now handled.



=== Added File Zope3/lib/python/Zope/App/ZopePublication/Browser/Debug.py ===
##############################################################################
#
# Copyright (c) 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.
# 
##############################################################################
"""Zope 3 debugger

This is the first preliminary (add weasle words) cut at a zope debugger.

$Id: Debug.py,v 1.1.2.1 2002/06/02 14:34:55 jim Exp $
"""
__metaclass__ = type # All classes are new style when run with Python 2.2+

from Zope.Publisher.Publish import publish as _publish
from Zope.App.ZopePublication.Browser.Publication import BrowserPublication
from ZODB.FileStorage import FileStorage
from ZODB.DB import DB
from Zope.Publisher.Browser.BrowserRequest import TestRequest
from Zope.Configuration.xmlconfig import XMLConfig
from cStringIO import StringIO
import base64

XMLConfig('../../site.zcml')()
db= DB(FileStorage('../../Data.fs'))
pub = BrowserPublication(db)

def publish(path='/', stdin='', basic=None, **kw):
    out = StringIO()
    if type(stdin) is str:
        stdin = StringIO(stdin)
    env = {'PATH_INFO': path}
    env.update(kw)

    if basic:
        env['HTTP_AUTHORIZATION']="Basic %s" % base64.encodestring(basic)

    request = TestRequest(StringIO(''), StringIO(), env)
    request.setPublication(pub)

    _publish(request, 0)