2007-11-26

web.py update 4 - apache cgi configuration

Finally I decided to put my web.py application on test server. I updated python to 2.5, and installed needed packages.

Then I decided to configure application as fast-CGI under existing Apache2 installation with bunch of other running applications. Short and good installation manual can be found at webpy page.

I tried to configure fast-CGI and then CGI setup, but something went wrong. All configuration examples are using url rewriting, and my Apache does not have proper module. I could of course install mod-rewrite for apache, but I realized that I don't need it yet. Simple web.py application should work even without mod-rewrite. It could be nice feature on constrained hosted systems.

After needed modifications my apache config file for CGI looks like that:

<VirtualHost *:80>
ServerName mywebpyapp.domain.com

Alias /static /var/www/mywebpyapp/static
ScriptAliasMatch ^/(.*) /var/www/mywebpyapp/run-cgi.py/$1

<Directory "/var/www/mywebpyapp">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


and my separate CGI script run-cgi.py:

#!/usr/local/bin/python2.5
import cgitb; cgitb.enable()
import sys
import web, app.controller

def cgidebugerror():
_wrappedstdout = sys.stdout
sys.stdout = web._oldstdout
cgitb.handler()
sys.stdout = _wrappedstdout

web.internalerror = cgidebugerror

#web.webapi.internalerror = web.debugerror
web.config.db_parameters = dict(dbn='postgres', user='user', pw='password', db='myappdb',host='localhost',port='5432')
web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)

if __name__ == "__main__":
urls=app.controller.urls
web.run(urls, globals(), web.reloader)


So my application is working now behind apache and it is ready for production deployment.

2007-11-18

Smartphones are much more than phones - looking for perfect one


Photo author: jurvetson

I used to carry together 2 mobile devices. It was Palm handheld and my cellphone. Those devices are quite old now so I'm looking for new alternative. Year 2007 was good for smartphones and other mobile devices. So there are even multiple options.
Are new smartphones functionally feasible to buy one device instead of cool handheld computer and tiny, elegant cell phone? Most solutions used few years ago were just 2 devices (handheld ,cell phone module) crammed in one case. Did we get increased interoperability and synergy of connected devices? No. The biggest positive was and still is ability to carry one device in pocket instead of two.

So maybe the big winner iPhone? I have specific needs for using custom software on smartphone platform. My perfect feature set contains:
- handheld that can use Linux or even better has established good Linux environment and community (easy hacking, lots of software)
- standard cellphone functions
- GPS or other location service (oh common - they are making even watches with GPS to track you kids)
- WiFi
- external memory card
- big touch screen
- bluetooth or other standard to connect other devices
- build in thumb keyboard or connected external one
- not so needed but it's ok to have lo-res camera

So iPhone is out of interest- it's too closed. Lets look at mix of existing Linux devices at wired blog. So there are many players pushing innovation forward. From typical cell phone producers the most interesting are Motorola running on Linux (open ezx community site), Nokia Linux based (N800 tablet) and new Symbian devices like N95 (it's too closed but it's interesting direction), some Samsung and HTC Windows CE/Mobile handhelds (there is still room for custom software, even another OS). A lot of options- nothing ideal like in real life.

Its good idea to create integrated and standardized platform with mobile features accessible to 3rd part applications like address book, SMS/MMS, call initiating, CLIR, , GPS or other location service, and of course network/internet connection. There is one interesting project called OpenMoko.
"OpenMoko is an Open Source project to create the world's first free mobile phone operating system. "- we can read at the project wiki page. I have have seen few similar projects but this one is really successful. It's outcome is good integrated platform, developer environment and mass produced cellphone FIC NEO1973. Currently produced form factor looks like typical cellphone with nice 2.8" 480x640 touchscreen. It's my favorite for now. For serious typing work it needs bluetooth keyboard. I'm looking forward for typical pocket pc form factor.

Device size is another feature important for buyers. The newest cell phones fit easily into pocket. Most cool smartphones are big- readable screen or usable keyboard takes much place. Have you seen people seeing others calling with bulky smartphones and asking: "Why are you listening to that calculator?" or "Are you trying to hit yourself in a head with that brick?". But there are other choices. Maybe internet tablets are not so bad - excellent for browsing or another tasks using bigger screen and keyboard. If you use wireless headset for calling- it seems still comfortable.

And now about the news. Last week I reviewed materials about Android platform published by Open Handset Alliance (Google is one of the biggest affiliates). It's good defined and integrated platform. It has opened API to all hardware functions (with security policies). Application layer is established on the top of custom Java ME virtual machine. There is no physical devices so it's still ... virtual. Hardware for platform is planned for production at year 2008. I hope that it will have usable features and enough performance.

We have a lot of promising new products now. Probably year 2008 will bring something new and even better. So maybe I will procrastinate a little more with buying new smartphone till next year.

2007-11-12

Weakly typed languages need more testing

I have to written and managed some projects using scripting languages. Those languages often have no strong typing or have duck typing like in python. This is their strength on one way, and weakness on another because it's easier to break the code giving mistaken parameter. Most of this errors are visible after running a buggy code.

Some of older programming languages have built coarse in error messages like in PHP or old ASP family. It doesn't help during debugging and can be really frustrating indeed.

Automatic testing is good, everybody can say even if they don't use it. So it's best to use unit testing specially for that kind of code. In that way simple errors caused by non checked and mistaken parameters can be easy found and unit functionality is checked also.

So once again I say- automatic tests are good. Scripting languages like python, perl or php need automatic tests as additional "safety net". Comparing code written in weakly and strong typed language both covered with tests both may have equal quality, so there is no real typed language quality advance over non typed one.Good tests are what gives you quality and confidence.

So next time if you are going to code something think about- how to test it.

2007-11-05

Evaluation and balancing goals week

Last week I spend on organization of my current projects and balancing my personal life. I also spend more time with family.
It's two months till the end of year and good moment for reviewing and tuning tasks and resolutions need to be done in this year. I'm thinking also about new goals for next year.

I have chosen new learning areas and ordered new batch of books covering subjects like business setup issues, personal skills and secrets of kitchen chemistry (yes, I like to cook something special sometimes).

So most of time it took me planning next movements for professional projects, reaching my personal goals and balancing it. It's hard to manage all that things together but happy family is worth it.