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.

2007年4月19日 星期四

Try to blog from SFO airpot

中文試一試。。



try try









Technorati Tags:



Powered by ScribeFire.

2007年3月30日 星期五

Creating a new user at django


Creating users


The most basic way to create users is to use the create_user helper
function that comes with Django:

>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword')
# At this point, user is a User object ready to be saved
# to the database. You can continue to change its attributes
# if you want to change other fields.
>>> user.is_staff = True
>>> user.save()


Changing passwords


Change a password with set_password():

>>> from django.contrib.auth.models import User
>>> u = User.objects.get(username__exact='john')
>>> u.set_password('new password')
>>> u.save()

Don’t set the password attribute directly unless you know what you’re
doing. This is explained in the next section.

 powered by clipmarksblog it

Django 的setting


The django-admin.py utility


When using django-admin.py, you can either set the environment variable
once, or explicitly pass in the settings module each time you run the utility.

Example (Unix Bash shell):

export DJANGO_SETTINGS_MODULE=mysite.settings
django-admin.py runserver

Example (Windows shell):

set DJANGO_SETTINGS_MODULE=mysite.settings
django-admin.py runserver

Use the --settings command-line argument to specify the settings manually:

django-admin.py runserver --settings=mysite.settings

 powered by clipmarksblog it

Django setting

Clipmarks user micmickimo has sent you a clip...

 clipped from www.djangoproject.com

Django settings


The basics

A settings file is just a Python module with module-level variables.

Here are a couple of example settings:

DEBUG = False DEFAULT_FROM_EMAIL = 'webmaster@example.com' TEMPLATE_DIRS = ('/home/templates/mike', '/home/templates/john') 

Because a settings file is a Python module, the following apply:

  • It doesn't allow for Python syntax errors.

  • It can assign settings dynamically using normal Python syntax. For example:

    MY_SETTING = [str(i) for i in range(30)] 
  • It can import values from other settings files.


The django-admin.py utility

When using django-admin.py, you can either set the environment variable once, or explicitly pass in the settings module each time you run the utility.

Example (Unix Bash shell):

export DJANGO_SETTINGS_MODULE=mysite.settings django-admin.py runserver 

Example (Windows shell):

set DJANGO_SETTINGS_MODULE=mysite.settings django-admin.py runserver 

Use the --settings command-line argument to specify the settings manually:

django-admin.py runserver --settings=mysite.settings 

On the server (mod_python)

In your live server environment, you'll need to tell Apache/mod_python which settings file to use. Do that with SetEnv:

<Location "/mysite/">     SetHandler python-program     PythonHandler django.core.handlers.modpython     SetEnv DJANGO_SETTINGS_MODULE mysite.settings </Location> 

Read the Django mod_python documentation for more information.

To see more clips or start creating your own, visit clipmarks.com
Sent with Clipmarks

gsmart_台灣技嘉erlated 推出 DVB-T/H smartphone

Fuming has sent you a clip...

 clipped from www.mobile01.com
在本屆CeBIT展場中,台灣集嘉通訊所出品的GSmart智慧型手機,也在展出之列。與同樣來自台灣的倚天科技一樣,展場均位於通訊主館的26館。更有默契的是,兩個攤位還比鄰而居哩!



自從確定了「only smart phones」的策略後,GSmart開始了一連串的研發計劃
本屆展場中所展出的T600與Q60,正是其新一代的代表作品。



一字排開的PDA phone,正是GSmart品牌從零到有的最佳見證。



今年的第一隻新產品:GSmart T600
主打行動電視訴求的T600,在數位電視規格方面,完整支援了DVB-T與DVB-H
(呃...這邊給GSmart一個小建議,這是國際級展覽,不是自家關起門的展覽。在展出之前,應該早就確定了螢幕解析度了吧?怎麼到了會場才用塗改的方式修正呢?= =a)



這是在展場當地所播放出來的數位電視畫質
在VGA螢幕上,配合當地良好的數位訊號,播放出來的效果令人相當滿意哩!



通體雪白的GSmart T600,尺寸承襲過往一貫的短小,體積僅有110.5x55.5x18.5 mm而已。
而在市場策略規劃上,由於主打數位電視功能,因此並未跟隨目前主流的整合GPS策略。



白析透明的機殼,配上亮眼的藍色背光燈,讓整體質感再上一層。



2.6" 大小的26萬色彩屏,擠下了VGA級的解析度,螢幕畫質之細膩可想而知
在微軟新一代OS: Windows Mobile 6的加持下,配上T600本身具備的INTEL PXA270 520MHz處理器、256MB ROM與96MB SDRAM的強悍硬體規格,在操作時幾乎感覺不到鈍感!



驗明正身一下,的的確確是520NHz的處理器啊!



磨沙質感處理過的背蓋,讓GSmart T600的背面,也美的令人窒息....
而這一次,GSmart的RD們終於開竅,把快門鍵改到了機身右側的下方去了!
對嘛!這樣的設計在橫置機器拍照時,才不會讓左手擋住鏡頭啊!



背面鏡頭雖然只有兩百萬畫素等級,但是支援自動對焦、微距拍攝與數位變焦的功能,相信也足堪使用了。



機身正面的按鍵皆採用圓型設計
從通話鍵與掛斷鍵刻意被縮小的體積來看,T600的通訊功能只是附加而已,真正的功能仍舊是在數位電視的觀賞。



講到數位電視,那就一定要帶到天線的部份
不過這地方....呃,好像是觸控筆槽的樣子咧.....= =+



別擔心,GSmart團隊就是要你拿觸控筆當天線!
只要把觸控筆拉到最長,並把筆端停留在出口附近,它就變成了一根數位電視專用的天線!
接下來,你要做的事就是找個支架擺好它,然後好好的看電視囉!
(話又說回來,這觸控筆伸長之後的長度還真不短哩!若真的是邊走邊看,只怕會對消費者造成一定程度的困擾吧?天線,還是內建的才是王道啊.....)



畢竟是數位電視,若是看的正緊張的時候突然沒電,那可真的會想殺人!
T600在出貨就搭載了1300mAh 的鋰電池,相信對於電力續航量,應該有加分的效果。
但實際耗電狀況究竟如何?仍需等待正式上市後,實測過才能確認。



對它已經迫不急待了嗎?
據官方說法,今年五月就可望上市囉!



由於我在15, 16號(當地時間),都沒有辦法拍到實機寫真
因此一直到17號,開放一般民眾進場後,才有機會拍到
這兩位年輕人,左邊那一位對於T600的體型及數位電視功能讚不絕口
一直在我們面前嫌他現用的Dopod 900(德國T-Mobile版)太大台,不好用.....balabala的
再問過當時坐在我旁邊的GSmart PM,他說歐洲市場對於行動電視的需求「極高」
因此也不難理解這兩位小伙子對於T600的癡迷程度了....^^b



另外一隻Q60,則是GSmart首款支援GSM三頻、EDGE與WCDMA的PDA手機,同時支援目前最新的HSDPA規格!



完整QWERTY鍵盤的設計,說明了Q60的走向,被定義成了行動mail 收發中心。
配合微軟的Direct Push技術,不必使用Blackberry也能到處收信囉~
(這也代表了,你再也沒有藉口說手邊沒有Blackberry機,不能到處收發email 了.....= =b)



機身正面的頂端處,配置了視訊通話用的30萬畫素鏡頭。



機身背後則配置了210萬畫素的自動對焦相機。



內裝預備搭載Windows mobile 6 Professional,CPU規格也同樣是INTEL PXA270 520MHz處理器。
不過關於記憶體規格部份,目前並沒有更進一步的資訊。



很可惜的是,Q60的螢幕規格仍停留在QVGA等級。
不過據現場人員透露,此機的部份硬體規格仍在敲定階段,因此會否發生上市後就變成了VGA等級,則有待時間驗證囉~



機身體積除了寬一點,達到了64mm外,長度111mm與厚度14mm的規格,都還在可接受的範圍之內。



機身左側配置了三向滾軸裝置,單手閱讀文件時,你會發現少不了它



觸控筆為可拆式設計。
拆開之後的長短二截,短的當然是拿來戳螢幕用啦~ 那長的咧?



只要打開機頂的micro-SD記憶卡插槽,再將長長的那一截觸控筆,插在其中的一個螺孔內並鎖緊之後......



那麼不必羨慕T600,Q60也能夠拿來當電視囉!
不過嘛....Q60已經支援了HSDPA網路,用它來看網路電視,會不會更有搞頭?^++^



《文章編纂:PERON@CeBIT》
To see more clips or start creating your own, visit clipmarks.com
Sent with Clipmarks

2007年3月29日 星期四

haha

Clipmarks user micmickimo has sent you a clip...

micmickimo's Message:
test
 clipped from en.wikipedia.org

Pythons kill their prey by the process of constriction, whereby they grasp the prey animal in their teeth to restrain it, while quickly wrapping a number of coils around the body of the prey. Then by applying only sufficient pressure to prevent the prey animal from being able to breathe in, ultimately causing it to succumb because of asphyxia. The prey animal might also suffer some restriction to circulation during constriction, particularly where the snake's coils are wrapped around the animal's neck, but this is not usually fatal as death typically occurs much sooner due to asphyxiation.


Pythons, like the closely related boas, are constrictors and are all, by definition, non-venomous. Most pythons feed on warm-blooded prey such as birds and mammals, but some are known to eat reptiles (including other snake species), amphibians and fish.


Pythons do not, as popularly believed, crush or squeeze their prey to death, and when constricting normal sized prey, the snake will almost certainly never apply enough pressure to break bones.


Larger pythons will usually eat something about the size of a house cat, but larger food items are not unknown (some large Asian species have been known to take down adult Deer, and the African Rock Python has been documented preying upon Gazelle). Pythons swallow their prey whole, and take several days or even weeks to fully digest it. Despite their intimidating size and muscular power, they are generally not dangerous to humans.


Most pythons have rows of heat-sensing organs along their lower lips (labial pits). These pits enable the python to detect objects that are hotter than the surrounding environment with great accuracy, and enable hunting to take place in total darkness, such as inside caves. Pythons that do not have heat-sensing organs identify their prey by smell. Pythons are ambush predators: they typically stay in a camouflaged position and then suddenly strike at passing prey.


Pythons will not usually attack humans unless startled or provoked, although females protecting their eggs can be aggressive. While a very large adult python could possibly kill a human being, humans are generally well outside the normal size range for prey. Reports of python attacks on humans are extremely rare. Despite this, pythons have been aggressively hunted, driving some species (like the Indian Python) to the brink of extinction.

 clipped from en.wikipedia.org

Cold-blooded organisms maintain their body temperatures in ways different from mammals and birds. The term is now outdated in scientific contexts. Cold-blooded creatures were, initially, presumed to be incapable of maintaining their body temperatures at all. They were presumed to be "slaves" to their environments. Whatever the environmental temperature was, so too was their body temperature. Cold-blooded animals are now called ectotherms, for the term cold-blooded is misleading.


Since that time, advances in the study of how creatures maintain their internal temperatures (termed: Thermophysiology) have shown that many of the earlier notions of what the terms "warm-blooded" and "cold-blooded" mean, were far from accurate (see below: breaking down cold-bloodedness). Today scientists realize that body temperature types are not a simple matter of black and white. Most creatures fit more in line with a graded spectrum from one extreme (cold-blooded) to another (warm-blooded).


  • Ectothermy - This refers to creatures that control body temperature through external means (Greek: "ectos"εκτος = "outside," "thermos" θερμος = "warm"), such as the sun, or flowing air/water. For more on this, see below.
  • To see more clips or start creating your own, visit clipmarks.com
    Sent with Clipmarks

    Test123

    test
    clipped from en.wikipedia.org

    Python is the common name for a group of non-venomous constricting snakes, specifically the family Pythonidae. Other sources consider this group a subfamily of the Boas (Pythoninae). Pythons are more related to boas than to any other snake-family. There is also a genus within Pythonidae which carries the name Python (Daudin, 1803). Pythons are distinguishable from boas in that they have teeth on the premaxilla, a small bone at the very front and center of the upper jaw. Most boas produce live young, while pythons produce eggs. Some species of sandboas (Ericinae) are also called python.


    Pythons range in size from 1 to 6 meters (3 to 20 feet) in length. Some pythons are among the longest species of snakes in the world; the Reticulated Python holds the record for longest snake, at 10.32 m (32 ft 9.5 in).[1] However the largest snakes that ever lived are the Paleocene Giganthopis garstini and Madtsoia. Both of these gargantuan snakes could grow to be at least 50 feet long.


    Some species exhibit vestigial bones of the pelvis and rear legs, which are externally apparent in the form of a pair of anal spurs on each side of the cloaca. These spurs are larger in males than females, and are used by the male to grip and/or stimulate the female during copulation. Male pythons of certain sepcies sometimes cause spur related injuries to each other during territorial combat, and though more likely to be incidental than intentional, some captured specimens have shown multiple episodes of scarring from such injuries.


    Some pythons display vivid colours and patterns on their scales while others are a nondescript brown or olive. They usually reflect appropriate camouflage for their native habitat. Even within a given species, they may be enormous differences in colouration and pattern between specimens from different parts of their range.


    There are periodic reports about record breaking snakes of phenomenal proportions similar to that of a reticulated python found on the island of Sumatra in Indonesia in 2003, and now on display in a Javan village[2] [3]. As with most such claims, this one has subsequently been debunked[4]. The motivation for such grossly exaggerated claims appears to be mainly economic gain, as, particularly when captured alive, such animals tend to become income producing tourist attractions for their keepers.

    To see more clips or start creating your own, visit clipmarks.com
    Sent with Clipmarks

    Power management

    clipped from en.wikipedia.org

    The Advanced Configuration and Power Interface (ACPI) specification is an open industry standard first released in December 1996 developed by HP, Intel, Microsoft, Phoenix and Toshiba that defines common interfaces for hardware recognition, motherboard and device configuration and power management. According to its specification[1], "ACPI is the key element in Operating System-directed configuration and Power Management (OSPM)".

     powered by clipmarksblog it