Mikhail Korobov avatar Mikhail Korobov committed 94d1b53

django 1.4 example

Comments (0)

Files changed (2)

docs/customization.rst

 
 fabfile.py::
 
-    from fab_deploy import *
+    from fab_deploy.utils import define_host
 
     # Common layout options.
     # They are separated in this example in order to stay DRY.
         PIP_REQUIREMENTS_PATH = '',
     )
 
+    @define_host('user@staging.example.com', COMMON_OPTIONS)
     def staging():
-        env.hosts = ['user@staging.example.com']
-        env.conf = COMMON_OPTIONS.copy()
-        env.conf.update(
+        return dict(
             REMOTE_CONFIG_TEMPLATE = 'stage_settings.py',
             CONFIG_TEMPLATES_PATHS = ['hosting/staging', 'hosting'],
         )
-        update_env()
 
+    @define_host('user@example.com', COMMON_OPTIONS)
     def production():
-        env.hosts = ['user@example.com']
-        env.conf = COMMON_OPTIONS.copy()
-        env.conf.update(
+        return dict(
             REMOTE_CONFIG_TEMPLATE = 'prod_settings.py',
             CONFIG_TEMPLATES_PATHS = ['hosting/production', 'hosting'],
         )
-        update_env()
 
+
+Example 2: django 1.4 layout
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Django 1.4 presents a new project layout. It can be used e.g. this way::
+
+    my_project
+        my_project
+            config_templates
+                ...
+            reqs
+                ...
+            ...
+            config.py
+            config.server.py
+            settings.py
+
+        fabfile.py
+        manage.py
+        ...
+
+fabfile.py::
+
+    from fab_deploy.utils import define_host
+
+    @define_host('user@example.com')
+    def staging():
+        return dict(
+            CONFIG_TEMPLATES_PATHS=['my_project/config_templates'],
+            LOCAL_CONFIG = 'my_project/config.py',
+            REMOTE_CONFIG_TEMPLATE = 'my_project/config.server.py',
+            PIP_REQUIREMENTS_PATH = 'my_project/reqs/',
+        )

fab_deploy/django_commands.py

 
 @utils.inside_project
 def manage(command):
-    """ Runs django management command.
-    Example::
+    """
+    Runs django management command. Example::
 
         fab manage:createsuperuser
+
     """
     command_name = command.split()[0]
     if not command_is_available(command_name):
 
 @utils.inside_project
 def test(what=''):
-    """ Runs 'runtests.sh' script from project root.
+    """
+    Runs 'runtests.sh' script from project root.
     Example runtests.sh content::
 
         #!/bin/sh
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.