A collection of opinions, thoughts, tricks and misc. information.
Hello everybody. Like I was saying the other day, I got my first big site on the internet:
matchstd.com, a location where individuals who have tested positive for any number of different stds (or just one), can find other individuals with the same stds... It's a good site, and it looks great (I'm no designer, but I'll give myself a pat on the back).
I learned quite a few things putting this system up. My development computer has apache 2,
cherrypy 2.2beta and a plethora of other installed packages that make my life easier. The transition, however, to the main server (
python-hosting.com), made my life a little more difficult. Their service is great, but I had never moved a site that utilized so many features (I've stuck up PHP sites on various services, as well as some simple CGI and static pages), and was so complex. I'm just happy a solution out there existed for python hosting that already included most of what I needed (python 2.4, sqlobject, kid, etc.) Anyway, a few pointers:
- Never program for a specific OS (I knew this before, but it's a good tip anyway). Always make sure that your application uses all the cross-platform tools available, instead of depending on hard-coded paths and such
- Organize your pages in a neat fashion.
By placing pages in a huge mess throughout a large folder, you're going to eventually lose track of exactly where they are (or you'll depend on instinct for the path names)... Doing that will force you to re-organize on the server... Not good. I'll lay out a good organization model below...
- Keep track of your changes. Use a repository such as subversion or CVS. If you haven't used a repository before, go with subversion off the bat.
- Make sure you've either programmed a nice way to keep log information organized, or use a program from the internet. I'd recommend webalizer, a completely free system that you cron, which produces lovely graphs and statistical printouts. It's extremely useful.
I'll put more up later... Or maybe not, but I hope some of those work out for you. Now, to the organization I mentioned. I've found the following setup makes things very easy to create both a web site, and programs that utilize the site's hidden engine:
- AppRoot
- html
Use a templating system, and put all templates here. Your pages directory will include the code to display these.
- libraries
For every function that your web application needs to perform, it's a good idea to implement it here, in such a way that doesn't require the server. This lets you write simple non-web applications that can interact with your site. Although you won't need this at first, it's always good for later.
- models
Database definitions. Place all code to create your tables here.
- pages
Place all actual page logic display here... Basically, the code
that constructs each page.
- server.py
When I'm using CP, I like to put my server startup code here...
- server.conf
Also with CP, it's nice to have the configuration here.
Okay. If anybody wants some input, feel free to comment!
-James