扭网实用程序

txwebutils的Python项目详细描述


txwebutils-用于twisted.web的实用程序

PyPI versionBuild StatusGitHub license

什么是txwebutils?在

txwebutils是一个纯python库,包含twisted.webweb框架的各种实用函数和实现。它是将我的其他项目中的有用代码组合在一起的结果。在

特点

  • twisted.web.resource.Resource.render_*方法的unicode字符串结果的支持。在
  • 支持twisted.web.resource.Resource.render_*的延迟结果。在
  • 获取unicode格式的URL参数的实用程序函数。在
  • 使用twisted.cred的自定义跨站点身份验证实现。在

示例

# -*- coding: utf-8 -*-"""Example for @unicode_response.The @unicode_response decorator allows both unicode and/or deferred results in render_* methods."""fromtwisted.internetimportdeferfromtwisted.web.resourceimportResourcefromtxwebutilsimportunicode_responseclassUnicodeRespondingResource(Resource):"""    This resource serves a unicode string on a GET request.    @unicode_response tries its best to guess the encoding correctly.    """@unicode_responsedefrender_GET(self,request):returnu"This is a unicode string: äöüß"classBinaryRespondingResource(Resource):"""    This resource serves a binary string on a GET request.    This shows that you can return whatever string type you desire.    """@unicode_responsedefrender_GET(self,request):returnb"This is a binary string"classDeferredResultingResource(Resource)"""    This resource serves a deferred which fires with a unicode string on a GET request.    """@unicode_responsedefrender_GET(self,request):returndefer.succeed(u"This is a unicode string: äöüß")classInlineCallbacksResource(Resource)"""    This resource uses 'twisted.internet.defer.inlineCallbacks'    """@unicode_response@defer.inlineCallbacksdefrender_GET(self,request):s=yielddefer.succeed(u"This is a unicode string: äöüß")defer.returnValue(s)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JPARepository save:在插入约束冲突后继续保存   java将一行字符串拆分为多行   java可以让任何计算机(多核或单核)同时运行多个线程   java mr nom无法执行   如何使用Java在MySQL数据库中插入日期?   java LinkedList在创建加权图时不添加对象元素   java将字符串拆分为等长的子字符串   java鼠标单击坐标仅第一次出现,其他鼠标单击坐标始终相同   java Apache POI,处理WorkbookFactory。创建()异常以获得更好的用户体验   具有属性和复合id的java ManyToMany   java如何定义自定义注释以使用目标元素的子集?   java HttpClient 4.3更改的参数(查询)处理?   java在运行时动态添加实体类   java我们通过phpMyAdmin访问的mysql数据库的数据库URL是什么?   java中LeftToPCorner练习的Codibility MaxPath   java如何将json对象列表转换为包含每个对象中某些字段的pojo字符串列表?   Eclipse中的java编译器遵从性和问题   java不可解析日期:“null”(偏移量为0)安卓