⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapsite.py

📁 python web programming 部分
💻 PY
字号:
#
# $Workfile: MapSite.py $ $Revision: 6 $
# $Date: 10/07/01 1:46p $ $Author: Sholden $
#
"""Used to instantiate required page generators, and look up realm authentication data."""

import Static
from types import ClassType, DictType, StringType

def PageSpec(op, path, query, session, headers, Map,
             Realm=None, PathFound=None):
    """Return the page processor and authentication realm coresponding to a path."""
    if not path:
        raise KeyError
    pathel = path[0]
    if not PathFound:
        PathFound = [pathel]
    else:
        PathFound.append(pathel)
    del path[0]
    item, realm = Map[pathel]
    if not realm:
        realm = Realm # Inherit realm from containing tree
    itemtype = type(item)
    if itemtype == DictType:
        return PageSpec(op, path, query, session, headers,
                         Map=item, Realm=realm, PathFound=PathFound)
    if len(PathFound) and not len(path): # A class element was not followed by a "/"
            raise ValueError
    if itemtype == StringType:
        if path[-1] == "": # remove trailing slash
            del path[-1]
        return Static.Page(op, path, query, session, headers,
                        Realm=realm, Initpath=item.split("/"))
    elif itemtype == ClassType:
        if path[-1] == "": # remove evidence of trailing slash
            del path[-1]
        return item(op, path, query, session, headers,
                     Realm=realm, Initpath=PathFound)
    else:
        raise KeyError

def RealmData(realm):
    try:
        return SiteSpec.RealmAuth[realm]
    except KeyError:
        return None

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -