2008年8月18日 星期一

2007年7月18日 星期三

Using mod_python with python2.5

More for my own reference than anything else….


To get mod_python working with python2.5 on kubuntu:


1. Install apache2, if you haven’t already.


2. Install python2.5:



sudo apt-get install python2.5
sudo apt-get install python2.5-dev

Don’t get rid of python2.4, since it’s still used by a number of things.


3. Change the symlink for /usr/bin/python to point at the new version:

sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.5 /usr/bin/python

4. Install apache apxs2:

sudo apt-get install apache2-threaded-dev

5. Download and extract the latest dist of mod_python. cd to that directory, configure and build:



./configure

make

6. Possibly a controversial step: install modpython as normal
(apt-get), then replace the shared-objects with the .so’s you’ve just
created:



sudo apt-get install libapache2-mod-python

From the downloaded modpython directory (i.e. where you ran configure & make), copy the shared-object files:



sudo cp src/mod_python.so /usr/lib/apache2/modules/
sudo cp dist/build/lib.linux-x86_64-2.5/mod_python/_psp.so /usr/lib/python2.4/site-packages/mod_python/

Copy the mod-python directory from python2.4 site-packages to 2.5:



sudo cp -R /usr/lib/python2.4/site-packages/mod_python/ /usr/lib/python2.5/site-packages/

Restart apache and use modpython as normal…

"注意! 很多本來在python2.4的packages, 會需要重裝, using easy_install"






Powered by ScribeFire.

2007年6月29日 星期五

Using site-package on Windows

為啥Windows中 Python目錄下含要有一個site-packages 檔案夾呢?
官方解釋: 

The standard Python distribution includes a directory
Lib/site-packages, which is used on Unix platforms to hold
locally-installed modules and packages. The site.py module
distributed with Python includes support for locating other
modules in the site-packages directory.

Motivation


On Windows platforms, the default setting for sys.path does not
 include a directory suitable for users to install locally
developed modules.
The "expected" location appears to be the
directory containing
the Python executable itself. This is also
the location where distutils
 (and distutils-generated installers)
installs packages.
Including locally developed code in the same
directory as installed executables is not good practice.


小銘版本:

因為Windows不像 Unix有一個folder (Lib/site-packages)放只有本機端安裝的python程式。
而且windows的 sys.path也沒有一個地方讓使用者能設定本地端安裝的python執行路徑。
最直接的地方是Python executable執行檔所放的地方。這也是用distutils 安裝其他python程式(packages)
會放的預定地。
但是若是把locally開發的程式也放在這路徑下並不是很好!
所以for Windows, 所有開發的新程式都會安裝在\Lib\site-package目錄下, 甚至是用distutils裝的新modules.







Powered by ScribeFire.

2007年6月14日 星期四

Script to create svn + Trac in Ubuntu

p.s doesn't work at .w02這台, but work in your VM's ubuntu after you have installed trac and subversion





$ ./create_dev_env my_project

The script it self looks like this:



#!/bin/sh

echo == Creating Subversion and Trac installation for $1

echo = Creating SVN Repository...

 

# Subversion

cd /var/lib/svn

mkdir -p /var/lib/svn/$1

svnadmin create /var/lib/svn/$1

sed s/EXAMPLE/$1/g /usr/share/trac/contrib/post-commit > /var/lib/svn/$1/hooks/post-commit

chmod +x /var/lib/svn/$1/hooks/post-commit

chown -R www-data:www-data /var/lib/svn/$1

 

# Trac

echo = Creating Trac install...

cd /var/lib/trac

mkdir -p /var/lib/trac/$1

 

echo - Creating files

trac-admin /var/lib/trac/$1 initenv $1 sqlite:db/trac.db svn \

/var/lib/svn/$1 /usr/share/trac/templates

 

echo - Removing anonymous permissions

trac-admin /var/lib/trac/$1 permission remove anonymous BROWSER_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous CHANGESET_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous FILE_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous LOG_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous MILESTONE_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous REPORT_SQL_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous REPORT_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous ROADMAP_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous SEARCH_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous TICKET_CREATE

trac-admin /var/lib/trac/$1 permission remove anonymous TICKET_MODIFY

trac-admin /var/lib/trac/$1 permission remove anonymous TICKET_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous TIMELINE_VIEW

trac-admin /var/lib/trac/$1 permission remove anonymous WIKI_CREATE

trac-admin /var/lib/trac/$1 permission remove anonymous WIKI_MODIFY

trac-admin /var/lib/trac/$1 permission remove anonymous WIKI_VIEW

 

echo - Creating Trac admins

trac-admin /var/lib/trac/$1 permission add ariejan TRAC_ADMIN

 

chown -R www-data:www-data /var/lib/trac/$1

 

echo

echo == Done.




Powered by ScribeFire.

2007年6月9日 星期六

一個神奇的問題! SVN server + apache2 在windows 的安裝



















根据网上的一些资料,按照如下步骤


  1. 首先将Subversion安装目录bin\下面的两个文件:mod_authz_svn.somod_dav_svn.so复制到Apache安装目录modules\目录下。

  2. 找到Apache安装目录下的conf目录,用文本编辑器打开httpd.conf,找到一下两行:



    #LoadModule dav_module modules/mod_dav.so

    #LoadModule dav_fs_module modules/mod_dav_fs.so



    将每行前面的注释符"#"去掉。再在所有LoadModule语句的最后添加一下几行:



    #SVN

    LoadModule dav_svn_module modules/mod_dav_svn.so

    LoadModule authz_svn_module modules/mod_authz_svn.so



    DAV svn

    SVNParentPath "E:/svnrepos"




但是使用启动测试一直有错,返回




Syntax
error on line 143 of C:\apache\conf\httpd.conf: API module structure
'dav_svn_module' in file C:\apache\modules\mod_dav_svn.so is garbled -
perhaps this is not an Apache module DSO?

Apache could not be started







后来再看资料,好像是SVN1.4.3提供的so文件只支持APACHE2.0,并不支持2.2版本的,除非重新编译。好在已经有人解决了,下载了一个支持APACHE2.2的,但却是SVN1.3.2的,死马当活马医了,放到SVN1.4中居然也可以,hoho~~。我是把所有和SVN有关的文件(含动态连接库文件)全部放在了APACHE安装目录的svn目录里,配置文件如下:



LoadModule dav_svn_module svn/mod_dav_svn_1.3.so

LoadModule authz_svn_module svn/mod_authz_svn_1.3.so



DAV svn

SVNParentPath "E:/svnrepos"






Powered by ScribeFire.

2007年6月4日 星期一

Django trick & note

Using template:



1. Prevent template using function call. So things like

I will now delete this valuable data. {{ data.delete }}  



The template system won’t execute a method if the method has

alters_data=True set







Powered by ScribeFire.

2007年4月23日 星期一

XULRunner findings

The XULRunner

目前一共有三種releases ,與firefox版本的對應情形如下:



The XULRunner 1.8.0.x <--> Firefox 1.5.0.x

The XULRunner 1.8.1.x <--> Firefox 2.0.x

The XULRunner 1.9 <--> Firefox 3









Technorati Tags: ,



Powered by ScribeFire.