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


Python StringEscapeUtils.escapeHtml方法代码示例

本文整理汇总了Python中org.apache.commons.lang.StringEscapeUtils.escapeHtml方法的典型用法代码示例。如果您正苦于以下问题:Python StringEscapeUtils.escapeHtml方法的具体用法?Python StringEscapeUtils.escapeHtml怎么用?Python StringEscapeUtils.escapeHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.StringEscapeUtils的用法示例。


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

示例1: __init__

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def __init__(self):
     print "formData=%s" % formData
     
     result = "{}"
     func = formData.get("func")
     oid = formData.get("oid")
     
     if func != "set-package-title":
         nodeId = formData.get("nodeId")
         nodePath = self.__getNodePath(formData.get("parents"), nodeId)
         originalPath = "manifest//%s" % nodeId
     
     self.__object = Services.getStorage().getObject(oid)
     sourceId = self.__object.getSourceId()
     payload = self.__object.getPayload(sourceId)
     self.__manifest = JsonConfigHelper(payload.open())
     payload.close()
     
     if func == "set-package-title":
         title = formData.get("title")
         self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
         self.__saveManifest()
     if func == "rename":
         title = formData.get("title")
         self.__manifest.set("%s/title" % nodePath, title)
         self.__saveManifest()
     elif func == "move":
         refNodeId = formData.get("refNodeId")
         refNodePath = self.__getNodePath(formData.get("refParents"),
                                          formData.get("refNodeId"));
         moveType = formData.get("type")
         if moveType == "before":
             self.__manifest.moveBefore(originalPath, refNodePath)
         elif moveType == "after":
             self.__manifest.moveAfter(originalPath, refNodePath)
         elif moveType == "inside":
             self.__manifest.move(originalPath, nodePath)
         self.__saveManifest()
     elif func == "update":
         title = StringEscapeUtils.escapeHtml(formData.get("title"))
         hidden = formData.get("hidden")
         hidden = hidden == "true"
         self.__manifest.set("%s/title" % nodePath, title)
         self.__manifest.set("%s/hidden" % nodePath, str(hidden))
         self.__saveManifest()
         result = '{ title: "%s", hidden: "%s" }' % (title, hidden)
     
     self.__object.close()
     writer = response.getPrintWriter("text/plain; charset=UTF-8")
     writer.println(result)
     writer.close()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:53,代码来源:manifest.py

示例2: handle_data

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def handle_data(self, data):
     # ~ print("Data     :", data)
     d = " ".join(data.split())
     if d:
         # ~ print ("This is real: ", d)
         if self.current_tag == "span":
             d = map2(d)
             # ~ if d in ["checked", "unchecked"]:
             # ~ print "Do yes/no, radio buttons, checkboxes stuff, how many spans?"
             if d in self.contacts:
                 # ~ print "We need to process %s " % self.contacts[d]
                 # if span has interesting string, trigger recording next tr
                 self.nexts["td"] = True
                 self.current_contact = self.contacts[d]
             if d in "Select the appropriate re-use condition for this research data":
                 print "Hit: collection-details-access-level but different, skip for now"
             if d in "Indicate an anticipated number of users of this data":
                 print "Hit: exp-number-users,skip for now"
             if d in self.simple_fields:
                 # ~ print "Simle field, the content of the next cell need to be packed"
                 self.current_field["name"] = self.simple_fields[d]
                 self.current_field["type"] = "simple"
                 self.nexts["td"] = True
             ## the if-else block is not useful if field names and values are in different cells
             ## it is useful when one next to each other
             # if self.leading:
             #    self.current_key = d
             #    #~ print "create key %s" % self.current_key
             #    self.jobj[self.current_key] = ""
             # else:
             #    #~ print "save value [ %s ] to %s" % (data, self.current_key)
             #    self.jobj[self.current_key] = d
             if self.nexts["p"] and self.start_push:
                 self.stacks.append(StringEscapeUtils.escapeHtml(d))
开发者ID:qcif,项目名称:rdsi-arms,代码行数:36,代码来源:docxexporter.py

示例3: getContent

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
    def getContent(self, oid, metadata):
        # Get the object
        object = Services.getStorage().getObject(oid)
        if object is None:
            return ""

        # Get the preview/source payload
        pid = metadata.getFirst("preview")
        if pid is None:
            pid = object.getSourceId()
        if pid is None:
            return ""
        payload = object.getPayload(object.getSourceId())
        if payload is None:
            return ""

        # Stream the content out to string
        out = ByteArrayOutputStream()
        IOUtils.copy(payload.open(), out)
        payload.close()
        string = out.toString("UTF-8")

        return "<pre>" + StringEscapeUtils.escapeHtml(string) + "</pre>"
开发者ID:Deakin,项目名称:the-fascinator,代码行数:25,代码来源:detail.py

示例4: __activate__

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
    def __activate__(self, context):
        self.velocityContext = context
        auth = context["page"].authentication
        if auth.is_logged_in():
            self.fd = self.vc("formData").get

            #print "formData=%s" % self.vc("formData")
            result = "{}"
            func = self.fd("func")
            oid = self.fd("oid")
    
            self.__object = Services.getStorage().getObject(oid)
            sourceId = self.__object.getSourceId()
            payload = self.__object.getPayload(sourceId)
            self.__manifest = Manifest(payload.open())
            payload.close()

            # Add a new custom node at the top leve
            if func == "add-custom":
                id = md5.new(str(uuid.uuid4())).hexdigest()
                self.__manifest.addTopNode(id, "Untitled")
                # We gave an ID for the Library to use in storage, but as
                #  metadata we want it to say 'blank'
                node = self.__manifest.getNode("node-%s" % id)
                node.setId("blank")
                print "Adding blank node: '%s'" % id
                self.__saveManifest()
                result = '{ "attributes": { "id": "node-%s", "rel": "blank" }, "data": "Untitled" }' % id

            # Update top-level package metadata
            if func == "update-package-meta":
                metaList = list(self.vc("formData").getValues("metaList"))
                jsonObj = self.__manifest.getJsonObject()
                for metaName in metaList:
                    value = self.fd(metaName)
                    jsonObj.put(metaName, value)
                #title = formData.get("title")
                #self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
                self.__saveManifest()

            # Rename the indicated node
            if func == "rename":
                node = self.__manifest.getNode(self.fd("nodeId"))
                node.setTitle(self.fd("title"))
                self.__saveManifest()

            # Move a node from one location to another
            elif func == "move":
                moveType = self.fd("type")
                if moveType == "before":
                    self.__manifest.moveBefore(self.fd("nodeId"), self.fd("refNodeId"))
                elif moveType == "after":
                    self.__manifest.moveAfter(self.fd("nodeId"), self.fd("refNodeId"))
                elif moveType == "inside":
                    self.__manifest.move(self.fd("nodeId"), self.fd("refNodeId"))
                self.__saveManifest()

            # Update the metadata of the indicated node
            elif func == "update":
                title = StringEscapeUtils.escapeHtml(self.fd("title"))
                hidden = self.fd("hidden")
                hidden = hidden == "true"

                node = self.__manifest.getNode(self.fd("nodeId"))
                node.setTitle(title)
                node.setHidden(hidden)
                self.__saveManifest()
                result = '{ "title": "%s", "hidden": "%s" }' % (title, hidden)

            # Update the metadata of the indicated node
            elif func == "delete":
                node = self.__manifest.getNode(self.fd("nodeId"))
                title = node.getTitle()
                if title:
                    self.__manifest.delete(self.fd("nodeId"))
                    self.__saveManifest()
                else:
                    title = "Untitled"
                result = '{ "title": "%s" }' % title
            self.__object.close()

        else:
            self.vc("response").setStatus(403)
            result = '{ "status": "error", "message": "Only registered users can access this API" }'

        writer = self.vc("response").getPrintWriter("text/plain; charset=UTF-8")
        writer.println(result)
        writer.close()
开发者ID:Deakin,项目名称:the-fascinator,代码行数:90,代码来源:manifest.py

示例5: escapeHtml

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def escapeHtml(self, text):
     return StringEscapeUtils.escapeHtml(text)
开发者ID:kiranba,项目名称:the-fascinator,代码行数:4,代码来源:layout.py

示例6: getMeta

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def getMeta(self, metaName):
     return StringEscapeUtils.escapeHtml(self.vc("formData").get(metaName, self.__manifest.getString(None, [metaName])))
开发者ID:Deakin,项目名称:the-fascinator,代码行数:4,代码来源:organiser.py

示例7: getPackageTitle

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def getPackageTitle(self):
     return StringEscapeUtils.escapeHtml(self.vc("formData").get("title", self.__manifest.getTitle()))
开发者ID:Deakin,项目名称:the-fascinator,代码行数:4,代码来源:organiser.py

示例8: getFormData

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def getFormData(self, field):
     return StringEscapeUtils.escapeHtml(self.vc("formData").get(field, ""))
开发者ID:Deakin,项目名称:the-fascinator,代码行数:4,代码来源:organiser.py

示例9: escapeHtml

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def escapeHtml(self, value):
     if value:
         return StringEscapeUtils.escapeHtml(value) or ""
     return ""
开发者ID:ozej8y,项目名称:redbox,代码行数:6,代码来源:detail.py

示例10: getEscapeHtml

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def getEscapeHtml(self, value):
     return StringEscapeUtils.escapeHtml(value)
开发者ID:the-fascinator,项目名称:fascinator-portal,代码行数:4,代码来源:result.py

示例11: getMeta

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def getMeta(self, metaName):
     return StringEscapeUtils.escapeHtml(formData.get(metaName, self.__manifest.get(metaName)))
开发者ID:kiranba,项目名称:the-fascinator,代码行数:4,代码来源:organiser.py

示例12: getRequestData

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def getRequestData(self, field):
     return StringEscapeUtils.escapeHtml(self.__requestData.getString("", [field]))
开发者ID:UTAS-Library,项目名称:Research-Data-Discovery-Service,代码行数:4,代码来源:inbox.py

示例13: getText

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
 def getText(self):
     return StringEscapeUtils.escapeHtml(self.__metadata.get("user_agreement_text"))
开发者ID:the-fascinator,项目名称:fascinator-portal,代码行数:4,代码来源:userAgreement.py

示例14: __activate__

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
    def __activate__(self, context):
        self.velocityContext = context
        auth = context["page"].authentication
        if auth.is_logged_in():
            self.fd = self.vc("formData").get

            print "formData=%s" % self.vc("formData")
            result = "{}"
            func = self.fd("func")
            oid = self.fd("oid")
    
            if func != "update-package-meta":
                nodeId = self.fd("nodeId")
                nodePath = self.__getNodePath(self.fd("parents"), nodeId)
                originalPath = "manifest//%s" % nodeId
    
            self.__object = Services.getStorage().getObject(oid)
            sourceId = self.__object.getSourceId()
            payload = self.__object.getPayload(sourceId)
            self.__manifest = JsonConfigHelper(payload.open())
            payload.close()
    
            if func == "update-package-meta":
                print "*********  update-package-meta ***************"
                metaList = list(self.vc("formData").getValues("metaList"))
                for metaName in metaList:
                    value = self.fd(metaName)
                    self.__manifest.set(metaName, value)
                #title = formData.get("title")
                #self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
                self.__saveManifest()
            if func == "rename":
                title = self.fd("title")
                self.__manifest.set("%s/title" % nodePath, title)
                self.__saveManifest()
            elif func == "move":
                refNodeId = self.fd("refNodeId")
                refNodePath = self.__getNodePath(self.fd("refParents"),
                                                 self.fd("refNodeId"));
                moveType = self.fd("type")
                if moveType == "before":
                    self.__manifest.moveBefore(originalPath, refNodePath)
                elif moveType == "after":
                    self.__manifest.moveAfter(originalPath, refNodePath)
                elif moveType == "inside":
                    self.__manifest.move(originalPath, nodePath)
                self.__saveManifest()
            elif func == "update":
                title = StringEscapeUtils.escapeHtml(self.fd("title"))
                hidden = self.fd("hidden")
                hidden = hidden == "true"
                self.__manifest.set("%s/title" % nodePath, title)
                self.__manifest.set("%s/hidden" % nodePath, str(hidden))
                #if self.__manifest.get("%s/id" % nodePath) is None:
                #    print "blank node!"
                self.__saveManifest()
                result = '{ title: "%s", hidden: "%s" }' % (title, hidden)
            elif func == "delete":
                title = self.__manifest.get("%s/title" % nodePath)
                if title:
                    self.__manifest.removePath(nodePath)
                    self.__saveManifest()
                else:
                    title = "Untitled"
                result = '{ title: "%s" }' % title
            
            self.__object.close()
        else:
            result = '{ "status": "error", "message": "Only registered users can access this API" }'
        
        writer = self.vc("response").getPrintWriter("text/plain; charset=UTF-8")
        writer.println(result)
        writer.close()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:75,代码来源:manifest.py

示例15: __init__

# 需要导入模块: from org.apache.commons.lang import StringEscapeUtils [as 别名]
# 或者: from org.apache.commons.lang.StringEscapeUtils import escapeHtml [as 别名]
    def __init__(self):
        print "formData=%s" % formData

        result = "{}"
        func = formData.get("func")
        oid = formData.get("oid")

        if func != "update-package-meta":
            nodeId = formData.get("nodeId")
            nodePath = self.__getNodePath(formData.get("parents"), nodeId)
            originalPath = "manifest//%s" % nodeId

        self.__object = Services.getStorage().getObject(oid)
        sourceId = self.__object.getSourceId()
        payload = self.__object.getPayload(sourceId)
        self.__manifest = JsonConfigHelper(payload.open())
        payload.close()

        if func == "update-package-meta":
            print "*********  update-package-meta ***************"
            metaList = list(formData.getValues("metaList"))
            for metaName in metaList:
                value = formData.get(metaName)
                self.__manifest.set(metaName, value)
            # title = formData.get("title")
            # self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
            self.__saveManifest()
        if func == "rename":
            title = formData.get("title")
            self.__manifest.set("%s/title" % nodePath, title)
            self.__saveManifest()
        elif func == "move":
            refNodeId = formData.get("refNodeId")
            refNodePath = self.__getNodePath(formData.get("refParents"), formData.get("refNodeId"))
            moveType = formData.get("type")
            if moveType == "before":
                self.__manifest.moveBefore(originalPath, refNodePath)
            elif moveType == "after":
                self.__manifest.moveAfter(originalPath, refNodePath)
            elif moveType == "inside":
                self.__manifest.move(originalPath, nodePath)
            self.__saveManifest()
        elif func == "update":
            title = StringEscapeUtils.escapeHtml(formData.get("title"))
            hidden = formData.get("hidden")
            hidden = hidden == "true"
            self.__manifest.set("%s/title" % nodePath, title)
            self.__manifest.set("%s/hidden" % nodePath, str(hidden))
            # if self.__manifest.get("%s/id" % nodePath) is None:
            #    print "blank node!"
            self.__saveManifest()
            result = '{ title: "%s", hidden: "%s" }' % (title, hidden)
        elif func == "delete":
            title = self.__manifest.get("%s/title" % nodePath)
            if title:
                self.__manifest.removePath(nodePath)
                self.__saveManifest()
            else:
                title = "Untitled"
            result = '{ title: "%s" }' % title

        self.__object.close()
        writer = response.getPrintWriter("text/plain; charset=UTF-8")
        writer.println(result)
        writer.close()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:67,代码来源:manifest.py


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