beaker

Difference between database and sqla backends in Beaker?

南笙酒味 提交于 2019-12-08 21:57:32
问题 It looks like Beaker supports two database backends, ext:database and ext:sqla, but what is the difference between them? 回答1: Overview Looking at the source code (Beaker-1.6.4-py2.7.egg), the backend initialization is different and the database schema are slightly different. The key difference seems to be whether you want to use a preexisting SQLAlchemy connection (ext:sqla) or create a brand new connection (ext:database). Additionally, ext:database can wholly be configured within ini

What's wrong with my Beaker, WSGI, Apache2, Python?

时光怂恿深爱的人放手 提交于 2019-12-06 08:45:50
Okay so my code is below. I'm working with apache2, mod_wsgi, beaker, python def application(environ, start_response): session = environ['beaker.session'] if not session.has_key('value'): session['value'] = 0 session.save() try: s = session['value'] except: s = "value not found" start_response('200 OK', [('Content-type', 'text/html')]) #response = "<br />".join(environ) beaker = "<br />".join(session) try: cookie = "".join(environ['HTTP_COOKIE']) except: cookie = "" return [cookie,'<br />', str(s), '<br />', beaker, '<br /> accessed:', str(session['_accessed_time']), '<br /> creation:', str

Pyramid with memcached: how to make it work? Error - MissingCacheParameter: url is required

梦想与她 提交于 2019-12-06 03:02:45
I have site on Pyramid framework and want to cache with memcached. For testing reasons I've used memory type caching and everything was OK. I'm using pyramid_beaker package. Here is my previous code (working version). In .ini file cache.regions = day, hour, minute, second cache.type = memory cache.second.expire = 1 cache.minute.expire = 60 cache.hour.expire = 3600 cache.day.expire = 86400 In views.py: from beaker.cache import cache_region @cache_region('hour') def get_popular_users(): #some code to work with db return some_dict The only .ini settings I've found in docs were about working with

How do I access session data in Jinja2 templates (Bottle framework on app engine)?

眉间皱痕 提交于 2019-12-03 08:14:50
I'm running the micro framework Bottle on Google App Engine. I'm using Jinja2 for my templates. And I'm using Beaker to handle the sessions. I'm still a pretty big Python newbie and am pretty stoked I got this far :) My question is how do I access the session data within the templates? I can get the session data no problem within the actual python code. And I could pass the session data each time I call a jinja template. But since I need the session data in the main menu bar of the site... that means I would have to pass it on every single page. Does anyone know if I can access it directly in

Undefined local variable or Method - Testing Puppet Modules using Beaker

风流意气都作罢 提交于 2019-12-02 04:01:39
I'm quite new to all of this. I am trying to test out a puppet module using Beaker. I keep getting this: NoMethodError: undefined method `describe' for #Beaker::TestCase:0x007fd6f95e6460 /Users/user1/beaker/Puppet/puppet-files/spec/classes/unit_spec.rb:3 /Users/user1/.rvm/gems/ruby-2.2.7/gems/beaker-3.24.0/bin/beaker:9 /Users/user1/.rvm/gems/ruby-2.2.7/bin/ruby_executable_hooks:15 /Users/user1/.rvm/gems/ruby-2.2.7/bin/ruby_executable_hooks:15. This is the command that I'm running - "beaker --hosts myhost.yaml --pre-suite spec". My unit_spec.rb contains this: require 'puppetlabs_spec_helper

Bottle.py session with Beaker

杀马特。学长 韩版系。学妹 提交于 2019-11-30 11:41:39
问题 first time questioner here. I'm currently struggling on how to use Beaker properly using the Bottle micro-framework. Here's the problematic program: #!/usr/bin/python # -*- coding: utf-8 -*- # filename: server.py import bottle as app from beaker.middleware import SessionMiddleware session_options = { 'session.type': 'file', 'session.data_dir': './session/', 'session.auto': True, } app_middlware = SessionMiddleware(app.app(), session_options) app_session = app.request.environ.get('beaker