Giter Site home page Giter Site logo

more.transaction's Introduction

CI Status https://coveralls.io/repos/github/morepath/morepath/badge.svg?branch=master

Morepath: Python web microframework with super powers

Morepath is a Python web framework. An application consists of models. Each type of model is published on a URL path. Content is exposed to the web using views.

Documentation.

more.transaction's People

Contributors

faassen avatar henri-hulski avatar jugmac00 avatar sgaist avatar taschini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

more.transaction's Issues

Raises unicode error with transaction 2.0

When more.transaction is used with transaction 2.0 the following type error appears:

env/local/lib/python2.7/site-packages/more/transaction/main.py:64: in transaction_tween
    t.note(request.path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <transaction._transaction.Transaction object at 0x7f1651c780d0>, text = '/'

    def note(self, text):
        """ See ITransaction.
            """

        if not isinstance(text, text_type):
>           raise TypeError("Note must be text (unicode)")
E           TypeError: Note must be text (unicode)

env/local/lib/python2.7/site-packages/transaction/_transaction.py:537: TypeError

This happens because in Transaction 2.0.3

The user and description fields must now be set with text (unicode) data. Previously, if bytes were provided, they’d be decoded as ASCII.

userid not taken properly

The code has some XXX marked that it should get the userid somehow from the identity on the request. Currently this is not happening, so the info is not properly recorded in the transaction.

Fail with Morepath 0.15 and multiple attempts

Using multiple attempts (> 1) and Morepath 0.15 (unreleased) results in lots of 404s because the paths cannot be resolved correctly anymore.

This is du to the change of the unconsumed path order with Morepath 0.15:
morepath/morepath@e2c7c42

This conflicts with https://github.com/morepath/more.transaction/blob/fe275f0/more/transaction/main.py#L64

Ideally we make sure that there's some kind of public api for this in morepath, so we don't have to keep those implementations in lockstep.

reraise is complicated

There's complicated logic to implement a reraise functionality, different in Python 2 and 3. I am wondering why this is not simply implemented with raise (without arguments). Perhaps this has to do with some kind of traceback manipulation I don't quite understand.

Note also that the PY3 compat layer defines an exec_ function that doesn't appear to be used.

If we can get rid of the complexity that would be nice -- running exec and frame manipulation is pretty extreme.

Update supported Python versions

  • drop support for Python versions < 3.6
  • add support for Python versions 3.7, 3.8 (if missing)
  • fix linting errors (if present)

If you are a beginner, and need to help for this issue, especially during Hacktoberfest, please comment here or reach out to me via https://jugmac00.github.io/

When using more than one variable in the path, the retried request fails

If a path like /page/{type}/{id} is retried using more.transaction, the request is no longer correctly parsed and the wrong view is found. /page/{type} works fine.

The fix seems rather simple. We need to reset the request correctly when attempting a new request:

if attempts != 1:
    request.make_body_seekable()
    request.unconsumed = parse_path(request.path_info)

(note the request.unconsumed line)

I'll write a test and a bugfix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.