Jul 09

Still remember the great company Caucho? Yes, it’s still alive. Besides its flagship product Resin, it also provides some open source libraries.

Actually, there are 2 remoting libraries you can use. One is Burlap, and another is Hessian. Hessian is the binary protocol implementation of Burlap. Burlap is xml based RPC. That’s quick easy to use in Spring framework, but 2 years ago, only be available in Java world. Now, it’s changed a lot. Take a look at Hessian, it’s pretty cool, so many implementations for different languages. Especially for Flex.

Hessian is very similar to AMF, but without any performance comparison, I don’t know which is more efficient. Anyway, we have one more solution for Flex Remoting, which from the Java world. That’s great!

Here is an example how to use Hessian in Flex.
Hessian: Flex Remoting Without AMF

Jul 08

今天把大概一年前写的 Django 程序拿出来做一些改进,主要这一年来 Django 做了重大升级,虽然兼容性非常不错,但是以前代码里面扩展 manage.py 的部分已经可以重写了,因为 Django 提供了 API 来进行扩展。

因为 Django 根据字符串形式的 namespace 来加载模块,所以我见过不少修改 manage.py,通过重新定义全局变量来修改 Django 设置的代码。我虽然也非常喜欢 hack Django 这个框架,但是我一定不喜欢去改 Django 本身的代码,尽可能通过外部修改来达到自己想要的功能。

trunk 中的 Django 版本提供了扩展 manage.py 的 Command 的 API,只需要在相应的 module 中加入 management/commands 目录,在 commands 下面创建多个 py 就可以得到扩展自定义命令的功能了。譬如加入 management/commands/mycommand.py,就可以通过 manage.py mycommand 来执行,非常的方便。我早起的程序通过修改 manage.py 本身来实现,现在完全可以升级一下了。

但是没想到出问题了,因为 namespace 的问题,Django 在搜索 commands 的方式上是通过 relative import 形式。但是我习惯性把 INSTALLED_APPS 这个变量中的 apps 都写成完整的 namespace,总是以项目目录为顶层包名,结果 Django 就找不到自定义的 commands。

namespaces 一直都是很麻烦,为了省事,我干脆还是把 INSTALLED_APPS 里面的东西改了,结果就可以用了,其实使用相对路径还是比较好的。最近人变懒了,不愿意去深入研究里面的细节了。

Jul 03

昨天开始看 Flex 相关的东西,打算把一个现有的 Python Web 应用前端逐渐转换成 Flex。向 咖啡屋的鼠标 了解了下 Flex 如何与后端应用通讯,知道了一个新的协议叫做 AMF,是 Flash/Flex 原生支持的 RPC 协议,而且用起来也要比 XML 方式更加简单。

正好又一个 Python 的实现叫做 PyAMF 可以做协议的解析,很不错!