当前位置: 首页>>代码示例>>Python>>正文


Python porcupine.HttpContext类代码示例

本文整理汇总了Python中porcupine.HttpContext的典型用法代码示例。如果您正苦于以下问题:Python HttpContext类的具体用法?Python HttpContext怎么用?Python HttpContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HttpContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: new

def new(self):
    "Displays a generic form for creating a new object"
    context = HttpContext.current()
        
    sCC = context.request.queryString['cc'][0]
    oNewItem = misc.getCallableByName(sCC)()
    
    params = {
        'CC': sCC,
        'URI': context.request.getRootUrl() + '/' + self.id,
        'ICON': oNewItem.__image__,
        'PROPERTIES_TAB': '',
        'EXTRA_TABS': '',
        'SECURITY_TAB': baseitem._getSecurity(self, context.user, True)
    }
    
    # inspect item properties
    sProperties = ''
    for attr_name in oNewItem.__props__:
        attr = getattr(oNewItem, attr_name)
        if isinstance(attr, datatypes.DataType):
            control, tab = baseitem._getControlFromAttribute(oNewItem,
                                                             attr_name,
                                                             attr,
                                                             False,
                                                             True)
            sProperties += control
            params['EXTRA_TABS'] += tab
    
    params['PROPERTIES'] = sProperties
    
    return params
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:32,代码来源:basecontainer.py

示例2: update

def update(self, data):
    "Updates an object based on values contained inside the data dictionary"
    context = HttpContext.current()
    # get user role
    iUserRole = objectAccess.getAccess(self, context.user)
    if data.has_key('__rolesinherited') and iUserRole == objectAccess.COORDINATOR:
        self.inheritRoles = data.pop('__rolesinherited')
        if not self.inheritRoles:
            acl = data.pop('__acl')
            if acl:
                security = {}
                for descriptor in acl:
                    security[descriptor['id']] = int(descriptor['role'])
                self.security = security

    for prop in data:
        oAttr = getattr(self, prop)
        if isinstance(oAttr, datatypes.File):
            # see if the user has uploaded a new file
            if data[prop]['tempfile']:
                oAttr.filename = data[prop]['filename']
                sPath = context.server.temp_folder + '/' + data[prop]['tempfile']
                oAttr.loadFromFile(sPath)
        elif isinstance(oAttr, datatypes.Date):
            oAttr.value = data[prop].value
        elif isinstance(oAttr, datatypes.Integer):
            oAttr.value = int(data[prop])
        else:
            oAttr.value = data[prop]
    txn = db.getTransaction()
    self.update(txn)
    return True
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:32,代码来源:baseitem.py

示例3: selectobjects

def selectobjects(self):
    "Displays the select objects dialog"
    context = HttpContext.current()
    sCC = context.request.queryString['cc'][0]
    params = {
        'ID': self.id or '/',
        'IMG': self.__image__,
        'DN': self.displayName.value,
        'HAS_SUBFOLDERS': str(self.hasSubfolders()).lower(),
        'MULTIPLE': context.request.queryString['multiple'][0],
        'CC': sCC
    }

    oCmd = OqlCommand()
    sOql = "select * from '%s'" % self.id
    if sCC != '*':
        ccs = sCC.split('|')
        ccs = ["contentclass='%s'" % x for x in ccs]
        sConditions = " or ".join(ccs)
        sOql += " where %s" % sConditions
    oRes = oCmd.execute(sOql)

    sOptions = ''
    for obj in oRes:
         sOptions += '<option img="%s" value="%s" caption="%s"/>' % \
                     (obj.__image__, obj.id, obj.displayName.value)
    params['OPTIONS'] = sOptions
    return params
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:28,代码来源:basecontainer.py

示例4: applySettings

def applySettings(self, data):
    "Saves user's preferences"
    context = HttpContext.current()
    activeUser = context.original_user
    for key in data:
        activeUser.settings.value[key] = data[key]
    txn = db.get_transaction()
    activeUser.update(txn)
    return True
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:9,代码来源:rootfolder.py

示例5: rename

def rename(self):
    "Displays the rename dialog"
    context = HttpContext.current()
    context.response.setHeader('cache-control', 'no-cache')
    return {
        'TITLE': self.displayName.value,
        'ID': self.id,
        'DN': self.displayName.value,
    }
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:9,代码来源:baseitem.py

示例6: login

def login(self, username, password):
    "Remote method for authenticating users"
    http_context = HttpContext.current()
    users_container = db.getItem("users")
    user = users_container.getChildByName(username)
    if user and hasattr(user, "authenticate"):
        if user.authenticate(password):
            http_context.session.user = user
            return True
    return False
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:10,代码来源:rootfolder.py

示例7: login

def login(self, username, password):
    "Remote method for authenticating users"
    http_context = HttpContext.current()
    users_container = db.get_item('users')
    user = users_container.get_child_by_name(username)
    if user and hasattr(user, 'authenticate'):
        if user.authenticate(password):
            http_context.session.userid = user.id
            return True
    return False
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:10,代码来源:rootfolder.py

示例8: new

def new(self):
    "Displays the form for creating a new application"
    context = HttpContext.current()
    oApp = common.Application()
    return {
        'CC': oApp.contentclass,
        'URI': self.id,
        'ICON': oApp.__image__,
        'SECURITY_TAB': baseitem._getSecurity(self, context.user, True)
    }
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:10,代码来源:appsfolder.py

示例9: new

def new(self):
    context = HttpContext.current()
    oGroup = security.Group()
    return {
        'CC' : oGroup.contentclass,
        'URI' : self.id,
        'REL_CC' : '|'.join(oGroup.members.relCc),
        'ICON' : oGroup.__image__,
        'SELECT_FROM_POLICIES' : 'policies',
        'POLICIES_REL_CC' : '|'.join(oGroup.policies.relCc),
        'SECURITY_TAB' : baseitem._getSecurity(self, context.user, True)
    }
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:12,代码来源:usersfolder.py

示例10: properties

def properties(self):
    "Displays the deleted item's properties form"
    context = HttpContext.current()
    sLang = context.request.getLang()
    modified = date.Date(self.modified)
    return {
        "ICON": self.__image__,
        "NAME": xml.xml_encode(self.originalName),
        "LOC": xml.xml_encode(self.originalLocation),
        "MODIFIED": modified.format(baseitem.DATES_FORMAT, sLang),
        "MODIFIED_BY": xml.xml_encode(self.modifiedBy),
        "CONTENTCLASS": self.get_deleted_item().contentclass,
    }
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:13,代码来源:deleteditem.py

示例11: properties

def properties(self):
    "Displays the deleted item's properties form"
    context = HttpContext.current()
    sLang = context.request.getLang()
    modified = date.Date(self.modified)
    return {
        'ICON': self.__image__,
        'NAME': self.originalName,
        'LOC': self.originalLocation,
        'MODIFIED': modified.format(baseitem.DATES_FORMAT, sLang),
        'MODIFIED_BY': self.modifiedBy,
        'CONTENTCLASS': self.getDeletedItem().contentclass
    }
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:13,代码来源:deleteditem.py

示例12: upload

def upload(self, chunk, fname):
    context = HttpContext.current()
    chunk = base64.decodestring(chunk)
    if not fname:
        fileno, fname = context.session.getTempFile()
        os.write(fileno, chunk)
        os.close(fileno)
        fname = os.path.basename(fname)
    else:
        tmpfile = file(context.server.temp_folder + '/' + fname, 'ab+')
        tmpfile.write(chunk)
        tmpfile.close()
    return fname
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:13,代码来源:rootfolder.py

示例13: user_settings

def user_settings(self):
    "Displays the user settings dialog"
    context = HttpContext.current()
    context.response.setHeader("cache-control", "no-cache")

    settings = context.session.user.settings
    taskbar_pos = settings.value.setdefault("TASK_BAR_POS", "bottom")

    params = {"TASK_BAR_POS": taskbar_pos}

    if taskbar_pos == "bottom":
        params["CHECKED_TOP"] = "false"
        params["CHECKED_BOTTOM"] = "true"
    else:
        params["CHECKED_TOP"] = "true"
        params["CHECKED_BOTTOM"] = "false"

    autoRun = settings.value.setdefault("AUTO_RUN", "")

    if settings.value.setdefault("RUN_MAXIMIZED", False) == True:
        params["RUN_MAXIMIZED_VALUE"] = "true"
    else:
        params["RUN_MAXIMIZED_VALUE"] = "false"

    # get applications
    oCmd = OqlCommand()
    sOql = "select displayName,launchUrl,icon from 'apps' " + "order by displayName asc"
    apps = oCmd.execute(sOql)

    sSelected = ""
    if autoRun == "":
        sSelected = "true"

    sApps = '<option caption="@@[email protected]@" selected="%s" value=""/>' % sSelected
    if len(apps) > 0:
        for app in apps:
            if autoRun == app["launchUrl"]:
                sSelected = "true"
            else:
                sSelected = "false"
            sApps += '<option img="%s" caption="%s" value="%s" selected="%s"/>' % (
                app["icon"],
                app["displayName"],
                app["launchUrl"],
                sSelected,
            )
    params["APPS"] = sApps

    return params
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:49,代码来源:rootfolder.py

示例14: selectcontainer

def selectcontainer(self):
    "Displays a dialog for selecting the destination container"
    context = HttpContext.current()
    rootFolder = db.getItem('')
    params = {
        'ROOT_ID': '/',
        'ROOT_IMG': rootFolder.__image__,
        'ROOT_DN': rootFolder.displayName.value,
        'ID': self.id,
    }
    sAction = context.request.queryString['action'][0]
    params['TITLE'] = '@@%[email protected]@' % sAction.upper()
    if sAction != 'select_folder':
        params['TITLE'] += ' &quot;%s&quot;' % self.displayName.value
    return params
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:15,代码来源:baseitem.py

示例15: user_settings

def user_settings(self):
    "Displays the user settings dialog"
    context = HttpContext.current()
    context.response.setHeader('cache-control', 'no-cache')
    
    settings = context.user.settings
    taskbar_pos = settings.value.setdefault('TASK_BAR_POS', 'bottom')
    
    params = {'TASK_BAR_POS' : taskbar_pos}
    
    if taskbar_pos == 'bottom':
        params['CHECKED_TOP'] = 'false'
        params['CHECKED_BOTTOM'] = 'true'
    else:
        params['CHECKED_TOP'] = 'true'
        params['CHECKED_BOTTOM'] = 'false'
        
    autoRun = settings.value.setdefault('AUTO_RUN', '')
        
    if settings.value.setdefault('RUN_MAXIMIZED', False) == True:
        params['RUN_MAXIMIZED_VALUE'] = 'true'
    else:
        params['RUN_MAXIMIZED_VALUE'] = 'false'

    # get applications
    oCmd = OqlCommand()
    sOql = "select displayName,launchUrl,icon from 'apps' " + \
           "order by displayName asc"
    apps = oCmd.execute(sOql)
    
    sSelected = ''
    if autoRun == '':
        sSelected = 'true'
    
    sApps = '<option caption="@@[email protected]@" selected="%s" value=""/>' \
            % sSelected
    if len(apps) > 0:
        for app in apps:
            if autoRun == app['launchUrl']:
                sSelected = 'true'
            else:
                sSelected = 'false'
            sApps += \
             '<option img="%s" caption="%s" value="%s" selected="%s"/>' % \
             (app['icon'], app['displayName'], app['launchUrl'], sSelected)
    params['APPS'] = sApps
    
    return params
开发者ID:BackupTheBerlios,项目名称:porcupineserver-svn,代码行数:48,代码来源:rootfolder.py


注:本文中的porcupine.HttpContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。