Example #1
0
import peewee

test_db = peewee.Database(peewee.SqliteAdapter(), 'test_pw.db')


class User(peewee.Model):
    username = peewee.CharField()
    active = peewee.BooleanField(default=False)

    class Meta:
        database = test_db


class Blog(peewee.Model):
    user = peewee.ForeignKeyField(User)
    name = peewee.CharField()

    class Meta:
        database = test_db


class Entry(peewee.Model):
    blog = peewee.ForeignKeyField(Blog)
    title = peewee.CharField()
    content = peewee.TextField(default='')
    pub_date = peewee.DateTimeField(null=True)

    class Meta:
        database = test_db

Example #2
0
#!/usr/bin/env python

import sys
import hashlib
import cyclone.web
import peewee
from twisted.python import log
from twisted.internet import defer, reactor

database = peewee.Database(peewee.SqliteAdapter(), 'BlueBell.db')


class Webuser(peewee.Model):
    id = peewee.PrimaryKeyField()
    username = peewee.CharField()
    salt = peewee.CharField()
    pwhash = peewee.CharField()

    class Meta:
        db_table = 'webusers'
        database = database


class BaseHandler(cyclone.web.RequestHandler):
    def get_current_user(self):
        return self.get_secure_cookie("user")


class MainHandler(BaseHandler):
    @cyclone.web.authenticated
    def get(self):
Example #3
0
#coding: utf-8

import peewee
from . import app

from members import *

database = peewee.Database(peewee.SqliteAdapter(), app.config['DATABASE_NAME'])


class BlogEntry(peewee.Model):
    title = peewee.CharField()
    eid = peewee.CharField()
    link = peewee.CharField()

    author_email = peewee.CharField()

    summary = peewee.TextField()
    tags = peewee.CharField()
    content = peewee.TextField()

    date = peewee.DateTimeField()
    updated = peewee.DateTimeField()

    class Meta:
        database = database

    @property
    def author(self):
        return Members().by_email(self.author_email)
Example #4
0
import peewee

from flask import Flask, request, session, g, redirect, url_for, \
        abort, render_template, flash
from functools import wraps
from hashlib import md5

# config
DATABASE = 'tweepee.db'
DEBUG = True
SECRET_KEY = 'hin6bab8ge25*r=x&+5$0kn=-#log$pt^#@vrqjld!^2ci@g*b'

app = Flask(__name__)
app.config.from_object(__name__)

database = peewee.Database(peewee.SqliteAdapter(), DATABASE)


# model definitions
class User(peewee.Model):
    username = peewee.CharField()
    password = peewee.CharField()
    email = peewee.CharField()
    join_date = peewee.DateTimeField()

    class Meta:
        database = database

    def following(self):
        return User.select().join(
            Relationship,