1. Bill Evans
  2. django-fab-deploy

Commits

Mikhail Korobov  committed 29e4782

before_restart callback for push command

  • Participants
  • Parent commits 4463e0f
  • Branches default

Comments (0)

Files changed (3)

File docs/CHANGES.rst

View file
 - ``verify_exists`` argument of ``fab_deploy.utils.upload_config_template``
   function was renamed to ``skip_unexistent``; it now also passes all extra
   kwargs directly to fabric's ``upload_template``.
-- ``fab_deploy.virtualenv.pip_setup_conf`` command for uploading pip.conf.
+- ``fab_deploy.virtualenv.pip_setup_conf`` command for uploading pip.conf
+  (thanks Vladimir Mihailenco);
+- ``fab_deploy.deploy.push`` no longer calls 'synccompress' management command;
+- ``fab_deploy.deploy.push`` accepts 'before_restart' keyword argument -
+  that's a callable that will be executed just before code reload.
 
 0.6 (2011-03-11)
 ----------------

File fab_deploy/deploy.py

View file
     apache.apache_setup()
     nginx.nginx_setup()
 
-def push(*args):
+def push(*args, **kwargs):
     ''' Run it instead of your VCS push command.
 
     Arguments:
         dj_cmd.syncdb()
     if 'migrate' in args:
         dj_cmd.migrate()
-    dj_cmd.compress()
+
+    # execute 'before_restart' callback
+    kwargs.get('before_restart', lambda: None)()
+
     if 'norestart' not in args:
         apache.touch()
     if 'test' not in args:

File fab_deploy_tests/tests/deploy.py

View file
         fab(deploy_project)
         self.assertResponse(url, 'foo')
 
+    def test_push_callback(self):
+        url = 'http://foo.example.com/instance/'
+
+        def before_restart():
+            before_restart.called = True
+        before_restart.called = False
+
+        def my_push(*args):
+            return push(*args, before_restart=before_restart)
+
+        fab(foo_site2)
+        fab(deploy_project)
+        fab(my_push)
+        self.assertTrue(before_restart.called)