Thursday, April 15, 2010

Installation

Too many pieces to put together here. The following components of the installation are available as Windows installers; just download and install them in the order listed before continuing with the rest:

Installing Trac

Installing mod_wsgi

Download mod_wsgi-win32-ap22py26-3.0.so to a temporary directory. Rename the file to mod_wsgi.so and copy it to the modules subdirectory of your Apache installation (usually C:\Program Files\Apache Software Foundation\Apache2.2\modules).

Locate httpd.conf under the conf subdirectory of the Apache installation (usually C:\Program Files\Apache Software Foundation\Apache2.2\conf) and open it in a text editor. Find the lines starting with LoadModule and insert the following line there:

LoadModule wsgi_module modules/mod_wsgi.so

Creating a Trac Site

Creating a Trac instance/site:

Run the following command from the command prompt:

trac-admin path-to-desired-location initenv

Note that you may have to specify the full path to trac-admin as shown here:

c:\python26\scripts\trac-admin path-to-desired-location initenv

You will be prompted for the following:

Project Name

Database connection string

Repository type

Path to repository

For the database connection string, use the following format:

postgres://user:pass@localhost:5432/dbname?schema=schemaname

If you are following the strings from the screenshots, the corresponding connection string would be:

postgres://testtrac:password@localhost:5432/testtrac?schema=testtrac

This will create your Trac site. You can do a trial run by saying:

tracd --port 8000 trac-site-location

...and then visiting http://localhost:8000/ using your web-browser.

Configuring mod_wsgi for the site

Run the following command at the command prompt. Replace "temporary-directory" with the name of a temporary folder where the required scripts for your Trac site will be generated.

trac-admin trac-site-location deploy temporary-directory

This command will create two folders within "temporary-directory" -- cgi-bin and htdocs. You will find the properly configured WSGI script for your site in temporary-directory\cgi-bin\trac.wsgi. Open the trac.wsgi in a text editor, prefix all path strings using the back-slash ('\') with the letter 'r'. For example, if you find this:

environ.setdefault('trac.env_path', 'C:\MyProject\Trac\ExampleSite')

...prefix the path string with the letter 'r' like this:

environ.setdefault('trac.env_path', r'C:\MyProject\Trac\ExampleSite')

I am assuming this to be a bug with how Trac works on Windows paths. Read about Python's raw strings to find out more about this.
Create a folder called apache within your Trac site and copy the generated trac.wsgi there.
Open httpd.conf, scroll to the bottom and add the following there:

Wednesday, February 17, 2010

This comes as a surprise. I have a C++ project in which the code has been split across several folders. I have two .CPP files of the same name (utility.cpp) in two different folders. The content in the files is not the same. Different symbols defined in each. Sounds like this should work without a hitch, right?

I'm not yet sure of this but it looks like there is no straightforward way to do this in VS2008. Both files are compiled to the same output folder. It looks like the compiler (cl.exe) compiles both .CPP files to the same .OBJ file. So, the last compiled .CPP wins. By the time the linker (linker.exe) reaches the scene, only the symbols defined in the last compiled .CPP are available and the linker fails giving you "LNK2028: unresolved token".

I looked at VS2008 options to see if there was a way to include the relative path of the source file as part of the compiler's output file path, but so far I have not been successful.