forked from mangoplum/mappy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mangoplum
committed
Apr 16, 2012
0 parents
commit 84b6d8b
Showing
23 changed files
with
7,801 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
instance/ | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from flaskext.script import Manager | ||
|
||
from mappy import app, db | ||
|
||
manager = Manager(app) | ||
|
||
@manager.command | ||
def clear(): | ||
"""Clear the database.""" | ||
print "%i documents in collection" % db['features'].count() | ||
db['features'].remove() | ||
print 'database cleared.' | ||
print "%i documents in collection" % db['features'].count() | ||
|
||
if __name__ == "__main__": | ||
manager.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
def _init_app(): | ||
from flask import Flask | ||
|
||
from . import default_config | ||
|
||
app = Flask(__name__, instance_relative_config=True) | ||
|
||
app.config.from_object(default_config) | ||
app.config.from_envvar(app.name.upper() + '_SETTINGS', silent=True) | ||
app.config.from_pyfile('local_config.py', silent=True) | ||
|
||
return app | ||
|
||
def _init_db(): | ||
from mongokit import Connection | ||
from .models import models | ||
|
||
conn = Connection(app.config['MONGODB_HOST'], | ||
app.config['MONGODB_PORT']) | ||
|
||
db = conn[app.config['MONGODB_DBNAME']] | ||
|
||
if all(k in app.config for k in ("MONGODB_USERNAME", "MONGODB_PASSWORD")): | ||
db.authenticate(app.config['MONGODB_USERNAME'], app.config['MONGODB_PASSWORD']) | ||
|
||
db.connection.register(models) | ||
|
||
return db | ||
|
||
app = _init_app() | ||
db = _init_db() | ||
|
||
from . import views |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
|
||
DEBUG = True | ||
|
||
MOBILE = True | ||
|
||
SECRET_KEY = 'development key' | ||
|
||
PORT = int(os.environ.get('PORT', 5000)) | ||
HOST = os.environ.get('HOST', '0.0.0.0') | ||
|
||
MONGODB_HOST = os.environ.get('MONGODB_HOST', 'localhost') | ||
MONGODB_PORT = os.environ.get('MONGODB_PORT', 27017) | ||
MONGODB_DBNAME = os.environ.get('MONGODB_DBNAME') | ||
MONGODB_USERNAME = os.environ.get('MONGODB_USERNAME') | ||
MONGODB_PASSWORD = os.environ.get('MONGODB_PASSWORD') | ||
|
||
PUBNUB_PUB_KEY = 'demo' | ||
PUBNUB_SUB_KEY = 'demo' | ||
PUBNUB_CHANNELS = {'features': '4370beb4-3888-4208-a507-82e2e2d0883b'} | ||
|
||
TILES_URL = 'http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png' | ||
|
||
JSCONSOLE_KEY = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import datetime | ||
|
||
from mongokit import Document | ||
|
||
class Feature(Document): | ||
__collection__ = 'features' | ||
|
||
structure = { | ||
'title': unicode, | ||
'info': unicode, | ||
'urgency': int, | ||
'pos': (float, float), | ||
'date_creation': datetime.datetime, | ||
} | ||
|
||
default_values = { | ||
'urgency': 1, | ||
'title': u'no title', | ||
'info': u'no info', | ||
'date_creation': datetime.datetime.utcnow | ||
} | ||
|
||
required_fields = ['pos', 'date_creation'] | ||
|
||
models = [Feature] |
Oops, something went wrong.