WebFaction
Community site: login faq
0
1

Hi,

I am slowly working my way through this tutorial.

I am stuck at this point:

Create the virtualenv and git clone your project the project. To isolate the Python we tell the virtualenv not to inherit from system Python, and we tell it to use distribute.

I don't have a project on Github to clone!

I have a Github account, and I am pretty comfortable with cloning/pushing and pulling (to and from my laptop to Githup repo)/forking, but I have no clue on how to work with Github/Virutalenv/Webfaction...

In other words, what exactly is the workflow for pushing/pulling to and from local machine to Github to my Webfaction account?

The way I was taught to use Django was to work directly on a test server, and then copy/paste code to a production machine; unfortunately, working local machine is new to me.

So, I guess my question is this:

What is the workflow for using virtualenv(wrapper)/Django/Github/Webfaction? Do you know of any good books and tutorials that would guide me through this process?

Any tips? Links? Book suggestions?

I really want to learn a workflow, but I am having a hard time finding info on the net that relates to my particular setup on Webfaction (Django 1.4/Python 2.7/mod_wsgi/nginx).

Thanks for listening!

Cheers, Micky

asked 04 Sep '11, 22:55

mhulse
411617
accept rate: 0%


This is my personal opinion, you will find as you read about solutions with this people have a lot of different opinions, it is completely up to you and what your comfortable doing and maintaining.

I am not sure if you fully understand what each piece of the puzzle does, I know once I fully understood what virtualenv did it helped me chose how I deal with this better.

First lets cover Git and your site. Git is a version management system. It is used to keep versions of your site as you code and make changes so you can review the progress, and if need be reverse changes.

The most basic function of this is for code development only, i.e. You are coding on your local machine, and check in the code every say 30 minnutes or whenever and you only use it to view code changes. You would than 'Deploy' or copy the code you want live manually using SSH or whatever.

Git also has 'post-commit' hooks that can set commands to run after a commit has been made.

I will cover some more complex examples in a moment but lets fist cover virtualenv real quick,

Virtualenv basically does 2 things(it may do more, but as far as I have ever needed to care it does 2). 1. It builds its own python binaries and puts them in ./bin (./ is the current working path) which I have never found important beyond troubleshooting scripts I later wrote for it. 2. It sets the python sys.path to itself, adding to the already defined paths. This is critical in maintaining paths between 2 apps. Let me illustrate the issue,

Python has paths defined it looks for modules in (sys.path),

/usr/python
/home/you/lib/python2.x
...

Now say you have 2 applications, app1 and app2,

/home/you/webapps/app1
/home/you/webapps/app2

Now lets say that both apps have a django 'app'(the things you define in settings.py) and that app has the same name for some reason, lets say 'django-voting' and that this app needs customization that differs between these 2 apps. In this case you could use virtualenv to isolate the 2 libraries from each-other. Explaining beyond this would best be done by the official docs,

http://pypi.python.org/pypi/virtualenv

Next we have the Django/Mod_wsgi stack.

Django is a dynamic application. And changes to its models and sometimes other code requires changes to the database, the application south is typically used to manage this. There are other caveats that you must be aware of when using Django compared to other frameworks, and this should all be something you are fully aware of before you set about automating Git for deployment.

This is how I deal with the issue in a nutshell,

I code locally and I commit to a the development repo for version changes whenever I feel is right.

When it is ready for deployment I deploy the live code to the site and make sure everything works.

I deploy manually and maintain everything on the server manually because personally I have never found any automation that works for how I code and maintain the code.

Many people use git's post-commit hooks to send the data to particular directories on the server and that is just fine, just not for me. If you do this keep in mind the dynamic part of django and the fact it needs apache restarted and may need syncdb or south ran to fix the db.

Lastly some people use Fabric to write very complex scripts that does everything for them, that is also fine but you should not begin to worry about that unless you know how Git/Virtualenv/Django work enogh to automate the whole process.

permanent link

answered 04 Sep '11, 23:44

johns
5.4k312
accept rate: 23%

edited 04 Sep '11, 23:46

WOW! Thanks you so much for the very informative reply!!!! You really helped clear things up for me! Just out of curiosity, how do you handle the syncing of your production's settings.py file? I am trying to understand how one would keep passwords, secret keys and email addresses private when uploading to a public repo? (P.S., I would upvote your answer but I don't have enough rep points to do so.) Thank you so much Johns! I greatly appreciate the pro advice and help! :)

(05 Sep '11, 01:07) mhulse

You're welcome. You can define certain files to exclude with most repos, you would just exclude settings.py and local_settings.py. I also do not use GitHub for my personal projects, but have a private git repo here.

(05 Sep '11, 01:13) johns

Awesome! Thanks you for all of your help! I really appreciate it. :)

(05 Sep '11, 14:56) mhulse
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×55
×13
×7
×6

question asked: 04 Sep '11, 22:55

question was seen: 3,674 times

last updated: 05 Sep '11, 14:56

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM