Posted by Graham Stratton
Mon, 28 Aug 2006 09:54:54 GMT
I decided that I need a system to alert me when one of my websites is down. The obvious technology for this is SMS, so I thought I’d look at how to do this.
There’s a very details tutorial and background to SMS at http://www.developershome.com/sms/ – however, it doesn’t suggest a good SMS gateway provider in the UK. Google ads suggested fastsms.co.uk (there’s something called fastsms III which I think is unrelated).
FastSMS have a package designed for developers, which can send
SMS messages either from emails or from HTTP requests. Details are at http://www.fastsms.co.uk/packages/velocity-direct.html
So far I’ve only got as far as signing up, but I don’t think sending an HTTP with the correct parameters will cause too many problems.
2 comments
Posted by Graham Stratton
Tue, 22 Aug 2006 13:24:40 GMT
Today I needed to install postgres on OS X, and it was sadly rather complex. Therefore, here’s a quick guide for myself in future.
I chose Darwin ports to install Postgres:
sudo port sync
sudo port install postgresql8 +server
the +server command creates a postgres8 user.
Then I needed to update my bash profile:
sudo -s
echo "PATH=$PATH:/opt/local/lib/postgresql81/bin" >> /etc/profile
echo "export PATH" >> /etc/profile
echo "export PGDATA=/usr/local/pgsql/data" >> /etc/profile
exit
source /etc/profile
create the data directory and start Postgres:
sudo mkdir -p /usr/local/pgsql
sudo chown postgres8 /usr/local/pgsql/
sudo -u postgres8 initdb
sudo -u postgres8 pg_ctl start
then finally databsaes can be created:
sudo -u postgres8 createdb tutors
Posted in Mac | 2 comments
Posted by Graham Stratton
Fri, 11 Aug 2006 14:33:00 GMT
A few days ago I spent about a day debugging a problem where I had set the IP address of certain domains in my /etc/hosts on my local machine, in order to test those domains on my new server before the DNS was switched over, and spent most of a day debugging that.
It turned out that NTL have a ‘transparent’ proxy, which routes web requests to the ‘correct’ server, so it didn’t matter where I attempted to send the requests. The fact that it (obviously, really) intercepted telnet sessions to port 80 didn’t make me any less confused. And I think it’s slightly buggy, I’m sure there was a class of requests that got to the right place.
Sadly today I got caught by this again. I spend a long while trying to debug my apache config, trying to set up a default page for people accessing my machine by IP or by an unknown name.
I’ve recently had a client transfer their domain to my server, so I tried to access that, but no matter how much I tried I kept getting my photography site. Accessing by IP address returned the same site. But the default site is the first in the server setup. Hmmm.
Enter NTLs translucent proxy. Firstly, the DNS change for the new domain doesn’t seem to have reached their servers yet. Hang on, why don’t they send me to the old server, then? Ah, because in the old DNS setup www.domain.tld existed but domain.tld didn’t; now both of them do. No, that doesn’t quite work.
It seems that if I try accessing by IP address the proxy is adding headers for some domain hosted on that server. Very strange. If I try accessing the same site from my other server it works fine.
1 comment
Posted by Graham Stratton
Thu, 10 Aug 2006 00:27:11 GMT
I decided that I wanted to put a Pylons application behind Apache. After the grief I had with Rails, I wasn’t keen to use fcgi. So I decided to try the mod_python approach, which is generally significantly faster anyway.
Since a Pylons app is a WSGI app, this should be trivial. The first thing to do was to install mod_python, a standard download, configure, compile and install. Then the WSGI app must be made suitable for deployment via mod_python. There is a project to create a mod_python gateway, but for some reason this wasn’t included in the latest version of mod_python. So I downloaded it, and saved it as mod_python/wsgi.py.
Then I created a two-liner python program startup.py:
from paste.deploy import loadapp
app = loadapp("config:/home/graham/flightsearch/deployment.ini")
Then I had to configure apache.
<Location /flightsearch>
SetHandler mod_python
PythonHandler mod_python.wsgi
PythonPath "['/home/graham/flightsearch'] + sys.path"
PythonOption wsgi.application startup::app
</Location>
I did all this and, erm, it didn’t work. In fact, I had segmentation faults in my Apache error log. A lot of Googling suggested a lot of possible reasons. It turned out to be that Apache uses the version of libexpat installed on the system, whereas python 2.4 ships with its own (later) version. This could just be an issue because the system is old (Fedora Core 1). Anyway, for some reason replacing the libraries on the system with the same version as python was using, and sym-linking them appropriately was enough to get things working.
Finally, Apache needs to be given access to some data and lock files associated with the application.
Posted in Python, Apache, Pylons | 6 comments
Posted by Graham Stratton
Tue, 08 Aug 2006 00:48:01 GMT
Generic stuff:
passwd
hostname fred
useradd -s /bin/bash -m graham
passwd graham
apt-get install sudo
vi /etc/sudoers (give graham sudo access)
vi /etc/console (add aliases for ll, etc)
sudo apt-get install ntp-simple
sudo /etc/init.d/ntpd start
sudo apt-get install subversion
sudo apt-get install darcs
sudo apt-get install make
sudo apt-get install gcc
sudo apt-get install libc6-dev (provides limits.h)
Had to upgrade to gcc/g++ 3.4 after errors like this (bug in gcc 3.3 in debian stable????):
multiple definition of `__i686.get_pc_thunk.bx'
sudo apt-get install rsync
sudo apt-get install apache2 apache2-dev
Python and Zope:
sudo apt-get install python2.4-dev
svn co svn://svn.zope.org/repos/main/Zope3/branches/3.3 Zope3
make
sudo apt-get install libjpeg-dev
wget http://effbot.org/downloads/Imaging-1.1.5.tar.gz
tar xzvf Imaging-1.1.5.tar.gz
cd Imaging-1.1.5/
python2.4 setup.py build
sudo python2.4 setup.py install
#zc.datetimewidget ought to be installed round here somewhere
vi ~/.pythonstartup
import readline, rlcompleter
readline.parse_and_bind("tab: complete")
export PYTHONSTARTUP=~/.pythonstartup
repozo.py -Rv -r vdsbackup/tobackup/cwd -o Data.fs
Mysql for typo:
sudo apt-get install mysql-server-4.1
mysql -uroot
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');
GRANT ALL ON test.* TO 'root'@'localhost' IDENTIFIED BY 'goodsecret'
vi config/database.yml
Trac:
wget http://www.clearsilver.net/downloads/clearsilver-0.10.3.tar.gz
tar xzvf clearsilver-0.10.3.tar.gz
cd clearsilver-0.10.3/
./configure --with-python=/usr/bin/python2.4 --disable-ruby
make
sudo make install
sudo apt-get install postgresql postgresql-client postgresql-dev
wget http://ftp.edgewall.com/pub/trac/trac-0.9.6.tar.gz
tar xzvf trac-0.9.6.tar.gz
cd trac-0.9.6/
sudo python setup.py install
wget http://initd.org/pub/software/psycopg/psycopg2-latest.tar.gz
tar xzvf ; build ; install
sudo su - postgres -c createdb trac
sudo su - postgres -c psql trac
CREATE USER trac WITH PASSWORD 'secret';
sudo vi /etc/postgresql/pg_hba.conf #Set access restrictions
svnadmin create /the/repos
trac-admin project initenv
#Give the connection string postgres://user:password@localhost/dbname
#Trac install breaks apache2. Insert loading of mod_dav before mod_dav_svn in httpd.conf
And ruby:
sudo apt-get install ruby1.8 ruby1.8-dev irb1.8 rdoc1.8
wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
tar xzvf rubygems-0.8.11.tgz
cd rubygems-0.8.11/
sudo ruby1.8 setup.rb
cd
rm -rf rubygems-0.8.11
rm rubygems-0.8.11.tgz
sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
sudo apt-get install sqlite3
sudo apt-get install sqlite3-doc
sudo apt-get install libsqlite3-dev
sudo smart install libsqlite3-ruby1.8
Looks like I forgot to record a bit. From memory:
sudo gem install rails
sudo gem install typo
sudo gem install fcgi
sudo gem install mysql
sudo chmod +rx /etc/apache2/logs
no comments
Posted by Graham Stratton
Tue, 08 Aug 2006 00:33:23 GMT
After discovering that the error message in my last post was apparently due to a gcc bug (in debian stable?!?), I decided to have another go. For some reason gem install fcgi worked without installing anything else new. Then I just had to change the apache config file slightly and fiddle with permissions of lots of log files, and fix a bug in typo, and now I have fcgi working again.
Posted in Rails, Debian | 8 comments
Posted by Graham Stratton
Wed, 02 Aug 2006 20:02:17 GMT
After the complexity of trying to get mod_fcgid to install last time, I’m giving up and just using cgi this time.
I tried what I did last time, but
gem install fcgi
failed with
checking for FCGX_Accept() in -lfcgi… no
I found someone who claimed to have a setup working, by compiling fcgi from fastcgi.com for themselves, but when I tried the compiler spewed this one:
multiple definition of `__i686.get_pc_thunk.bx’
I really don’t know why it’s so hard. Surely apache2 on debian must be one of the more common deployment platforms?
Posted in Rails, Debian | 4 comments
Posted by Graham Stratton
Wed, 02 Aug 2006 18:07:00 GMT
I’ve now completed moving most of my stuff to my new server. So far, this blog has caused me most grief. I spent ages trying to get typo to install. I kept getting the error
checking for sqlite3_open() in -lsqlite3
when trying to install the typo gem. It turned out that not only is one required to have libsqlite3 and libsqlite3-dev installed, but one mustn’t have libsqlite or libsqlite-dev installed. Apparently installing the debian package build-essential is also required.
Posted in Rails, Typo | 3 comments
Posted by Graham Stratton
Fri, 28 Jul 2006 14:15:50 GMT
It seems I’m not the only one who’d like something like Ruby’s symbols in Python. The answer is Phillip Eby’s SymbolType package, available now from a cheeseshop near you.
no comments
Posted by Graham Stratton
Thu, 13 Jul 2006 21:56:00 GMT
I wrote most of this pretty much the day after I returned from Europython, but I haven't gotten round to posting it until now.
<sidenote>
I don't like markdown. Apparently it's meant to be as much like plain text as possible, but which do you do:
Heading
=======
or
###Heading###
?
Hashes being so much effort to type on Mac doesn't make them any more endearing, either. We need a Zope 3 blog application!
</sidenote>
Introduction
Notes from Europython 2006, at CERN in Switzerland. As last year, the conference was great fun, really interesting and left my brain crammed with ideas. I hope I got most of them written down!
I think that there were slightly fewer people there this year, but the enthusiam and number of interesting projects seemed to still be very high. I'm happy python's still en route to taking over the world. Not quickly, but it's getting there. Ironically the IT industry seems to be one of the slowest moving out there.
Web Frameworks
In a stark contrast to last year, when there were oodles of Zope talks and no other Python web frameworks, this year most of the talk was about the three new Python web frameworks: Django, TurboGears and Pylons.
Zope
Europython definitely left me with the impression that Zope is losing momentum. This doesn't necessarily the end for Zope; firstly, it could just be an illusion, as people were too busy being enthusiastic about other frameworks. But more importantly, there never have been that many sites built with raw Zope; Zope's success has been with the use of Plone and other CMSs built on it.
However, I do feel that the Zope 3 project is losing momentum. Most of the ideas have been experimented with, and what remains is the hard slog to make existing applications reasonably compatible with it. There's a limit to how many more major architectural changes people will put up with once major projects start to be built with it.
Zope 3 in general feels too complex to me at the moment. There were few major changes in the last release; most of them were removals of 'convenience ZCML' directives, which, whilst I agree with Philipp that the changes make Zope 3 a bit easier to understand, don't really make life any easier. The component architecture is wonderful, but there's a big step between that and a working web application.
I think that either Zope 3 is too complex, and most people will never understand it well enough to use it, or there's just far too big a gap from the books to what you need to know and understand to write an application. Maybe not on the implementation side, but in terms of data structuring and things like that. There have been a lot of discussions on the mailing lists about how to do many to many relations, whether one should do a direct object reference, and things like that. Most users could probably manage to do one way or another, but get stuck on trying to work out which one to do.
Tarek's talk on zope-cookbook.org was quite interesting for me. I had assumed that it was just a place people could upload random docs, but it's actually very carefully planned and structured. If it gets a lot more recipes in it, it should become a very valuable resource. I think it probably needs a lot more design guides. Working out how to do things is hard, but nowhere near as hard as working out what should be done in the first place.
The new boys
I attended talks on TurboGears, Django and Pylons, but didn't really take in too much, and I can't entirely remember which is which. Maybe someone will draw up a comparison table showing which ORM, templating engine, etc, each of them use. I was impressed by the number of things Pylons does using WSGI; adding functionality using WSGI demonstrates that components are genuinely easily pluggable.
Ajax
For some reason it is customary to write Ajax rather than AJAX.
A year ago, Ajax was pretty new, with Google maps and Gmail being the main users. Today no framework will succeed without Ajax support. Tarek Ziade of Nuxeo gave a talk on the state of the art. He covered a number of approaches.
Firstly, CrackAjax is a tool to convert python into Ajax. I guess the number of constructs is quite limited, unlike an Ajax backend for pypy, which was apparently demonstrated at the conference. CrackAjax has not been developed for about 8 months.
Azax allows you to describe the JS behaviour in an XML file, though the number of possible behaviours is currently quite limited.
Tarek's recommended solution is a client-side framework, the two examples he suggested being Scriptaculous with Prototype, and MochiKit.
Tarek has been good and uploaded his slides; they're certainly worth a look if you need to do Ajax in python web apps.
WSGI
The Weally Simple Gateway Interface, defined in PEP 333, is gathering pace rapidly as people realise just how powerful it is. James Gardner's talk on WSGI covers the topic nicely, and he has also uploaded slides, so I refer the reader to them. Also look at Pylons, a web framework where most of the components are integrated using WSGI.
CPSSkins
This is a very impressive technology allowing through-the-web development of web designs using a very cunning bit of Ajax on top of Zope 3. Just drag and drop your portlets and data widgets, and you're done. How cool is that going to be? There are demos at www.z3lab.org http://www.z3lab.org/sections/front-page/design-features/news-portlet-widget
Language
Python 3000
Guido's keynote on Python 3000 was, for me, very encouraging for the future of the language. At present there are not too many new and complex features coming into the language; the major changes will be getting rid of bug-inducing features.
The announcement that print will become a function instead of a statement prompted a synchronised intake of breath through the whole lecture theatre. The argument is that, well, it should be, and it makes it much easier to replace printing with logging during application development.
Relative imports will have to be explicit. Hooray!
PyPy
Unfortunately I didn't get to attend many of the pypy talks. However, the lightning talk on the features of pypy 3000 was encouraging; the core team are still highly enthusiastic about the project and its potential. There are still plenty of ridiculous sounding ideas going rounds, such as being able to change the interpreter being used at runtime, which gives me great faith in the project. It hasn't got too serious yet, and is continuing to be the research project it set out to be.
Of course, pypy isn't really a python compiler, it's really a generic compiler. Obviously the first thing you want to compile is the compiler itself, just because it's cool, but now that's done, the options are pretty much unlimited. Whether pypy ever makes python interpretation as fast as C remains to be seen!
Libraries
zc.buildout
Jim Fulton introduced zc.buildout, a tool for setting up environments with many software packages. It's not Zope specific; it builds on eggs, adding the flexibility required to be able to guarantee the correct versions of different packages and databases for development and deployment. Well worth a look, IMO. Jim has also been nice and uploaded slides.
Applications
Mercurial
Mercurial is yet another source control management tool. But it's written in python, and applies patches much faster than subversion, whilst using less memory and having a smaller repository. Apparently it doesn't deal with conflicts as well as darcs does. Mercurial has been selected as the SCM tool for OpenSolaris; it's ideally suited to this, as it's an environment where people may regularly want to apply hundreds of patches to customise a standard source tree.
MailManager
MailManager has been around for quite a long while. LogicalWare were one of the first Open Source companies in the UK to secure funding. MailManager allows companies to distribute mail to enquiry and support helplines internally, and to track messages.
LogicalWare sell this software as a service, or as support, or as pre-installed boxes. Sadly they do not receive that many contributions to the project from the open source community. It is always hard for a company to get such contributions, and it is interesting seeing which companies succeed. I think Zope corporation does better because other people are using the software for their own projects continually, so are more likely to improve it that a system like MailManager which is installed and left, probably not by a developer.
Business
A discussion on the last afternoon concluded that to support customers, a good model may be to have a connected issue tracker, for customer use, and a bug tracker for developer use. This is the model used by Launchpad. It seems a good model, so I'd be surprised if there isn't already a product which offers this solution.
Summary
Well, thanks for reading. I'd be keen to hear other opinions!
Posted in Software development, Zope3, Python, Conferences | 3 comments