Ejemplo n.º 1
0
 def _init_couch(self, app):
     from flask.ext.couchdb import CouchDBManager
     couch = CouchDBManager(app,auto_sync=False)
     couch.add_document(self.user)
     for doc in self.documents:
         couch.add_document(doc)
     self.couch = couch
Ejemplo n.º 2
0
 def __init__(self, app):
     manager = CouchDBManager()
     # ...add document types and view definitions...
     manager.setup(app)
     server = Server()
     self.db = server['active_server_cp']
Ejemplo n.º 3
0
from flask.ext.couchdb import CouchDBManager, Document, TextField, IntegerField, DateTimeField, ViewField, Row, ViewDefinition

from flask import g
from werkzeug import LocalProxy
couch = LocalProxy(lambda: g.couch)

import datetime
import os

from app import app # omg cyclical imports!!

# Setup database here, so we have access to the manager object
app.config['COUCHDB_DATABASE'] = "bluepad"
app.config['COUCHDB_SERVER'] = os.getenv('CLOUDANT_URL', "http://localhost:5984/")
couch_manager = CouchDBManager()
couch_manager.setup(app)

# used for password encryption
from flaskext.bcrypt import Bcrypt
bcrypt = Bcrypt(app)

# User, but we'll be polite and call them writers :)
class Writer(Document):
    doc_type = "writer"
    name = TextField() # username/pen-name; not full name
    email = TextField() # optional
    password = TextField()
    @classmethod
    def new(cls, name=None):
        if name is None: name = haiku()
        # create a writer object and return it!
Ejemplo n.º 4
0
COUCHDB_DATABASE = 'flask-photolog'

# application

app = Flask(__name__)
app.config.from_object(__name__)
app.config.from_envvar('PHOTOLOG_SETTINGS', silent=True)

# uploads

uploaded_photos = UploadSet('photos', IMAGES)
configure_uploads(app, uploaded_photos)

# documents

manager = CouchDBManager()


def unique_id():
    return hex(uuid.uuid4().time)[2:-1]


class Post(Document):
    doc_type = 'post'
    title = TextField()
    filename = TextField()
    caption = TextField()
    published = DateTimeField(default=datetime.datetime.utcnow)

    @property
    def imgsrc(self):
Ejemplo n.º 5
0
This contains the data models for 0x10challenges. Some of these exist only
in code, others are stored in a CouchDB database.

:copyright: (C) 2013 Matthew Frazier
:license:   MIT/X11 -- see the LICENSE file for details
"""
import datetime
from abc import ABCMeta, abstractmethod
from flask.ext.couchdb import (CouchDBManager, Document, Mapping,
                               TextField, IntegerField, BooleanField,
                               DecimalField, DateTimeField,
                               DictField, ListField, ViewField)
from flask.ext.login import UserMixin


manager = CouchDBManager(auto_sync=False)


class Challenge(object):
    """
    This is the base class that each challenge inherits from.
    """
    __metaclass__ = ABCMeta

    #: The ID of this challenge. This should be unique, and is used to
    #: look up the challenge from the URL etc.
    id = None

    #: The version of this challenge. This is a 2-tuple: the first item
    #: is the "spec version," which indicates whether code can be reused.
    #: The second item is the "results version," which indicates whether the
Ejemplo n.º 6
0
from flask import Flask, g
from flask.ext.couchdb import CouchDBManager
from werkzeug.local import LocalProxy

app = Flask(__name__)
app.config["COUCHDB_SERVER"] = "http://localhost:5984"
app.config["COUCHDB_DATABASE"] = "fridgio"
manager = CouchDBManager()
manager.setup(app)

couch = LocalProxy(lambda: g.couch)

from fridgio import views
Ejemplo n.º 7
0
import json

from flask import Flask, render_template, g, request, redirect, url_for, flash
from flask.ext.login import LoginManager, login_required, current_user, login_user, logout_user
from flask.ext.couchdb import CouchDBManager
from flask.ext import restful

import forms
import clojure_format
import couchdb_views
# import rest
from models import User
app = Flask(__name__)
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
# fetch the database from the default url and port
couch = CouchDBManager()
loginManager = LoginManager()
api = restful.Api(app)

# api.add_resource(rest.Template, '/ajax/templates')
# api.add_resource(rest.Block, '/ajax/block', '/ajax/block/<string:block_id>')
# api.add_resource(rest.Connection, '/ajax/connection')

@app.route('/ajax/templates')
def templates():
	return json.dumps([row.value for row in couchdb_views.templates_docs(g.couch)])


@app.route('/ajax/block/new')
def block_new():
	username, project_name = get_user_project()