Skip to content

Commit

Permalink
added MongoEngine models
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Oct 15, 2015
1 parent 5645de0 commit 88effa0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,4 +1,4 @@
https://github.com/mitsuhiko/flask/tarball/master
dataset
flask-mongoengine
nose
Flask-Bootstrap
11 changes: 2 additions & 9 deletions wtf/db.py
@@ -1,10 +1,3 @@
# coding: utf-8
from os import path
from flask import current_app
import dataset

def get_table(tablename):
database_name = current_app.config['DATABASE_NAME']
database_path = path.join(current_app.instance_path, database_name)
db = dataset.connect('sqlite:///{0}'.format(database_path))
return db[tablename]
from flask_mongoengine import MongoEngine
db = MongoEngine()
6 changes: 5 additions & 1 deletion wtf/development_instance/config.cfg
Expand Up @@ -3,4 +3,8 @@ RUN_USE_RELOADER = True
RUN_HOST='localhost'
RUN_PORT=5000
DATABASE_NAME = 'noticias.db'
MEDIA_FOLDER = 'media_files'
MEDIA_FOLDER = 'media_files'

MONGODB_DB = "noticias"
MONGODB_HOST = "localhost" # substitua se utilizar um server remoto
MONGODB_PORT = 27017
8 changes: 8 additions & 0 deletions wtf/models.py
@@ -0,0 +1,8 @@
# coding: utf-8
from .db import db


class Noticia(db.Document):
titulo = db.StringField()
texto = db.StringField()
imagem = db.StringField()

0 comments on commit 88effa0

Please sign in to comment.