Giter VIP home page Giter VIP logo

pyramid_beaker's Introduction

Pylons

Build Status

Pylons is a rapid web application development framework.

Note

Pylons has merged with repoze.bfg, and is now in maintenance-only mode. It's highly recommended that new projects start with the new merged web framework, pyramid.

Install

Read the online Installation instructions.

If you want to install from source you can run the following command:

$ python setup.py install

This will display a message and download setuptools if the module is not already installed. It will then install Pylons and all its dependencies. You may need root privileges to install setuptools.

Testing

To test the source distribution run the following command:

$ python setup.py test

This will install additional dependencies needed for the tests. As above, you may need root privileges.

Documentation

Read the complete Pylons web framework documentation.

Definitive Guide to Pylons is a book about Pylons published by Apress, written by James Gardner, with free HTML rendering.

Generating documentation requires Sphinx:

$ easy_install Sphinx

Then to build the documentation use the commands:

$ cd pylons/docs/<lang>
$ make html

pyramid_beaker's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyramid_beaker's Issues

When caching to DB, errors occur trying re-add table to meta

I'm using beaker for my session cache, since my production environment will have multiple web servers. During development, under circumstances that cause beaker to re-initialize I get an error that beaker_cache table is already added to the meta. I'm worried that this will occur in production and I don't quite know what causes it. Has anyone else reported this problem?

test_includeme fails with current pyramid

Testing this package with current pyramid results in:

[   12s] ======================================================================
[   12s] FAIL: test_includeme (pyramid_beaker.tests.TestIncludeMe)
[   12s] ----------------------------------------------------------------------
[   12s] Traceback (most recent call last):
[   12s]   File "/home/abuild/rpmbuild/BUILD/pyramid_beaker-0.8/pyramid_beaker/tests.py", line 356, in test_includeme
[   12s]     "<class 'pyramid_beaker.PyramidBeakerSessionObject'>")
[   12s] AssertionError: "<cla[14 chars]aker.BeakerSessionFactoryConfig.<locals>.Pyram[19 chars]ct'>" != "<cla[14 chars]aker.PyramidBeakerSessionObject'>"
[   12s] - <class 'pyramid_beaker.BeakerSessionFactoryConfig.<locals>.PyramidBeakerSessionObject'>
[   12s] + <class 'pyramid_beaker.PyramidBeakerSessionObject'>
[   12s] 

Is that to be expected?

Re-using an already existing session

I want to use Beaker sessions with Pyramid, but I also want the environ['session'] object to be available for wsgi middleware that come before my Pyramid app. thus, I'd like to add a simple session factory that looks something like this:

def my_session_factory(request):
    return request.environ['beaker.session']

But also, wrap it under the SessionObject subclass that pyramid_beaker provides. Any idea about how to do this? I'd be willing to implement & test it in a fork and send a pull request, but I wanted to discuss it first.

New release on pypi

Could we get a new release at pypi? After spending a couple of hours trying to find out why pyramid_beaker wasn't working with py3 and then debugging it all the way down, it had already been patched 7 months ago here.

An updated release would allow the current version at pypi to be compatible with py3, possibly also integrating the two other open issues first.

A new CSRF token is generated each request

I have a problem where a new CSRF token is generated in every request when I call:

token = request.session.get_csrf_token()

When debugging I found that the get_csrf_token() method always calls self.new_csrf_token(). The csrft value should, of course, be persisted to the session, but looks like that does not happen.

I have confirmed, by looking at the cookies, that I am seeing the same session on multiple requests. But always with a new CSRF token.

The problem occurs only when I use "session.type = file". The "cookie" session type works as expected.

If anyone has this working correctly, please drop a line. I am very confused, I was unable to pinpoint the problem. Here are the package versions I am using, on Python 2.7:

Beaker==1.6.4
pyramid==1.5.1
pyramid_beaker.git@9c73d0ae54fb857f5fae1454584ab95d1c3e2839#egg=pyramid_beaker-master

Broken functionality with Pyramid 1.4

After updating to Pyramid 1.4, pyramid_beaker no longer works with my app. My beaker factory has been configured with session.type = file, but nothing is being written to the data directory and no session cookies are ever set. It's just silently failing. Are you able to reproduce this?

beaker session encrypt_key and validate_key features break under python 3.3.3, pyramid 1.5.2

Platform I am using:

Mac Air, Yosemite 10.10.1
Python 3.3.3
Babel 1.3
Beaker 1.6.4
beautifulsoup4 4.3.2
Chameleon 2.19
Cython 0.21.2
lingua 3.7
Mako 1.0.0
MarkupSafe 0.23
oursql 0.9.4
passlib 1.6.2
PasteDeploy 1.5.2
pip 1.5.2
polib 1.0.6
pycrypto 2.6.1
Pygments 2.0.1
pymongo 2.7.2
pyramid 1.5.2
pyramid-beaker 0.8
pyramid-chameleon 0.3
pyramid-debugtoolbar 2.3
pyramid-mako 1.0.2
pyramid-tm 0.10
pytz 2014.10
repoze.lru 0.6
requests 2.5.1
setuptools 2.1
six 1.9.0
SQLAlchemy 0.9.8
SQLAlchemy-Utils 0.29.1
teacup 0.0
transaction 1.4.3
translationstring 1.3
venusian 1.0
waitress 0.8.9
WebOb 1.4
WebTest 2.0.17
zope.deprecation 4.1.1
zope.interface 4.1.2
zope.sqlalchemy 0.7.5

What is the issue?

Whenever I try to encrypt the session using the option encrypt_key and validate_key in beaker session, I get internal server error suggesting that there is an issue in byte-string conversion.


development.ini

#pyramid_beaker settings
session.type = file
session.data_dir = %(here)s/data/sessions/data
session.lock_dir = %(here)s/data/sessions/lock
session.key = SomeKey
session.secret = SomeSecret
session.domain = localhost
session.path = /

session.encrypt_key = Test123
session.validate_key = 124Tester

Error python traceback:

pydev debugger: process 73158 is connecting

Starting server in PID 73158.
serving on http://0.0.0.0:6543
2015-01-20 12:45:31,403 ERROR [waitress][Dummy-5] Exception when serving /
Traceback (most recent call last):
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/waitress-0.8.9-py3.3.egg/waitress/channel.py", line 337, in service
    task.service()
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/waitress-0.8.9-py3.3.egg/waitress/task.py", line 173, in service
    self.execute()
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/waitress-0.8.9-py3.3.egg/waitress/task.py", line 392, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/pyramid/router.py", line 242, in __call__
    response = self.invoke_subrequest(request, use_tweens=True)
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/pyramid/router.py", line 220, in invoke_subrequest
    request._process_response_callbacks(response)
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/pyramid/request.py", line 84, in _process_response_callbacks
    callback(self, response)
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/pyramid_beaker/__init__.py", line 30, in session_callback
    self.persist()
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/beaker/session.py", line 717, in persist
    self._session().save()
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/beaker/session.py", line 415, in save
    data = self._encrypt_data(data)
  File "/Users/Home/Programming/Python/3.x/pyramid_projs/env2/lib/python3.3/site-packages/beaker/session.py", line 262, in _encrypt_data
    self.validate_key + nonce, 1)
TypeError: Can't convert 'bytes' object to str implicitly

Error I receive on Front end:

Internal Server Error

The server encountered an unexpected internal server error

(generated by waitress)

Session written when only read causing parallel issues

I have an app that calls multiple requests in parallel. One of the requests simply reads the session in order to track information while the next request actually posts information to the session. Given that we have many servers these request might not execute in the right order. What can happen is the request that only reads the session can overwrite the seconds requests set with stale data if they execute together just the right way.

Making the requests serial is not ideal as it is pretty much a fire and forget type event from the front ends perspective.

My app already explicitly calls beaker's persist() method when session variables are written. This prevents some of these issues.

On line 30 in init.py there is self.persist() and the "if" that drives it uses self.accessed() which I think is being flipped if the session variable is read.

I've hacked my code to reproduce the issue consistently which was fairly intermittent normally. Commenting out the persist on line 30 makes the issue go away.

I notice a pretty explicit comment about beaker's "auto" configuration option in the call_save method. From my perspective I need to control the sessions write explicitly. I'd like to somehow have this extension honor the auto option of beaker although I see this as probably breaking backwards compatibility of this plugin.

I'm happy to put together a pull request if you'd let me know how you'd prefer this be implemented. If you'd rather it not get implemented I'll just fork in some fashion.

I'm thinking that in call_save we could keep track of a dirty variable. Only if one of the dictionary modifying functions has been called do we call persist on line 30. call_save() will set a variables say session._pyramid_session_dirty = True given that _dirty might have a name conflict.

I tried changing self.accessed to self.dirty, but that didn't seem to fix it. Looking at beaker code that doesn't seem reliable anyways. I couldn't find a way to see if the session had actually been modified vs just read in beaker. Accessed seems to only be if it got loaded up.

Thanks!

TypeError at get_csrf_token

Wanted to investigate the csrf protection feature. Tried simple

print (request.session.get_csrf_token())

Result was

2013-07-07 21:06:26,950 ERROR [waitress][Dummy-2] Exception when serving /api/wikis
Traceback (most recent call last):
  File "/usr/lib/python3.3/site-packages/waitress-0.8.5-py3.3.egg/waitress/channel.py", line 332, in service
    task.service()
  File "/usr/lib/python3.3/site-packages/waitress-0.8.5-py3.3.egg/waitress/task.py", line 174, in service
    self.execute()
  File "/usr/lib/python3.3/site-packages/waitress-0.8.5-py3.3.egg/waitress/task.py", line 382, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/usr/lib/python3.3/site-packages/pyramid/router.py", line 251, in __call__
    response = self.invoke_subrequest(request, use_tweens=True)
  File "/usr/lib/python3.3/site-packages/pyramid/router.py", line 227, in invoke_subrequest
    response = handle_request(request)
  File "/usr/lib/python3.3/site-packages/pyramid_debugtoolbar-1.0.6-py3.3.egg/pyramid_debugtoolbar/toolbar.py", line 130, in toolbar_tween
    return handler(request)
  File "/usr/lib/python3.3/site-packages/pyramid/tweens.py", line 21, in excview_tween
    response = handler(request)
  File "/usr/lib/python3.3/site-packages/pyramid_tm-0.7-py3.3.egg/pyramid_tm/__init__.py", line 82, in tm_tween
    reraise(*exc_info)
  File "/usr/lib/python3.3/site-packages/pyramid_tm-0.7-py3.3.egg/pyramid_tm/compat.py", line 13, in reraise
    raise value
  File "/usr/lib/python3.3/site-packages/pyramid_tm-0.7-py3.3.egg/pyramid_tm/__init__.py", line 63, in tm_tween
    response = handler(request)
  File "/usr/lib/python3.3/site-packages/pyramid/router.py", line 161, in handle_request
    response = view_callable(context, request)
  File "/usr/lib/python3.3/site-packages/pyramid/config/views.py", line 586, in __call__
    return view(context, request)
  File "/usr/lib/python3.3/site-packages/pyramid/config/views.py", line 319, in attr_view
    return view(context, request)
  File "/usr/lib/python3.3/site-packages/pyramid/config/views.py", line 295, in predicate_wrapper
    return view(context, request)
  File "/usr/lib/python3.3/site-packages/pyramid/config/views.py", line 345, in rendered_view
    result = view(context, request)
  File "/usr/lib/python3.3/site-packages/pyramid/config/views.py", line 491, in _requestonly_view
    response = view(request)
  File "/home/me/myapp/myapp/views.py", line 23, in listItems
    print (request.session.get_csrf_token())
  File "/usr/lib/python3.3/site-packages/pyramid_beaker-0.7-py3.3.egg/pyramid_beaker/__init__.py", line 88, in get_csrf_token
    token = self.get('_csrft_', None)
  File "/usr/lib/python3.3/site-packages/beaker/session.py", line 554, in __getattr__
    return getattr(self._session(), attr)
  File "/usr/lib/python3.3/site-packages/beaker/session.py", line 550, in _session
    **params)
  File "/usr/lib/python3.3/site-packages/beaker/session.py", line 112, in __init__
    self._create_id()
  File "/usr/lib/python3.3/site-packages/beaker/session.py", line 126, in _create_id
    getpid())).hexdigest(),
TypeError: Unicode-objects must be encoded before hashing

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.