Thursday, March 20, 2008

I'd better to write a several of tutorial for basic of Python.

I think a good understand of Python is very important for learn, from now no I will write a several of step to step tutorial for how to use Python language.

Monday, March 17, 2008

Getting start with Django

I plan to develop our new project Sparrow by Django.Today,we'll do some basic configurations.
Create Project and Config data base.
1) create project
For one thing,of course,we need download the Django and setup it.I decide to grap the last version of Django,so I setup the Subverion client,and then check out the last Django trunk.
svn co djtrunk
And then put my djtrunk path to PYTHONPATH environment variables.
finally,we place our djtrunk/django/bin on our system path.because this directary includes management utilities such as

For now,everything is OK,we'll create our first application in Django environment.It's easy to create a project.Open your django project directory and just type following command. startproject sparrow
Note:sparrow is our project's name,you can change as everything you like.
After run this command,Django will create a sparrow directory.and this directory include four files:
  • A file required for Python treat the directory as a package (i.e., a group of modules)
  • A command-line utility that lets you interact with this Django project in various ways
  • Settings/configuration for this Django project
  • The URL declarations for this Django project; a “table of contents” of your Django-powered site
Now,you have your first Django application.let's test it.Navigate to the sparrow directory and run following command:
python runserver
you will see some log information,and the server is run on port 8000(default).Then open your browser and open folling url:"8000.You will see a congratulation page with some default legend.Django includes a built-in, lightweight Web server you can use while developing your site. We’ve included this server so you can develop your site rapidly, without having to deal with configuring your production Web server (e.g., Apache) until you’re ready for production.
2) Config data base for Django project.
As of now,Django support three type DataBase:
We plan to use the PostgreSQL.How to do that?
First of all,we'll download the PostgreSQL database engine and download the python postgresql package. Take note of whether you’re using version 1 or 2; you’ll need this information later.
Windows user can download from
Now,we'll config the database in Django.please open the file in sparrow directoary.
and find the section DATABASE_ENGINE,and change it like this;

DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'test2' # Or path to database file if using sqlite3.
DATABASE_USER = 'postgres' # Not used with sqlite3.
DATABASE_PASSWORD = '123456' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '5432' # Set to empty string for default. Not used with sqlite3.
Congratulation,we have our first Django application and config it with postgreSQL.It's cool.
In next chapter we'll discuss how to create a Domain model,it'll map to real database table.

Monday, March 10, 2008

How to add and remove apache server as a WinNT service

I plan to deploy my new application in appache server,but I don't want setup as default (for all users) configuration.I just want to this service only for me .so when I finished setup.I do following setup.
open the directory of apache installed.then type following command.
>>httpd -k install
then apache server be installed as a windows service.And we also can saw it in apache monitor,it's easily to maintain now.In the other hand ,if we need remove it from windows service.type following command
>>httpd -k uninstall.
and start apache with command
>>httpd -k start.
and stop apache with command
>>httpd -k stop.
and restart apache with command
>>httpd -k restart.