Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Can't access bottle_pgsql plugin once mounted
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Emmanuel Quevillon  
View profile  
 More options Nov 9 2012, 6:15 am
From: Emmanuel Quevillon <hor...@gmail.com>
Date: Fri, 9 Nov 2012 03:15:40 -0800 (PST)
Local: Fri, Nov 9 2012 6:15 am
Subject: [newbie] Can't access bottle_pgsql plugin once mounted

Hi,

I'm new to bottle  and I'd like to create a small web app using bottle.
The idea is to create 2 files (index.py and lib.py) to match URL such as
host:8080/ and host:8080/lib

I found a way to do it, calling mount from index.py such as :

import bottle
fro, m lib import lib

index = bottle.Bottle()
index.mount(lib, '/lib')

This works well.
But Ilike to access postgresql db, so I use bottle_pgsql plugin to do it.

So I install the plugin into lib.py such as:

import bottle
import bottle_pgsql

lib = bottle.Bottle()
libcfg configdict.ConfigDict = ('demult.ini')
lib.config = libcfg
lib.TEMPLATE_PATH = [libcfg.get ('tmpl') ['library']]
pgsql = bottle_pgsql.Plugin ('dbname =' + libcfg.get ('db') ['dbnm'] +
                            'User =' + libcfg.get ('db') ['user'] +
                            'Password =' ​​+ libcfg.get ('db') ['pass'] +
                            'Host =' + libcfg.get ('db') ['host'] +
                            'Port =' + libcfg.get ('db') ['port'])
lib.install (pgsql)

then when I do

@lib.route('/', apply=[pgsql])
def home(db):
    .....

I get a 500 internal server error without any output from the dev server
console.

So 'm confused and what should I do? Should I remove 'apply' from the route
decorator and let the install call in place
or should I call only 'apply' in route decorator remove install call?
I've tried both and the result is the same.
However, when I call host:8080/ it work perfecly and display my index html
page where as host:8080/lib return 500 internal error

I hope my question is clear enough?

Thanks in advance.

Emmanuel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[newbie] Can't access bottle_pgsql plugin once mounted" by Marcel Hellkamp
Marcel Hellkamp  
View profile  
 More options Nov 9 2012, 8:16 am
From: Marcel Hellkamp <m...@gsites.de>
Date: Fri, 09 Nov 2012 14:16:00 +0100
Subject: Re: [bottlepy] [newbie] Can't access bottle_pgsql plugin once mounted
Am 09.11.2012 12:15, schrieb Emmanuel Quevillon:

You can skip the "apply=[pgsql]". By app.install()ing a plugin, it is
automatically applied to all routes of that application.

Try enabling debug mode via "bottle.debug(True)" to get meaningful errors.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Emmanuel Quevillon  
View profile  
 More options Nov 9 2012, 10:51 am
From: Emmanuel Quevillon <hor...@gmail.com>
Date: Fri, 9 Nov 2012 07:51:13 -0800 (PST)
Local: Fri, Nov 9 2012 10:51 am
Subject: Re: [bottlepy] [newbie] Can't access bottle_pgsql plugin once mounted

Hi Marcel,

Thanks for your quick answer.

I get rid of the apply=[pgsql] call.  The view is rendered as wanted. But
now, I can access the 'db' attribute to execute pgsql query to the database?

lib.install(pgsql)

@lib.route('/')
@bottle.mako_view('library/home')
def home():
    .....

If I change def home(): to def home(db): then I get the error from bottle :

NameError("global name 'db' is not defined",)

Where as in the documentation it is defined as follow :

app.install(plugin)

@app.route('/show/:<item>')
def show(item, db):
    db.execute('SELECT * from items where name="%s"', (item,))
    row = db.fetchone()
    if row:...

If I try like this

@lib.route('/:id')
@bottle.mako_view('library/home')
def home(id,db):
    print "OK home "
    print id

I get

TypeError('home() takes exactly 2 arguments (1 given)',)

I'm sorry but I'm really confused, getting my hairs out of my head :(

Thanks

Emmanuel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »