Monday, December 29, 2008

Plone deployment using buildout

Prerequisites
* python2.4
* python-devel
* python-imaging - Python Imaging Library
* python-setuptools - setuptools

Under Ubuntu use:
$ sudo apt-get install python2.4 build-essential python2.4-dev python-imaging python-setuptools

Under openSUSE use:
$ sudo zypper in python-2.4 python-2.4-devel python-2.4-imaging python-2.4-xml

If you're using Linux and your distribution doesn't provide a package for setuptools, download ez_setup.py and run it with:
$ python2.4 ez_setup.py

Note: I got error here saying that directory structure doesn't exists. In that case just create it with mkdir command and try again:
mkdir -p /usr/local/lib64/python2.4/site-packages

This will download and install setuptools and the easy_install script. Watch the console output to understand where easy_install is installed. If this is not in your system PATH, you should add this directory to the path as well by adding following to lines to the end of $HOME/.bash_profile for one user, /etc/profile for all users except root, and /root/.bash_profile for root user.
PATH=$PATH:/path/to/easy_install
export PATH

Installation
$ sudo easy_install-2.4 -U ZopeSkel
$ cd /home/'your_username'
$ paster create --list-templates
$ paster create -t plone3_buildout myPloneProject
-----------------------------------------------------------------------------------
Enter zope2_install (Path to Zope 2 installation; leave blank to fetch one) ['']:
Enter plone_products_install (Path to directory containing Plone products; leave blank to fetch one) ['']:
Enter zope_user (Zope root admin user) ['admin']:
Enter zope_password (Zope root admin password) ['']: passwd
Enter http_port (HTTP port) [8080]:
Enter debug_mode (Should debug mode be "on" or "off"?) ['off']: on
Enter verbose_security (Should verbose security be "on" or "off"?) ['off']: on
-----------------------------------------------------------------------------------

Enter directory with created template:
$ cd myPloneProject

Create base directory structure, including scripts and latest version of the zc.buildout egg, for created template:
$ python2.4 bootstrap.py

Next step is time-consuming so after typing next command go for coffee. If you have some download running in background, stop it before doing online build with:
$ ./bin/buildout -v

This reads the generated buildout.cfg file and executes its various "parts", setting up Zope, creating a Zope instance, downloading and installing Plone.

You will need to run ./bin/buildout again each time you change buildout.cfg. If you do not want buildout to go online and look for updated versions of eggs or download other archives, you can run it in non-updating, offline mode, with using -o switch:
$ ./bin/buildout -o

Start your Zope instance in foreground so you can see debug info in console:
$ ./bin/instance fg

Start your Zope instance as background process in daemon mode:
$ ./bin/instance start

To run test use:
$ ./bin/instance test -s plone.portlets

Stop your instance with:
$ ./bin/instance stop

Resource:
http://plone.org/documentation/tutorial/buildout/tutorial-all-pages

Wednesday, December 17, 2008

Subversion with apache on Centos

I used Centos4 as OS on which I installed subversion with apache. It was painful three days but it was sucess at the end. Before we start with this I have to say couple of important things:
subversion 1.4.x will work with apache-2.0.x cause they relay on APR 0.9.x module, and
subversion-1.5.x will work with apache-2.2.x cause they relay on APR 1.3.x module.
APR 0.9.x and APR 1.3.x are not compatibile, and because of that, subversion 1.5.x will not work with apache-2.0.x. Same case is probably with subversion 1.4.x and apache-2.2.x combination. When installing subversion modules for apache from source you'll need to tell to configuration where are APR and APR-UTIL libraries. You can use these libraries from apache source or from subversion. I decided to use APR and APR-UTIL libraries from apache source.

Subversion uses a lot of other programs and libraries which need to be installed before using the subversion package. So to simplify things I'll try using yum as much as possible.

Update your version of apache and install subversion that fits this version of apache using yum:
yum upgrade httpd

Add repos to yum:
joe /etc/yum.repos.d/dag.repo

[dag]
Name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
gpgcheck=1
enabled=1

Then install these packages:
yum install httpd-devel
yum install subversion

Check the version of your installed apache (2.0.52 in my case) using:
yum info httpd

and download apropriate source using:
wget http://apache.blic.net/httpd/httpd-2.0.63.tar.gz

There is no source for 2.0.52 any more so I used 2.0.63 with crossed fingers.
tar xfz httpd-2.0.63.tar.gz
cd httpd-2.0.63

cd apr
./configure --prefix=/usr/local/apr
make
make install
cd ..

cd apr-util
./configure --prefix=/usr/local/apr-utils --with-apr=/usr/local/apr/
make
make install
cd ..

Check the version of your installed subversion (1.4.6 in my case) using:
yum info subversion

and download apropriate source using:
wget http://subversion.tigris.org/downloads/subversion-deps-1.4.6.tar.gz
wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.gz

tar xfz subversion-1.4.6.tar.gz
tar xfz subversion-deps-1.4.6.tar.gz
cd subversion-1.4.6

rm -f /usr/local/lib/libsvn*
rm -f /usr/local/lib/libapr*
rm -f /usr/local/lib/libexpat*
rm -f /usr/local/lib/libneon*
sh ./autogen.sh

./configure --with-apxs=/usr/sbin/apxs \
--with-apr=/usr/local/apr/ \
--with-apr-util=/usr/local/apr-utils/
make
make install

At this point you will have included two svn modules in httpd.conf file which is why we did compiling from source.

Make your project for first revision of repository
mkdir -v /usr/local/svn-projects
mkdir -v /usr/local/svn-projects/htdocs
joe /usr/local/svn-projects/htdocs/index.html
chown -Rv apache.apache /usr/local/svn-projects

Make your repository
mkdir -v /usr/local/subversion/
/usr/local/bin/svnadmin create --fs-type fsfs /usr/local/subversion/repository
chown -Rv apache.apache /usr/local/subversion
ls /usr/local/subversion/repository

Edit httpd.conf.
Check that there are two loaded svn modules.
LoadModule dav_svn_module /usr/lib/httpd/modules/mod_dav_svn.so
LoadModule authz_svn_module /usr/lib/httpd/modules/mod_authz_svn.so

Add this code to apache httpd.conf:
< Location /subversion>
DAV svn
SVNPath /usr/local/subversion/repository/
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /usr/local/subversion/repository/conf/svn-auth-file
Require valid-user
</Location>

Add new users. For first user:
htpasswd -cmd /usr/local/subversion/repository/conf/svn-auth-file {user-name}

For every other user:
htpasswd -md /usr/local/subversion/repository/conf/svn-auth-file {user-name}

Prepare files for repository and import your project to repository:
mkdir -pv /tmp/subversion-layout/{branches,tags}
mv -v /usr/local/svn-projects/htdocs /tmp/subversion-layout/trunk
export SVN_EDITOR=joe
/usr/local/bin/svn import /tmp/subversion-layout/ http://127.0.0.1/subversion/

Make your working copy:
cd /usr/local/svn-projects/
/usr/local/bin/svn checkout http://127.0.0.1/subversion/trunk/ htdocs

Make post-commit hook to get fresh working copy:
cp -v /usr/local/subversion/repository/hooks/post-commit.tmpl /usr/local/subversion/repository/hooks/post-commit
chmod +x /usr/local/subversion/repository/hooks/post-commit

Edit post-commit hook by commenting two last lines and by adding one line like this:
#commit-email.pl "$REPOS" "$REV" commit-watchers@example.org
#log-commit.py --repository "$REPOS" --revision "$REV"
/usr/bin/svn update /usr/local/svn-projects/htdocs/ --username svn_user --password svn_pass --non-interactive >> /usr/local/subversion/repository/logs/post-commit.log

Make log file for created hook:
mkdir -v /usr/local/subversion/repository/logs/
touch /usr/local/subversion/repository/logs/post-commit.log
chown -Rv apache.apache /usr/local/subversion/ /usr/local/svn-projects/

Restart your apache and you'll have your first revision working:
/bin/sbin/httpd -k restart

Cheers!

Saturday, July 12, 2008

OpenGL - computer graphics assignment

Final semester is over and so is my computer graphics assignment. My idea was to make some simple models and play with light effects. So check board, desk lights and some pieces on board will be probably easy to model and nice to see. First I draw my scene idea on piece of paper. You can find it here. And code for final implementation of assignment can be found here. This is just the main unit. You need to create project first and add this code to newly created project. Creating project is described in one of my previous post OpenGL - installation.

I will describe here in short what I have used to create such scene. For lighting the lamps I have used spot lights and two side lighting material to get glowing effect of upper part of lamps. Pieces are made using vertex function and then assigning normals for light reflection. Lamps are made with spheres and cylinders. Upper part of lamps are unclosed cylinders with different size of base radius. First part of animation moves camera from the center of check board toward positive side of y axis. Second part of animation just rotates scene over one of axises. Zoom in/out effect was achieved with parameter theta of projection function. That's pretty much it.

You can interact with animation with these key's:
a - rotate left
d - rotate right
w - zoom in
d - zoom out
p - pause animation
l - turn on/off left desk light
r - turn on/off right desk light
m - turn on/off moving desk light
b - increase amount of light of moving desk light

Saturday, July 5, 2008

OpenGL - rotating cube


Rotating cube. This is my first animation in OpenGL. You can comment/uncomment setLightening(); function in init() function to disable/enable custom lighting. Code for this example can be found here.

Monday, June 23, 2008

OpenGL - installation in 10 easy steps

If you are using Dev-Cpp in order to play with OpenGL then here is one easy installation with glut, glu and openGL libraries.

Monday, June 9, 2008

Digital image processing without tears

I recently downloaded MatLab software package for student research of digital image processing. So here are results of my studying. If you are struggling with MatLab in order to achieve some goals in image processing area or you are studying this at college, maybe these exercises will help. More info about exercises can be found here.

Exercise1 - Introduction to MatLab
Exercise2 - Pixel value transformation
Exercise3 - Filtering in space area
Exercise4 - Filtering in frequency area
Exercise5 - Motion blur and Wiener's filter
Exercise6 - Shadow corection
Exercise7 - Edge detection
Exercise8 - Image segmentation, Isodata algorithm, Isodata2 algorithm
Exercise9 - Mathematical morfology, Conditional dilatation algoritam

Commands & terms

Practical Test 1 (example) - assignment
Practical Test 1 (example) - solution
Practical Test 1 (example) - Resource1
Practical Test 1 (example) - Resource2
Practical Test 1 (example) - Resource3

Practical Test 1 - assignment
Practical Test 1 - solution
Practical Test 1 - Resource1
Practical Test 1 - Resource2
Practical Test 1 - Resource3

Practical Test 1 (corrective) - assignment
Practical Test 1 (corrective) - solution
Practical Test 1 (corrective) - Resource1
Practical Test 1 (corrective) - Resource2
Practical Test 1 (corrective) - Resource3

Test1 - Question1
Test1 - Question2
Test1 - Question3
Test1 - Question4
Test1 - Question5
Test1 - Question6
Test1 - Question7
Test1 - Question8
Test1 - Question9
Test1 - Question10
Test1 - Question11
Test1 - Question12
Test1 - Question13
Test1 - Question14
Test1 - Question15
Test1 - Question16
Test1 - Question17
Test1 - Question18
Test1 - Question19
Test1 - Question20

Practical Test 2 (example) - assignment
Practical Test 2 (example) - solution
Practical Test 2 (example) - Resource1
Practical Test 2 (example) - Resource2
Practical Test 2 (example) - Resource3

Practical Test 2 - assignment
Practical Test 2 - solution
Practical Test 2 - Resource1
Practical Test 2 - Resource2
Practical Test 2 - Resource3

Test2 - Question1
Test2 - Question2
Test2 - Question3
Test2 - Question4
Test2 - Question5
Test2 - Question6
Test2 - Question7
Test2 - Question8
Test2 - Question9
Test2 - Question10
Test2 - Question11
Test2 - Question12
Test2 - Question13
Test2 - Question14
Test2 - Question15
Test2 - Question16
Test2 - Question17
Test2 - Question18
Test2 - Question19
Test2 - Question20

Project assignment - Skew detection - presentation