View of /PEAK/src/peak/ddt/web_runner.py
Parent Directory
| Revision Log
Revision:
1942 -
(
download)
(
as text)
Tue Nov 23 23:26:05 2004 UTC (19 years, 5 months ago) by
pje
File size: 1472 byte(s)
DEPRECATED 'permissionNeeded' attribute of descriptors, and removed
'security.IGuardedDescriptor'. Please see CHANGES.txt for more details,
and information on upgrading. Now 'peak.security' is decoupled from the
PEAK core frameworks, or more precisely, there are no "forward references"
from the PEAK core to 'peak.security', except for the temporary vestigial
implementations of 'permissionNeeded' that will be removed in the next
release.
from peak.api import *
from interfaces import *
import os
from cStringIO import StringIO
from runners import HTMLRunner, FileURL
class TestDocument(web.FileResource):
def getStreamAndSize(self):
output = StringIO()
HTMLRunner(
config.ServiceArea(self),
argv = ['HTMLRunner', FileURL.fromFilename(self.filename)],
stdout = output,
stderr = StringIO(),
).run()
size = output.tell()
output.seek(0)
return output,size
class IndexedDirectory(web.ResourceDirectory):
index_html = web.bindResource(
'directoryIndex', metadata=[security.Anybody]
)
def contents(self):
contents = []
names = os.listdir(self.filename); names.sort()
for name in names:
if name not in ['.','..']:
try:
ob = self[name]
except KeyError:
pass # print name
else:
contents.append(ob)
return contents
contents = binding.Make(contents, [security.Anybody])
class PublishedDirectory(IndexedDirectory):
isRoot = True
resourceDefaultsIni = binding.Obtain(
"pkgfile:peak.ddt/resource_defaults.ini",
offerAs = ['peak.web.resourceDefaultsIni']
)
filename = binding.Make(
lambda self: self.lookupComponent(commands.ARGV)[1]
)
resourcePath = ''