Skip to main content

txwebutils - utilities for twisted.web

PyPI version Build Status GitHub license

What is txwebutils?

txwebutils is a pure-python library containing various utility functions and implementations for the twisted.web web framework. It is the result of combining useful code from my various other projects.

Features

  • support for unicode string results for twisted.web.resource.Resource.render_* methods.
  • support for deferreds results for twisted.web.resource.Resource.render_*.
  • utility functions to get the URL parameters in unicode.
  • A custom cross-site authentication implementation using twisted.cred.

Examples

# -*- coding: utf-8 -*-
"""
Example for @unicode_response.

The @unicode_response decorator allows both unicode and/or deferred results in render_* methods.
"""
from twisted.internet import defer
from twisted.web.resource import Resource
from txwebutils import unicode_response


class UnicodeRespondingResource(Resource):
    """
    This resource serves a unicode string on a GET request.

    @unicode_response tries its best to guess the encoding correctly.
    """
    @unicode_response
    def render_GET(self, request):
        return u"This is a unicode string: äöüß"

class BinaryRespondingResource(Resource):
    """
    This resource serves a binary string on a GET request.
    This shows that you can return whatever string type you desire.
    """
    @unicode_response
    def render_GET(self, request):
        return b"This is a binary string"

class DeferredResultingResource(Resource)
	"""
    This resource serves a deferred which fires with a unicode string on a GET request.
    """
    @unicode_response
    def render_GET(self, request):
        return defer.succeed(u"This is a unicode string: äöüß")

class InlineCallbacksResource(Resource)
	"""
    This resource uses 'twisted.internet.defer.inlineCallbacks'
    """
    @unicode_response
    @defer.inlineCallbacks
    def render_GET(self, request):
        s = yield defer.succeed(u"This is a unicode string: äöüß")
        defer.returnValue(s)

Metadata

Release files for txwebutils 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for txwebutils 0.0.1
File Size Uploaded Provenance
txwebutils-0.0.1.tar.gz 13.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for txwebutils 0.0.1
File Interpreter ABI Platform
txwebutils-0.0.1-py2-none-any.whl Python 2 none any Details

Total release size: 30.8 kB

Release files / txwebutils-0.0.1.tar.gz

Download URL txwebutils-0.0.1.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dc7502ee720cec2598506bb2efcc695927c5c8053175f07c7f3c85e625591996
BLAKE2b-256 checksum
How to use checksums
d0ef779c70e18471d92e84e1abcb1cf56145009d163911d54fb0395117422989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

Release files / txwebutils-0.0.1-py2-none-any.whl

Download URL txwebutils-0.0.1-py2-none-any.whl
Size 17.3 kB
Tags Python 2
SHA-256 checksum
How to use checksums
06bf813f7b2a8886d47ba126bfb2e55a262f7bcd454935052c3586e51eceae9b
BLAKE2b-256 checksum
How to use checksums
2cae5d4ca8a13fade3ca4baaadc098694a0f85595930f1c872c3705f168be489
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

Security for txwebutils 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page