[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Publisher - FileResource.py:1.1 config.zcml:1.1
Jim Fulton
jim@zope.com
Thu, 13 Jun 2002 19:15:44 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Publisher
In directory cvs.zope.org:/tmp/cvs-serv10697/lib/python/Zope/App/Publisher
Added Files:
FileResource.py config.zcml
Log Message:
Got icons working, and, along the way:
- Implemented the icon directive
- Implemented
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/ResourcesProposal
- Added a special view, named '', for service manager containers that
allows resources to have URLs like:
http://foo.com/@@/resourcename
- Fixed some server code that caused HTTP response data to get
promoted to unicode
- Updated the folder contents page to display icons.
- Ported icons for folder, file, image, and zptpage. Many more icons
need to be ported or created.
=== Added File Zope3/lib/python/Zope/App/Publisher/FileResource.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.
#
##############################################################################
"""
$Id: FileResource.py,v 1.1 2002/06/13 23:15:43 jim Exp $
"""
__metaclass__ = type # All classes are new style when run with Python 2.2+
from Zope.Misc.content_types import guess_content_type
from Zope.Misc.package_home import package_home
from Zope.Misc.standard_dates import rfc1123_date
from Zope.Misc.DateTimeParse import time as timeFromDateTimeString
from Zope.Exceptions import NotFoundError
from time import time
from os import stat
import os
class File:
"""Image objects stored in external files."""
def __init__(self, path):
self.path=path
file=open(path, 'rb')
data=file.read()
file.close()
self.content_type, enc = guess_content_type(path, data)
self.__name__=path[path.rfind('/')+1:]
self.lmt=float(stat(path)[8]) or time()
self.lmh=rfc1123_date(self.lmt)
class Image(File):
def __init__(self, path):
super(Image, self).__init__(path)
if self.content_type in (None, 'application/octet-stream'):
ext = os.path.splitext(self.path)[1]
if ext:
self.content_type='image/%s' % ext[1:]
=== Added File Zope3/lib/python/Zope/App/Publisher/config.zcml ===
<zopeConfigure xmlns='http://namespaces.zope.org/zope' >
<include package=".Browser" />
</zopeConfigure>