Josh is pretty involved with JSON RPC these days, and he has written a Python client and a Python/Tornado server plugin. The cool thing about his jsonrpclib is, it mostly supports the same interface with Python's XMLRPC model, so you'll have no trouble replacing XMLRPC with JSONRPC. I've written a simple chat server and client to get myself familiarized with his modules.
2009-10-20
2009-10-15
Getting the Current Module in Python
Say, you want to insert a function, class or any other object into the current module dynamically; how can you do that? Of course, you start with getting the module name:
myName = globals()['__name__']
Then, getting the module itself:
import sys me = sys.modules[myName]
OK, you got the module, now insert something in it:
setattr(me, 'hello', lambda x: 'Hello %s'%x)
We can call hello in our module from now on:
print hello('World')
2009-10-14
Merging PDF Files Using Ghostscript
If you have to merge PDF files, you need no other than Ghostscript (which is installed by default with many Linux distributions); here's the command line:
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=firstANDsecond.pdf -dBATCH first.pdf second.pdf
2009-10-09
Josh's CouchDB Articles...
My friend Josh is writing a series of articles on CouchDB; he is covering CouchDB from the ground up, be sure to check it out!
Web Application Testing with Selenium: Basics and Setup
Introduction
It's always hard to ensure an application works up to a specification and continue keeping up to the specs in the course of development. Testing web applications is even harder, since they are composed of more components, and usually at least some of the components of the application are not directly controlled by the developers, such as links to other internet resources or mashups.
Luckily, there's a great tool for easing the pain of web application testing: Selenium. Selenium simulates a human user, by controlling a web browser using Javascript through a system called Selenium Core. The simulated behaviour includes clicking on links, form and dialog buttons; filling in forms; drag&drop and others.
2009-10-08
PySWIP: Facts and Rules
PySWIP is a Python module which enables accessing SWI-Prolog's foreign language interface using our beloved computer language. Here's a small tutorial on adding facts and rules to prolog knowledgebase.
2009-10-07
Testing Syntax Highlighter
import os
import fnmatch
function filterPythonSource(path):
return fnmatch.filter(os.listdir(path),
'*.py')
if __name__ == '__main__':
print filterPythonSource(os.getcwd())
2009-08-13
Getting the currently playing song info on Amarok through DCOP
import pydcop
playerService = pydcop.DCOPObject('amarok', 'player')
d = dict(
title=playerService.title(),
artist=playerService.artist(),
album=playerService.album()
)
print '%(artist)s - %(title)s (%(album)s)' % d
kdcop is a great application to discover DCOP services.
I've posted a slightly extended version of this entry to: Active State Python Cookbook