view src/ltpdarepo/query.py @ 10:ec561d030fc2

Add html class to HTTP error pages message.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 15 Jun 2011 17:49:27 +0200
parents ceb5df800c51
children d45fa969ebf9
line wrap: on
line source

from flask import g

from ltpdarepo.form import Form
from wtforms.fields import TextField, HiddenField


class IQuery(Form):
    querystring = HiddenField()
    name = TextField("Name")


class Query(dict):
    def __init__(self, name=None, db=None, querystring=None):
        super(Query, self).__init__(name=name, db=db, querystring=querystring)
        self.__dict__ = self

    def create(self):
        curs = g.db.cursor()
        curs.execute("""INSERT INTO queries (name, db, querystring)
                        VALUES (%(name)s, %(db)s, %(querystring)s)""", dict(self))