Upgrading to mongodb 1.8. Adding user/pass to mongo, using item_frequencies with map_reduce (to avoid eval on the db).

This commit is contained in:
Samuel Clay 2011-03-19 16:19:53 -04:00
parent ffef62858b
commit fbfede640c
3 changed files with 25 additions and 9 deletions

View file

@ -503,7 +503,7 @@ class Feed(models.Model):
def save_popular_tags(self, feed_tags=None, verbose=False):
if not feed_tags:
all_tags = MStory.objects(story_feed_id=self.pk, story_tags__exists=True).item_frequencies('story_tags')
all_tags = MStory.objects(story_feed_id=self.pk, story_tags__exists=True).item_frequencies_mr('story_tags')
feed_tags = sorted([(k, v) for k, v in all_tags.items() if isinstance(v, float) and int(v) > 1],
key=itemgetter(1),

26
fabfile.py vendored
View file

@ -127,9 +127,9 @@ def setup_common():
setup_local_files()
setup_libxml()
setup_python()
setup_mongoengine()
setup_supervisor()
setup_hosts()
setup_mongoengine()
# ==================
# = Setup - Common =
@ -191,17 +191,29 @@ def setup_python():
sudo('su -c \'echo "import sys; sys.setdefaultencoding(\\\\"utf-8\\\\")" > /usr/lib/python2.6/sitecustomize.py\'')
put('config/pystartup.py', '.pystartup')
def setup_mongoengine():
with cd('~/code'):
run('git clone https://github.com/hmarr/mongoengine.git')
sudo('ln -s ~/code/mongoengine/mongoengine /usr/local/lib/python2.6/dist-packages/mongoengine')
def setup_supervisor():
sudo('apt-get -y install supervisor')
def setup_hosts():
put('config/hosts', '/etc/hosts', use_sudo=True)
def setup_mongoengine():
with cd('~/code'):
run('git clone https://github.com/hmarr/mongoengine.git')
sudo('ln -s ~/code/mongoengine/mongoengine /usr/local/lib/python2.6/dist-packages/mongoengine')
def setup_pymongo_repo():
with cd('~/code'):
run('git clone git://github.com/mongodb/mongo-python-driver.git pymongo')
with cd('~/code/pymongo'):
sudo('python setup.py install')
def setup_forked_mongoengine():
with cd('~/code/mongoengine'):
run('git remote add github http://github.com/samuelclay/mongoengine')
run('git pull github dev')
# ===============
# = Setup - App =
# ===============

View file

@ -370,4 +370,8 @@ DEBUG_TOOLBAR_CONFIG = {
# = Mongo =
# =========
MONGODB = connect(MONGO_DB['NAME'], host=MONGO_DB['HOST'], port=MONGO_DB['PORT'])
MONGODB = connect(MONGO_DB['NAME'],
host=MONGO_DB['HOST'],
port=MONGO_DB['PORT'],
username=MONGO_DB.get('USERNAME'),
password=MONGO_DB.get('PASSWORD'))