Source

fabulator / src / fabulator / core / django.py

"""
    Class to manage your django project
"""

from fabric.api import sudo, run, cd
from fabric.contrib.files import sed

class Django(object):
    
    def __init__(self, conf, env):
        self.conf = conf
        self.env = env
        
    def configure(self):
        """configure your django project : deals withs settings.py"""
        with cd("%(dir)s" % self.conf):
            run("cp deploy/%s-settings.py %s/settings_local.py" % (self.env.type, self.conf.get('dir')))
            sed("%(dir)s/settings_local.py" % self.conf, "DOCUMENT_ROOT", "%(dir)s" % self.conf)
        
    def syncdb(self):
        """run syncdb"""
        conf = self.conf.copy()
        conf["bin_dir"] = self.env.virtualenv.conf.get("bin_dir")
        run("%(bin_dir)s/python %(dir)s/manage.py syncdb --noinput" % conf)
        
    def load_fixtures(self):
        """load from fixtures"""
        pass
    
    def dump_fixtures(self, app, format="yaml"):
        """dump a fixture"""
        pass
        
    def runserver(self, host="localhost", port=8080):
        """launches the development server"""
        conf = self.conf.copy()
        conf["bin_dir"] = self.env.virtualenv.conf.get("bin_dir")
        conf["host"] = host
        conf["port"] = port
        run("%(bin_dir)s/python %(dir)s/manage.py runserver %(host)s:%(port)d" % conf)