Now use currentStation by default.
This commit is contained in:
parent
92f80f6c62
commit
26e0f8af9c
|
@ -147,7 +147,7 @@ class Inscription(things.Thing):
|
|||
if description is None:
|
||||
if environs.getVar("debug"):
|
||||
raise Exception('Description for "%s" missing' % self)
|
||||
raise faults.PathNotFound(self, self.getUriInternPath())
|
||||
raise faults.PathNotFound(self.getUriInternPath())
|
||||
description.submit()
|
||||
alerts = {}
|
||||
if not self.connaissanceReglement:
|
||||
|
@ -341,8 +341,7 @@ L'équipe Villes Internet
|
|||
logs.debug("""Setting session user = "%s" at location "%s".""" % (
|
||||
self.simpleLabel, session.userLocation))
|
||||
nextUrl = document.getActionUri("identifiant")
|
||||
return environs.getVar('httpRequestHandler').outputRedirect(
|
||||
self, nextUrl)
|
||||
return environs.getVar('httpRequestHandler').outputRedirect(nextUrl)
|
||||
|
||||
connaissanceReglement = property(getConnaissanceReglement)
|
||||
courriel = property(getCourriel)
|
||||
|
|
|
@ -152,7 +152,7 @@ class PageSequence(things.Thing):
|
|||
if pageNumber:
|
||||
if submission.getField("previous") and pageNumber > 1:
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(
|
||||
self, dataHolder.getActionUri(str(pageNumber - 1)))
|
||||
dataHolder.getActionUri(str(pageNumber - 1)))
|
||||
elif submission.getField("next") \
|
||||
and pageNumber < len(self.evaluateXpath("yep:pages/*")):
|
||||
pageNodes = self.evaluateXpath("yep:pages/*[%d]" % pageNumber)
|
||||
|
@ -173,7 +173,7 @@ class PageSequence(things.Thing):
|
|||
str(pageNumber + 1)))
|
||||
finally:
|
||||
environs.pull(_level = "PageSequence.submit")
|
||||
raise faults.PathNotFound(self, "/".join(arguments))
|
||||
raise faults.PathNotFound("/".join(arguments))
|
||||
return things.Thing.submit(self, *arguments)
|
||||
|
||||
#~ def walkActions1(self, uriPathFragments):
|
||||
|
@ -193,7 +193,7 @@ class PageSequence(things.Thing):
|
|||
#~ if uriPathFragments[-1] == 'exists':
|
||||
#~ return False
|
||||
#~ else:
|
||||
#~ raise faults.PathNotFound(self, '/'.join(uriPathFragments))
|
||||
#~ raise faults.PathNotFound('/'.join(uriPathFragments))
|
||||
#~ pageNode = pageNodes[0]
|
||||
#~ if pageNode.name == 'login':
|
||||
#~ libertyAlliance = self.walkToLocation(
|
||||
|
|
|
@ -48,7 +48,7 @@ class MyQuestionnaire(things.Thing):
|
|||
#~ if user is None:
|
||||
#~ if uriPathFragments[-1] == 'exists':
|
||||
#~ return False
|
||||
#~ raise faults.PathUnauthorized(self, "/".join(uriPathFragments))
|
||||
#~ raise faults.PathUnauthorized("/".join(uriPathFragments))
|
||||
#~ try:
|
||||
#~ questionnaire = self.walkToLocation(
|
||||
#~ "/questionnaires/%s" % strings.simplify(user.email))
|
||||
|
@ -59,7 +59,7 @@ class MyQuestionnaire(things.Thing):
|
|||
#~ except KeyError:
|
||||
#~ if uriPathFragments[-1] == 'exists':
|
||||
#~ return False
|
||||
#~ raise faults.PathNotFound(self, '/'.join(uriPathFragments))
|
||||
#~ raise faults.PathNotFound('/'.join(uriPathFragments))
|
||||
#~ questionnairesHolder = self.walkToLocation("/questionnaires/")
|
||||
#~ questionnaireHolder = questionnaireFeature.newXmlHolder(questionnairesHolder)
|
||||
#~ else:
|
||||
|
|
|
@ -166,7 +166,7 @@ class DataHolder(stations.AbstractStation):
|
|||
submission = environs.getVar("submission")
|
||||
isCreated = self.saveDataFile(submission.file, submission.length)
|
||||
if isCreated:
|
||||
httpRequestHandler.outputSuccessCreated(self, self.getUriAbsolutePath())
|
||||
httpRequestHandler.outputSuccessCreated(self.getUriAbsolutePath())
|
||||
else:
|
||||
httpRequestHandler.outputSuccessNoContent()
|
||||
|
||||
|
@ -485,10 +485,10 @@ class DataHolder(stations.AbstractStation):
|
|||
except IOError, error:
|
||||
if error.errno in (errno.ENOENT, errno.ENOTDIR):
|
||||
# No such file or directory
|
||||
raise faults.PathNotFound(self, "")
|
||||
raise faults.PathNotFound("")
|
||||
if error.errno == errno.EACCES:
|
||||
# Permission denied
|
||||
raise faults.PathForbidden(self, "")
|
||||
raise faults.PathForbidden("")
|
||||
raise
|
||||
if hasattr(dataFile, "fileno"):
|
||||
dataSize = os.fstat(dataFile.fileno())[6]
|
||||
|
@ -518,7 +518,7 @@ class DataHolder(stations.AbstractStation):
|
|||
def metadata(self, *uriPathFragments):
|
||||
metadata = self.getMetadata()
|
||||
if metadata is None:
|
||||
raise faults.PathNotFound(self, "metadata")
|
||||
raise faults.PathNotFound("metadata")
|
||||
return metadata.checkAccessAndWalk(
|
||||
uriPathFragments, environs.getVar("httpCommand"), environs.getVar("instruction"))
|
||||
|
||||
|
@ -601,16 +601,15 @@ class StaticDataHolder(DataHolder):
|
|||
except IOError, error:
|
||||
if error.errno == errno.ENOENT:
|
||||
# No such file or directory
|
||||
raise faults.PathNotFound(self, "")
|
||||
raise faults.PathNotFound("")
|
||||
if error.errno == errno.EACCES:
|
||||
# Permission denied
|
||||
raise faults.PathForbidden(self, "")
|
||||
raise faults.PathForbidden("")
|
||||
raise
|
||||
if data is None:
|
||||
data = self.data
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
self, data, contentLocation = self.getUriAbsolutePath(), mimeType = self.mimeType,
|
||||
modificationTime = self.getModificationTime())
|
||||
data, mimeType = self.mimeType, modificationTime = self.getModificationTime())
|
||||
|
||||
|
||||
class ImageHolder(StaticDataHolder):
|
||||
|
@ -811,8 +810,8 @@ class XmlHolder(DataHolder, documents.AbstractDocument):
|
|||
|
||||
def outputHttpSource(self):
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
self, self.getData(), contentLocation = self.getUriAbsolutePath(),
|
||||
mimeType = self.mimeType, modificationTime = self.getModificationTime())
|
||||
self.getData(), mimeType = self.mimeType,
|
||||
modificationTime = self.getModificationTime())
|
||||
|
||||
def parseDataFile(self):
|
||||
dataFile = self.getDataFile()
|
||||
|
|
|
@ -91,7 +91,7 @@ class DirectoryHolder(dataholders.DataHolder):
|
|||
else:
|
||||
logs.info('Ignoring unknown mode "%s" for directory at "%s".' % (
|
||||
modeName, self.getAbsolutePath()))
|
||||
raise faults.PathForbidden(self, "")
|
||||
raise faults.PathForbidden("")
|
||||
|
||||
def doHttpMkcol(self, collectionName = None):
|
||||
if collectionName is None:
|
||||
|
@ -100,7 +100,7 @@ class DirectoryHolder(dataholders.DataHolder):
|
|||
if content is not None:
|
||||
logs.debug(content)
|
||||
self.containedFileSystem.mkdir(collectionName)
|
||||
environs.getVar("httpRequestHandler").outputSuccessCreated(self, collectionName)
|
||||
environs.getVar("httpRequestHandler").outputSuccessCreated(collectionName)
|
||||
|
||||
def doHttpPut(self, itemName = None):
|
||||
# FIXME: To complete.
|
||||
|
@ -111,7 +111,7 @@ class DirectoryHolder(dataholders.DataHolder):
|
|||
|
||||
httpRequestHandler = environs.getVar("httpRequestHandler")
|
||||
if itemName is None:
|
||||
return httpRequestHandler.outputErrorMethodNotAllowed(self, "Not a document")
|
||||
return httpRequestHandler.outputErrorMethodNotAllowed("Not a document")
|
||||
|
||||
itemNameCore, itemNameExtension = os.path.splitext(itemName)
|
||||
if itemNameExtension in dataholders.mimeTypes:
|
||||
|
@ -131,7 +131,7 @@ class DirectoryHolder(dataholders.DataHolder):
|
|||
submission = environs.getVar("submission")
|
||||
isCreated = newHolder.saveDataFile(submission.file, submission.length)
|
||||
if isCreated:
|
||||
httpRequestHandler.outputSuccessCreated(newHolder, self.getUriAbsolutePath())
|
||||
httpRequestHandler.outputSuccessCreated(self.getUriAbsolutePath(), station = newHolder)
|
||||
else:
|
||||
httpRequestHandler.outputSuccessNoContent()
|
||||
|
||||
|
@ -354,7 +354,7 @@ Unknown file name extension = "%s", length = %d, for file "%s" at "%s".\
|
|||
"""Handles HTTP GET."""
|
||||
command = environs.getVar("httpCommand")
|
||||
if command != "GET":
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
modeNames = self.getConfigString("yep:defaultMode", default = "index").lower()
|
||||
for modeName in modeNames.split():
|
||||
if modeName == "index":
|
||||
|
@ -375,7 +375,7 @@ Unknown file name extension = "%s", length = %d, for file "%s" at "%s".\
|
|||
else:
|
||||
logs.info('Ignoring unknown mode "%s" for directory at "%s".' % (
|
||||
modeName, self.getAbsolutePath()))
|
||||
raise faults.PathForbidden(self, "styled")
|
||||
raise faults.PathForbidden("styled")
|
||||
|
||||
def walkToAction(self, uriPathFragments, command = None, instruction = None):
|
||||
actionName = uriPathFragments[0]
|
||||
|
|
|
@ -122,8 +122,7 @@ class AbstractDocument(nodes.NodeWrapper):
|
|||
|
||||
def outputHttpSource(self):
|
||||
data = self.serialize()
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
self, data, contentLocation = self.getUriAbsolutePath(), mimeType = "text/xml")
|
||||
environs.getVar("httpRequestHandler").outputData(data, mimeType = "text/xml")
|
||||
|
||||
node = property(getNode, setNode, deleteNode)
|
||||
|
||||
|
|
|
@ -400,8 +400,8 @@ class Element(stations.AbstractStation, nodes.NodeWrapper):
|
|||
data = self.serialize()
|
||||
dataHolder = self.getDataHolder()
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
self, data, contentLocation = self.getUriAbsolutePath(),
|
||||
mimeType = dataHolder.mimeType, modificationTime = dataHolder.getModificationTime())
|
||||
data, mimeType = dataHolder.mimeType,
|
||||
modificationTime = dataHolder.getModificationTime())
|
||||
|
||||
def register(cls, namespaceUri, elementName):
|
||||
modules.registerElementClass(namespaceUri, elementName, cls)
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
"""Faults Module"""
|
||||
|
||||
|
||||
import environs
|
||||
|
||||
|
||||
class AbstractFault(Exception):
|
||||
def __str__(self):
|
||||
return self.makeFaultString()
|
||||
|
@ -37,11 +40,13 @@ class BadRequest(AbstractFault):
|
|||
reason = None
|
||||
station = None
|
||||
|
||||
def __init__(self, station, reason = None):
|
||||
def __init__(self, reason = None, station = "current"):
|
||||
AbstractFault.__init__(self)
|
||||
self.station = station
|
||||
if reason is not None:
|
||||
self.reason = reason
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
self.station = station
|
||||
|
||||
def makeFaultString(self):
|
||||
if self.path:
|
||||
|
@ -54,10 +59,12 @@ class PathForbidden(AbstractFault):
|
|||
path = None
|
||||
station = None
|
||||
|
||||
def __init__(self, station, path):
|
||||
def __init__(self, path, station = "current"):
|
||||
AbstractFault.__init__(self)
|
||||
self.station = station
|
||||
self.path = path
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
self.station = station
|
||||
|
||||
def makeFaultString(self):
|
||||
return 'Access to path "%s" forbidden in %s' % (self.path, self.station)
|
||||
|
@ -67,10 +74,12 @@ class PathNotFound(AbstractFault):
|
|||
path = None
|
||||
station = None
|
||||
|
||||
def __init__(self, station, path):
|
||||
def __init__(self, path, station = "current"):
|
||||
AbstractFault.__init__(self)
|
||||
self.station = station
|
||||
self.path = path
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
self.station = station
|
||||
|
||||
def makeFaultString(self):
|
||||
return 'Path "%s" not found in %s' % (self.path, self.station)
|
||||
|
@ -80,10 +89,12 @@ class PathUnauthorized(AbstractFault):
|
|||
path = None
|
||||
station = None
|
||||
|
||||
def __init__(self, station, path):
|
||||
def __init__(self, path, station = "current"):
|
||||
AbstractFault.__init__(self)
|
||||
self.station = station
|
||||
self.path = path
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
self.station = station
|
||||
|
||||
def makeFaultString(self):
|
||||
return 'Access to path "%s" unauthorized in %s' % (self.path, self.station)
|
||||
|
|
|
@ -375,7 +375,7 @@ class html(WidgetElement):
|
|||
|
||||
command = environs.getVar("httpCommand")
|
||||
if command not in ("GET", "PUT"):
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
try:
|
||||
kupuHolder = self.walkToLocation("/javascript/kupu.html")
|
||||
|
|
|
@ -113,9 +113,8 @@ class HttpRequestHandlerMixin:
|
|||
self.application.handleHttpCommand(self)
|
||||
except IOError:
|
||||
logger.exception("An exception occured:")
|
||||
station = environs.getVar("rootStation", default = None)
|
||||
path = self.path.split("?")[0]
|
||||
return self.outputErrorNotFound(station, path)
|
||||
return self.outputErrorNotFound(path)
|
||||
assert environ == environs.get()
|
||||
|
||||
do_DELETE = doHttpCommand
|
||||
|
@ -163,7 +162,7 @@ class HttpRequestHandlerMixin:
|
|||
(self.address_string(), self.log_date_time_string(), format%args))
|
||||
|
||||
|
||||
def outputAlert(self, station, data, title = None, url = None):
|
||||
def outputAlert(self, data, station = "current", title = None, url = None):
|
||||
import html
|
||||
if title is None:
|
||||
title = N_("Alert")
|
||||
|
@ -182,10 +181,13 @@ class HttpRequestHandlerMixin:
|
|||
buttonsBar,
|
||||
),
|
||||
)
|
||||
self.outputData(station, layout.serialize(), mimeType = "text/html")
|
||||
self.outputData(layout.serialize(), contentLocation = None, mimeType = "text/html",
|
||||
station = station)
|
||||
|
||||
def outputData(self, station, data, contentLocation = None, headers = None, mimeType = None,
|
||||
modificationTime = None, successCode = 200):
|
||||
def outputData(self, data, contentLocation = "current", headers = None, mimeType = None,
|
||||
modificationTime = None, station = "current", successCode = 200):
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
if isinstance(data, basestring):
|
||||
dataFile = None
|
||||
dataSize = len(data)
|
||||
|
@ -211,20 +213,20 @@ class HttpRequestHandlerMixin:
|
|||
headers["Connection"] = "close"
|
||||
elif not self.close_connection:
|
||||
headers["Connection"] = "Keep-Alive"
|
||||
if contentLocation == "current":
|
||||
contentLocation = station.getUriAbsolutePath()
|
||||
if contentLocation is not None:
|
||||
headers["Content-Location"] = contentLocation
|
||||
if mimeType:
|
||||
headers["Content-Type"] = "%s; charset=utf-8" % mimeType
|
||||
if modificationTime:
|
||||
headers["Last-Modified"] = time.strftime(
|
||||
"%a, %d %b %Y %H:%M:%S GMT", modificationTime)
|
||||
headers["Last-Modified"] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", modificationTime)
|
||||
# TODO: Could also output Content-MD5.
|
||||
ifModifiedSince = self.headers.get("If-Modified-Since")
|
||||
if modificationTime and ifModifiedSince:
|
||||
# We don't want to use bandwith if the file was not modified.
|
||||
try:
|
||||
ifModifiedSinceTime = time.strptime(
|
||||
ifModifiedSince[:25], "%a, %d %b %Y %H:%M:%S")
|
||||
ifModifiedSinceTime = time.strptime(ifModifiedSince[:25], "%a, %d %b %Y %H:%M:%S")
|
||||
if modificationTime[:8] <= ifModifiedSinceTime[:8]:
|
||||
self.send_response(304, "Not Modified.")
|
||||
for key in ("Connection", "Content-Location"):
|
||||
|
@ -239,8 +241,8 @@ class HttpRequestHandlerMixin:
|
|||
assert not data
|
||||
data = dataFile.read(1048576) # Read first MB chunk
|
||||
if mimeType == "text/html" and data.startswith("<?xml"):
|
||||
# Internet Explorer 6 renders the page differently when they
|
||||
# start with <?xml...>, so skip it.
|
||||
# Internet Explorer 6 renders the page differently when they start with <?xml...>, so
|
||||
# skip it.
|
||||
i = data.find("\n")
|
||||
if i > 0:
|
||||
data = data[i + 1:]
|
||||
|
@ -292,11 +294,13 @@ class HttpRequestHandlerMixin:
|
|||
outputFile.write(chunk)
|
||||
return
|
||||
|
||||
def outputErrorAccessForbidden(self, station, filePath):
|
||||
def outputErrorAccessForbidden(self, filePath, station = "current"):
|
||||
if filePath is None:
|
||||
message = "Access Forbidden"
|
||||
else:
|
||||
message = """Access to "%s" Forbidden.""" % filePath
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
self.setCookie()
|
||||
logs.info(message)
|
||||
data = "<html><body>%s</body></html>" % message
|
||||
|
@ -312,11 +316,13 @@ class HttpRequestHandlerMixin:
|
|||
data = styledData
|
||||
return self.send_error(403, message, data)
|
||||
|
||||
def outputErrorBadRequest(self, station, reason):
|
||||
def outputErrorBadRequest(self, reason, station = "current"):
|
||||
if reason:
|
||||
message = "Bad Request: %s" % reason
|
||||
else:
|
||||
message = "Bad Request"
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
logs.info(message)
|
||||
data = "<html><body>%s</body></html>" % message
|
||||
if station:
|
||||
|
@ -331,7 +337,9 @@ class HttpRequestHandlerMixin:
|
|||
data = styledData
|
||||
return self.send_error(400, message, data)
|
||||
|
||||
def outputErrorInternalServer(self, station):
|
||||
def outputErrorInternalServer(self, station = "current"):
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
message = "Internal Server Error"
|
||||
logs.info(message)
|
||||
data = "<html><body>%s</body></html>" % message
|
||||
|
@ -347,11 +355,13 @@ class HttpRequestHandlerMixin:
|
|||
data = styledData
|
||||
return self.send_error(500, message, data)
|
||||
|
||||
def outputErrorMethodNotAllowed(self, station, reason):
|
||||
def outputErrorMethodNotAllowed(self, reason, station = "current"):
|
||||
if reason:
|
||||
message = "Method Not Allowed: %s" % reason
|
||||
else:
|
||||
message = "Method Not Allowed"
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
logs.info(message)
|
||||
data = "<html><body>%s</body></html>" % message
|
||||
# This error doesn't need a pretty interface.
|
||||
|
@ -359,11 +369,13 @@ class HttpRequestHandlerMixin:
|
|||
# resource.
|
||||
return self.send_error(405, message, data)
|
||||
|
||||
def outputErrorNotFound(self, station, filePath):
|
||||
def outputErrorNotFound(self, filePath, station = "current"):
|
||||
if filePath is None:
|
||||
message = "Not Found"
|
||||
else:
|
||||
message = """Path "%s" Not Found.""" % filePath
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
self.setCookie()
|
||||
logs.info(message)
|
||||
data = "<html><body>%s</body></html>" % message
|
||||
|
@ -379,11 +391,13 @@ class HttpRequestHandlerMixin:
|
|||
data = styledData
|
||||
return self.send_error(404, message, data)
|
||||
|
||||
def outputErrorUnauthorized(self, station, filePath):
|
||||
def outputErrorUnauthorized(self, filePath, station = "current"):
|
||||
if filePath is None:
|
||||
message = "Access Unauthorized"
|
||||
else:
|
||||
message = """Access to "%s" Unauthorized.""" % filePath
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
self.setCookie()
|
||||
logs.info(message)
|
||||
data = "<html><body>%s</body></html>" % message
|
||||
|
@ -408,8 +422,10 @@ class HttpRequestHandlerMixin:
|
|||
logs.debug(message)
|
||||
self.send_response(100, message)
|
||||
|
||||
def outputRedirect(self, station, uri):
|
||||
def outputRedirect(self, uri, station = "current"):
|
||||
assert uri
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
# We need to save the session before sending response, otherwise, the
|
||||
# server may receive a new HTTP request before the session is saved.
|
||||
session = environs.getVar("session")
|
||||
|
@ -444,11 +460,13 @@ class HttpRequestHandlerMixin:
|
|||
if self.command != "HEAD":
|
||||
self.wfile.write(data)
|
||||
|
||||
def outputSuccessCreated(self, station, filePath):
|
||||
def outputSuccessCreated(self, filePath, station = "current"):
|
||||
if filePath is None:
|
||||
message = "Created"
|
||||
else:
|
||||
message = """File "%s" Created.""" % filePath
|
||||
if station == "current":
|
||||
station = environs.getVar("currentStation", default = None)
|
||||
logs.debug(message)
|
||||
data = "<html><body>%s</body></html>" % message
|
||||
if station:
|
||||
|
@ -547,8 +565,7 @@ Client: %(clientIp)s
|
|||
except smtplib.SMTPException, error:
|
||||
logs.warning("SMTP error while sending talkback: %r" % error)
|
||||
|
||||
station = environs.getVar("rootStation", default = None)
|
||||
return self.outputErrorInternalServer(station)
|
||||
return self.outputErrorInternalServer()
|
||||
|
||||
def send_error(self, code, message = None, data = None, headers = None):
|
||||
# We need to save the session before sending response, otherwise, the
|
||||
|
|
|
@ -217,7 +217,7 @@ class Application(object):
|
|||
if submission.hasField("login") and not authorization \
|
||||
and rootDataHolder.getConfigBoolean("yep:useHttpAuthentication",
|
||||
default = False):
|
||||
return httpRequestHandler.outputErrorUnauthorized(rootDataHolder, httpPath)
|
||||
return httpRequestHandler.outputErrorUnauthorized(httpPath)
|
||||
if submission.hasField("logout") and authorization:
|
||||
# Since HTTP authentication provides no way to logout, we send a status
|
||||
# Unauthorized to force the user to press the cancel button. But instead of
|
||||
|
@ -229,7 +229,7 @@ class Application(object):
|
|||
try:
|
||||
authenticationScheme, credentials = authorization.split(None, 1)
|
||||
except ValueError:
|
||||
return httpRequestHandler.outputErrorUnauthorized(rootDataHolder, httpPath)
|
||||
return httpRequestHandler.outputErrorUnauthorized(httpPath)
|
||||
authenticationScheme = authenticationScheme.lower()
|
||||
if authenticationScheme == "basic":
|
||||
loginAndPassword = base64.decodestring(credentials)
|
||||
|
@ -246,27 +246,23 @@ class Application(object):
|
|||
"/accounts/passwords/%s" % strings.simplify(login))
|
||||
except faults.PathNotFound:
|
||||
logs.info("Wrong login = %s" % login)
|
||||
return httpRequestHandler.outputErrorUnauthorized(
|
||||
rootDataHolder, httpPath)
|
||||
return httpRequestHandler.outputErrorUnauthorized(httpPath)
|
||||
passwordAccount = passwordAccountHolder.getRootElement()
|
||||
from expression.modules.passwordaccounts import PasswordAccount
|
||||
if not isinstance(passwordAccount, PasswordAccount):
|
||||
logs.info("Wrong password account file (%r)" % passwordAccount)
|
||||
return httpRequestHandler.outputErrorUnauthorized(
|
||||
rootDataHolder, httpPath)
|
||||
return httpRequestHandler.outputErrorUnauthorized(httpPath)
|
||||
|
||||
if password != passwordAccount.password:
|
||||
logs.debug("Wrong password = %s (instead of %s)" % (
|
||||
password, passwordAccount.password))
|
||||
return httpRequestHandler.outputErrorUnauthorized(
|
||||
rootDataHolder, httpPath)
|
||||
return httpRequestHandler.outputErrorUnauthorized(httpPath)
|
||||
user = passwordAccount.getUser()
|
||||
if user:
|
||||
sessionToken = user.getSessionToken()
|
||||
else:
|
||||
logs.warning("account without <user/>!")
|
||||
return httpRequestHandler.outputErrorUnauthorized(
|
||||
rootDataHolder, httpPath)
|
||||
return httpRequestHandler.outputErrorUnauthorized(httpPath)
|
||||
if sessionToken:
|
||||
try:
|
||||
session = sessions.retrieveSession(sessionToken)
|
||||
|
@ -301,7 +297,7 @@ class Application(object):
|
|||
user.getDocument().save()
|
||||
else:
|
||||
logs.info("Unknown authentication scheme = %s" % authenticationScheme)
|
||||
return httpRequestHandler.outputErrorUnauthorized(rootDataHolder, httpPath)
|
||||
return httpRequestHandler.outputErrorUnauthorized(httpPath)
|
||||
|
||||
# Handle use of cookies, session and user.
|
||||
cookie = None
|
||||
|
@ -410,34 +406,36 @@ class Application(object):
|
|||
try:
|
||||
if not rootDataHolder.checkAccess(
|
||||
uriPathFragments, httpRequestHandler.command):
|
||||
raise faults.PathNotFound(rootDataHolder, "/".join(uriPathFragments))
|
||||
raise faults.PathNotFound("/".join(uriPathFragments))
|
||||
if inRawMode:
|
||||
if not rootDataHolder.isContentAccessAuthorized(inRawMode, None):
|
||||
raise faults.PathUnauthorized(
|
||||
rootDataHolder, "/".join([inRawMode] + uriPathFragments))
|
||||
raise faults.PathUnauthorized("/".join([inRawMode] + uriPathFragments))
|
||||
rootDataHolder._inRawMode = True
|
||||
rootDataHolder.walk(uriPathFragments, httpRequestHandler.command)
|
||||
except faults.BadRequest, fault:
|
||||
if environs.getVar("debug"):
|
||||
logs.exception(str(fault))
|
||||
httpRequestHandler.outputErrorBadRequest(fault.station, fault.reason)
|
||||
httpRequestHandler.outputErrorBadRequest(fault.reason, station = fault.station)
|
||||
except faults.PathForbidden, fault:
|
||||
if environs.getVar("debug"):
|
||||
logs.exception(str(fault))
|
||||
httpRequestHandler.outputErrorAccessForbidden(fault.station, fault.path)
|
||||
httpRequestHandler.outputErrorAccessForbidden(
|
||||
fault.path, station = fault.station)
|
||||
except faults.PathNotFound, fault:
|
||||
if environs.getVar("debug"):
|
||||
logs.exception(str(fault))
|
||||
httpRequestHandler.outputErrorNotFound(fault.station, fault.path)
|
||||
httpRequestHandler.outputErrorNotFound(fault.path, station = fault.station)
|
||||
except faults.PathUnauthorized, fault:
|
||||
if environs.getVar("debug"):
|
||||
logs.exception(str(fault))
|
||||
# Output an Unauthorized status only when the user is not yet logged in,
|
||||
# because we assume each user has only one account.
|
||||
if environs.getVar("user") is None:
|
||||
httpRequestHandler.outputErrorUnauthorized(fault.station, fault.path)
|
||||
httpRequestHandler.outputErrorUnauthorized(
|
||||
fault.path, station = fault.station)
|
||||
else:
|
||||
httpRequestHandler.outputErrorAccessForbidden(fault.station, fault.path)
|
||||
httpRequestHandler.outputErrorAccessForbidden(
|
||||
fault.path, station = fault.station)
|
||||
except:
|
||||
httpRequestHandler.outputUnknownException()
|
||||
finally:
|
||||
|
|
|
@ -276,7 +276,7 @@ def retrieveSession(sessionToken):
|
|||
containedFileSystem = filesystems.PartialFileSystem(sessionsPath))
|
||||
sessionHolder = sessionsDirectoryHolder.getItem(sessionToken)
|
||||
if sessionHolder is None:
|
||||
raise faults.PathNotFound(rootDataHolder, "")
|
||||
raise faults.PathNotFound("")
|
||||
return sessionHolder.getRootElement()
|
||||
|
||||
|
||||
|
|
|
@ -96,11 +96,11 @@ class AbstractStation(object):
|
|||
if not self.exists():
|
||||
if instruction in ("exists", "existsAndIsAuthorized"):
|
||||
return False
|
||||
raise faults.PathNotFound(self, "/".join(uriPathFragments))
|
||||
raise faults.PathNotFound("/".join(uriPathFragments))
|
||||
if not self.isAccessAuthorized(None):
|
||||
if instruction in ("existsAndIsAuthorized", "isAuthorized"):
|
||||
return False
|
||||
raise faults.PathUnauthorized(self, "/".join(uriPathFragments))
|
||||
raise faults.PathUnauthorized("/".join(uriPathFragments))
|
||||
return True
|
||||
|
||||
def checkAccessAndWalk(self, uriPathFragments, command = None, instruction = None):
|
||||
|
@ -275,8 +275,7 @@ class AbstractStation(object):
|
|||
content = environs.getVar("submission").readFile()
|
||||
if content is not None:
|
||||
logs.debug(content)
|
||||
environs.getVar("httpRequestHandler").outputErrorAccessForbidden(
|
||||
self, self.getUriAbsolutePath())
|
||||
environs.getVar("httpRequestHandler").outputErrorAccessForbidden(self.getUriAbsolutePath())
|
||||
|
||||
def doHttpGet(self):
|
||||
if self.getInRawMode():
|
||||
|
@ -288,14 +287,15 @@ class AbstractStation(object):
|
|||
if content is not None:
|
||||
logs.debug(content)
|
||||
environs.getVar("httpRequestHandler").outputErrorMethodNotAllowed(
|
||||
self, "%s already exists" % self.getUriAbsolutePath())
|
||||
"%s already exists" % self.getUriAbsolutePath())
|
||||
|
||||
def doHttpOptions(self):
|
||||
# We need to flush the input buffer anyway.
|
||||
content = environs.getVar("submission").readFile()
|
||||
if content is not None:
|
||||
logs.debug(content)
|
||||
environs.getVar("httpRequestHandler").outputData(self, "", headers = {"DAV": "1"})
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
"", contentLocation = None, headers = {"DAV": "1"})
|
||||
|
||||
def doHttpPost(self):
|
||||
# FIXME
|
||||
|
@ -312,14 +312,14 @@ class AbstractStation(object):
|
|||
depth = int(depth)
|
||||
except ValueError:
|
||||
if depth != "infinity":
|
||||
raise faults.BadRequest(self, "Bad depth header for PROPFIND request = %s" % depth)
|
||||
raise faults.BadRequest("Bad depth header for PROPFIND request = %s" % depth)
|
||||
# Note: A PROPFIND request with a Depth: Infinity header can impose a large burden on
|
||||
# the server. The WebDAV Working Group has stated that it is acceptable for DAV servers
|
||||
# to refuse these kinds of requests. Properly written client software should not
|
||||
# issue them.
|
||||
else:
|
||||
if depth > 1:
|
||||
raise faults.BadRequest(self, "Bad depth header for PROPFIND request = %s" % depth)
|
||||
raise faults.BadRequest("Bad depth header for PROPFIND request = %s" % depth)
|
||||
requestDocumentNode = libxml2.readDoc(
|
||||
content, None, None,
|
||||
libxml2.XML_PARSE_DTDLOAD | libxml2.XML_PARSE_NONET)
|
||||
|
@ -328,7 +328,7 @@ class AbstractStation(object):
|
|||
|
||||
def doHttpPut(self):
|
||||
httpRequestHandler = environs.getVar("httpRequestHandler")
|
||||
httpRequestHandler.outputErrorMethodNotAllowed(self, "Not a document")
|
||||
httpRequestHandler.outputErrorMethodNotAllowed("Not a document")
|
||||
|
||||
def exists(self):
|
||||
return True
|
||||
|
@ -813,11 +813,10 @@ class AbstractStation(object):
|
|||
|
||||
def outputHttpHtmlDocument(self, htmlDocument, stylesheet = None):
|
||||
mimeType, data = self.generateXmlDocumentStyledData(htmlDocument, stylesheet)
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
self, data, contentLocation = self.getUriAbsolutePath(), mimeType = mimeType)
|
||||
environs.getVar("httpRequestHandler").outputData(data, mimeType = mimeType)
|
||||
|
||||
def outputHttpSource(self):
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
def replyToHttpPropfindRequest(self, requestDocument, depth):
|
||||
import webdav
|
||||
|
@ -826,7 +825,7 @@ class AbstractStation(object):
|
|||
data = multistatus.getDocument().serialize()
|
||||
logs.debug("\nPROPFIND response =\n%s" % data)
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
self, data, mimeType = "text/xml", successCode = 207)
|
||||
data, contentLocation = None, mimeType = "text/xml", successCode = 207)
|
||||
|
||||
def source(self):
|
||||
"""Handles HTTP GET & PUT."""
|
||||
|
@ -836,7 +835,7 @@ class AbstractStation(object):
|
|||
elif command == "PUT":
|
||||
self.doHttpPut()
|
||||
else:
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
def styled(self):
|
||||
"""Handles HTTP GET."""
|
||||
|
@ -846,7 +845,7 @@ class AbstractStation(object):
|
|||
stylesheet = self.getDataHolder().getSiteXslt()
|
||||
self.outputHttpHtmlDocument(xmlDocument, stylesheet)
|
||||
else:
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
def unstyled(self):
|
||||
"""Handles HTTP GET."""
|
||||
|
@ -855,7 +854,7 @@ class AbstractStation(object):
|
|||
xmlDocument = self.generateXmlDocument()
|
||||
self.outputHttpHtmlDocument(xmlDocument)
|
||||
else:
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
def walk(self, uriPathFragments, command = None, instruction = None):
|
||||
# Don't check access to self: it must have been done before call.
|
||||
|
@ -917,7 +916,7 @@ class AbstractStation(object):
|
|||
if function is None:
|
||||
if instruction in ("exists", "existsAndIsAuthorized"):
|
||||
return False
|
||||
raise faults.PathNotFound(self, "/".join(uriPathFragments))
|
||||
raise faults.PathNotFound("/".join(uriPathFragments))
|
||||
# Check the number of arguments of function.
|
||||
functionCode = function.func_code
|
||||
acceptsArbitraryPositionalArguments = functionCode.co_flags & 4 != 0
|
||||
|
@ -932,7 +931,7 @@ class AbstractStation(object):
|
|||
if argumentsCount < minArgumentsCount or argumentsCount > maxArgumentsCount:
|
||||
if instruction in ("exists", "existsAndIsAuthorized"):
|
||||
return False
|
||||
raise faults.PathNotFound(self, "/".join(uriPathFragments))
|
||||
raise faults.PathNotFound("/".join(uriPathFragments))
|
||||
if command is None:
|
||||
if instruction in ("exists", "existsAndIsAuthorized", "isAuthorized"):
|
||||
return True
|
||||
|
@ -940,7 +939,7 @@ class AbstractStation(object):
|
|||
if not self.isAccessAuthorized(command):
|
||||
if instruction in ("existsAndIsAuthorized", "isAuthorized"):
|
||||
return False
|
||||
raise faults.PathUnauthorized(self, "/".join(uriPathFragments))
|
||||
raise faults.PathUnauthorized("/".join(uriPathFragments))
|
||||
if instruction in ("exists", "existsAndIsAuthorized", "isAuthorized"):
|
||||
# Note: In some cases, it will answer True, but the real call (with instruction ==
|
||||
# None) may raise a fault.
|
||||
|
@ -963,7 +962,7 @@ class AbstractStation(object):
|
|||
function, uriPathFragments))
|
||||
if instruction in ("exists", "existsAndIsAuthorized"):
|
||||
return False
|
||||
raise faults.PathNotFound(self, "/".join(uriPathFragments))
|
||||
raise faults.PathNotFound("/".join(uriPathFragments))
|
||||
except faults.PathNotFound, fault:
|
||||
logs.exception("Fault %s occured while calling %s(%s)" % (
|
||||
fault, function, uriPathFragments))
|
||||
|
|
|
@ -79,7 +79,7 @@ class DbXmlContainerHolder(dataholders.DataHolder):
|
|||
|
||||
command = environs.getVar("httpCommand")
|
||||
if command != "GET":
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
result = self.getDbXmlDocumentResultFromXpath(xpathExpression)
|
||||
return result.checkAccessAndWalk(uriPathFragments, command, environs.getVar("instruction"))
|
||||
|
@ -167,7 +167,7 @@ class DbXmlContainerHolder(dataholders.DataHolder):
|
|||
|
||||
command = environs.getVar("httpCommand")
|
||||
if command != "GET":
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
result = self.getDbXmlNodeResultFromXpath(xpathExpression)
|
||||
return result.checkAccessAndWalk(uriPathFragments, command, environs.getVar("instruction"))
|
||||
|
@ -343,8 +343,7 @@ class DbXmlDocumentStation(stations.AbstractStation, documents.AbstractDocument)
|
|||
data = self.dbxmlDocument.getContentAsString()
|
||||
dataHolder = self.getDataHolder()
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
self, data, contentLocation = self.getUriAbsolutePath(),
|
||||
mimeType = dataholders.mimeTypes[".xml"],
|
||||
data, mimeType = dataholders.mimeTypes[".xml"],
|
||||
modificationTime = dataHolder.getModificationTime())
|
||||
|
||||
def save(self):
|
||||
|
|
|
@ -237,7 +237,7 @@ class MessageContext(html.WidgetElementContext):
|
|||
# If this method is called as a HTTP handler, alerts the user that the email has been
|
||||
# sent.
|
||||
environs.getVar("httpRequestHandler").outputAlert(
|
||||
self, N_("The email has been successfully sent."), title = N_("Email Sent"))
|
||||
N_("The email has been successfully sent."), title = N_("Email Sent"))
|
||||
|
||||
|
||||
class Mixed(Multipart):
|
||||
|
|
|
@ -111,7 +111,7 @@ class LibertyAlliance(directories.Directory):
|
|||
|
||||
command = environs.getVar("httpCommand")
|
||||
if command != "GET":
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
success = True
|
||||
session = environs.getVar("session")
|
||||
if session is None:
|
||||
|
@ -304,7 +304,7 @@ You have been succesfully authenticated; click ok to go back to the service prov
|
|||
## #certificateFilePath = property(getCertificateFilePath)
|
||||
## #certificationAuthorityCertificateFilePath
|
||||
else:
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
def getCertificateFilePath(self):
|
||||
nodes = self.evaluateXpath("yep:certificateFile")
|
||||
|
@ -373,7 +373,7 @@ You have been succesfully authenticated; click ok to go back to the service prov
|
|||
|
||||
command = environs.getVar("httpCommand")
|
||||
if command != "GET":
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
authnRequest = lasso.AuthnRequest(self.metadata.providerId)
|
||||
|
||||
|
@ -411,8 +411,7 @@ You have been succesfully authenticated; click ok to go back to the service prov
|
|||
assert identityProviderMetadata is not None
|
||||
ssoUrl = "%s?%s" % (
|
||||
identityProviderMetadata.singleSignOnServiceUrl, ssoQuery)
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(
|
||||
self, ssoUrl)
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(ssoUrl)
|
||||
|
||||
def singleSignOn(self):
|
||||
"""Liberty Alliance Identity Provider Method which processes an
|
||||
|
@ -423,7 +422,7 @@ You have been succesfully authenticated; click ok to go back to the service prov
|
|||
|
||||
command = environs.getVar("httpCommand")
|
||||
if command != "GET":
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
ssoQuery = locations.cleanUpQuery(
|
||||
environs.getVar("httpQuery"), "sessionToken")
|
||||
|
@ -432,7 +431,7 @@ You have been succesfully authenticated; click ok to go back to the service prov
|
|||
authnResponse = lasso.AuthnResponse.new_from_request_query(
|
||||
ssoQuery, self.metadata.providerId)
|
||||
if authnResponse is None:
|
||||
raise faults.PathForbidden(self, "")
|
||||
raise faults.PathForbidden("")
|
||||
if not authnResponse.verify_signature(
|
||||
self.peerPublicKeyFilePath, # FIXME: Use a certificate instead & How to know which SP?
|
||||
self.privateKeyFilePath # Should be removed. Used only to generate a fake signature.
|
||||
|
|
|
@ -320,7 +320,7 @@ provider.\
|
|||
|
||||
command = environs.getVar("httpCommand")
|
||||
if command != "GET":
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
identityProviderMetadata = self.identityProviderMetadata
|
||||
assert identityProviderMetadata is not None
|
||||
|
@ -351,8 +351,7 @@ provider.\
|
|||
relayState = cryptedRelayState,
|
||||
serviceProviderId = providerId,
|
||||
singleSignOnServiceUrl = identityProviderMetadata.singleSignOnServiceUrl)
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(
|
||||
self, ssoUrl)
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(ssoUrl)
|
||||
|
||||
def processAuthenticationResponse(self):
|
||||
"""Liberty Alliance Service Provider Method which processes an
|
||||
|
@ -407,7 +406,7 @@ provider.\
|
|||
# Error, unknown profile.
|
||||
response = sso.buildAuthenticationResponseFromKeywords(keywords)
|
||||
else:
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
relayState = response.getRelayState()
|
||||
statusCode = response.getStatusCode()
|
||||
|
@ -415,7 +414,7 @@ provider.\
|
|||
message = _("Liberty Alliance authentication response"
|
||||
" failed (reason = %s).") % statusCode
|
||||
return environs.getVar("httpRequestHandler").outputAlert(
|
||||
self, message, title = N_("Failure"), url = self.constructUri("/"))
|
||||
message, title = N_("Failure"), url = self.constructUri("/"))
|
||||
|
||||
assertion = response.getAssertion()
|
||||
idpNameIdentifier = assertion.getIDPProvidedNameIdentifier()
|
||||
|
@ -490,8 +489,7 @@ provider.\
|
|||
if not nextUrl:
|
||||
nextUrl = "/"
|
||||
nextUrl = self.constructUri(nextUrl)
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(
|
||||
self, nextUrl)
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(nextUrl)
|
||||
|
||||
def singleSignOn(self):
|
||||
"""Liberty Alliance Identity Provider Method which processes an
|
||||
|
@ -500,7 +498,7 @@ provider.\
|
|||
|
||||
command = environs.getVar("httpCommand")
|
||||
if command != "GET":
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
# Build the Authentication Request.
|
||||
submission = environs.getVar("submission")
|
||||
|
@ -561,8 +559,7 @@ provider.\
|
|||
url = sso.getServiceProviderAssertionArtifactHandlerUrl(
|
||||
serviceProviderMetadata.assertionConsumerServiceUrl, # FIXME
|
||||
sso.buildStatus("noPassive"))
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(
|
||||
self, url)
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(url)
|
||||
return self.afterAuthentication(
|
||||
"singleSignOn", authenticationRequest)
|
||||
elif forceAuthentication or user is None:
|
||||
|
|
|
@ -43,6 +43,7 @@ import xforms.descriptions as descriptions
|
|||
|
||||
from identities import Identity
|
||||
|
||||
|
||||
class LoginPage(descriptions.Page):
|
||||
def newContext(self, specimen, *attributes, **keywords):
|
||||
return LoginPageContext(self, specimen, *attributes, **keywords)
|
||||
|
@ -55,10 +56,9 @@ class LoginPage(descriptions.Page):
|
|||
submission = environs.getVar("submission")
|
||||
if submission.getField("emailPassword"):
|
||||
# Alert the user that its password has been sent by email.
|
||||
nextUrl = specimen.constructUri(
|
||||
nextUrl, preserveAbsolutePath = True)
|
||||
nextUrl = specimen.constructUri(nextUrl, preserveAbsolutePath = True)
|
||||
return environs.getVar("httpRequestHandler").outputAlert(
|
||||
self, N_("An email containing your password as been sent to %s") % specimen.email,
|
||||
N_("An email containing your password as been sent to %s") % specimen.email,
|
||||
title = N_("Password sent by email"), url = nextUrl)
|
||||
else:
|
||||
# Log the user in.
|
||||
|
@ -76,15 +76,13 @@ class LoginPage(descriptions.Page):
|
|||
user.getDocument().save()
|
||||
baseEnviron = environs.get(_level = "handleHttpCommand")
|
||||
baseEnviron.setVar("user", user)
|
||||
logs.debug(
|
||||
"""Setting session user = "%s" at location "%s".""" % (
|
||||
user.simpleLabel, session.userLocation))
|
||||
logs.debug("""Setting session user = "%s" at location "%s".""" % (
|
||||
user.simpleLabel, session.userLocation))
|
||||
# Note: constructUri must be called after getOrCreateSession, so
|
||||
# that nextUrl contains the sessionToken.
|
||||
nextUrl = specimen.constructUri(
|
||||
nextUrl, preserveAbsolutePath = True)
|
||||
nextUrl = specimen.constructUri(nextUrl, preserveAbsolutePath = True)
|
||||
return environs.getVar('httpRequestHandler').outputRedirect(
|
||||
specimen, nextUrl)
|
||||
nextUrl, station = specimen)
|
||||
|
||||
def validateSubmittedContext(self, context):
|
||||
modelContext = context.xformsDefaultModel
|
||||
|
@ -275,12 +273,12 @@ class PasswordAccounts(directories.Directory):
|
|||
|
||||
command = environs.getVar("httpCommand")
|
||||
if command != "GET":
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
|
||||
try:
|
||||
elementFeature = modules.getElementFeature(namespaces.yep.uri, "passwordAccount")
|
||||
except (KeyError, ValueError):
|
||||
raise faults.PathNotFound(environs.getVar("currentStation"), "")
|
||||
raise faults.PathNotFound("")
|
||||
constructorStation = stations.HolderConstructorStation(
|
||||
"login", elementFeature, previous = self)
|
||||
return constructorStation.checkAccessAndWalk(
|
||||
|
|
|
@ -339,7 +339,7 @@ class Page(xforms.Control):
|
|||
nextUrl = None
|
||||
if not nextUrl:
|
||||
nextUrl = specimen.getUri()
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(specimen, nextUrl)
|
||||
return environs.getVar("httpRequestHandler").outputRedirect(nextUrl, station = specimen)
|
||||
|
||||
def submitContext(self, context):
|
||||
bodyNodes = self.evaluateXpath("yep:body")
|
||||
|
|
|
@ -84,8 +84,7 @@ class ZipHolder(directories.DirectoryHolder):
|
|||
def outputHttpSource(self):
|
||||
dataFile = self.fileSystem.open(self.getFileSystemPath(), "rb")
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
self, dataFile, contentLocation = self.getUriAbsolutePath(), mimeType = self.mimeType,
|
||||
modificationTime = self.getModificationTime())
|
||||
dataFile, mimeType = self.mimeType, modificationTime = self.getModificationTime())
|
||||
|
||||
## def setupDataHolder(self):
|
||||
## self.containedFileSystem = filesystems.ZipFileSystem(
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
|
||||
environs.getVar("httpRequestHandler").outputData(
|
||||
environs.getVar("currentStation", default = None), self.data,
|
||||
contentLocation = self.getUriAbsolutePath(), mimeType = self.mimeType,
|
||||
modificationTime = self.getModificationTime())
|
||||
self.data, mimeType = self.mimeType, modificationTime = self.getModificationTime())
|
||||
|
|
|
@ -66,4 +66,4 @@ if virtualHost.isSsl and virtualHost.brotherVirtualHost is not None:
|
|||
nextUrl = "http://%s%s" % (uriAuthority, nextUrlAbsolutePath)
|
||||
else:
|
||||
nextUrl = self.constructUri(nextUrl, preserveAbsolutePath = True)
|
||||
environs.getVar("httpRequestHandler").outputRedirect(self, nextUrl)
|
||||
environs.getVar("httpRequestHandler").outputRedirect(nextUrl)
|
||||
|
|
Reference in New Issue