Playing with Meteor Again

It’s been awhile. I’m looking at Meteor again after my first look about 2 or 3 years ago. It seems to have matured into a rather cool web framework. It’s USP is real time updates between server and clients. Anything entered into the server database, is reflected (almost) immediately on each of the clients. If a client makes changes, those are reflected immediately on the local, and are background updated to the server, and then out to the other clients. It’s really slick.

It uses (by default) a mongodb as backend, and minimongos on each client, which live in the browser memory and have a subset of the full database cached locally. These listen for updates from the server and push updates to the server form teh minimongo. The client only reads and acts on the minimongo.

I decided to pay proper attention this time instead of skimming, so I’ve bought the Discover Meteor Book by Tom Coleman and Sacha Greif.

I’ve also done some digging into the architecture of Meteor because I have always wondered about how much control and scalability I might be sacrificing for the “magic”. This page from The Meteor Cookbook helped a lot (thanks). I now understand that I can remove the mongodb from the meteor server itself and deploy and admin as I wish in production. I am still a little hazy on scaling the meteor app itself, but that is coming in later chapters!

All in all, I’m enjoying myself. The long winter evenings will just fly.

Advertisements

Installing Python, pyMongo, and Bottle on Windows

I had no problem installing all of the above on my Mac. On Windows, however, it was a bit of a pain. Thinking about it, it maybe that the mac install was Python 2.7, which everyone has been there and done that, whereas the Windows install was python 3.3, which may be a little later to the party.

Anyway, what I did:

  1. Install python 3.3 from http://www.python.org/download/releases/ Use the msi installer
  2. Install the pymongo using the msi from http://pypi.python.org/pypi/pymongo/ > Look down the bottom to find the windows installers. I suggest you don’t do an easy_install, it won’t compile properly and will either not work at all, or will have degraded performance.
  3. Install distribute. The instructions are here. I found it easiest to install from cygwin/git-bash using:
     $ curl -O http://python-distribute.org/distribute_setup.py
    $ python distribute_setup.py
  4. Install pip using easy_install supplied by distribute. NB: you must do this from the DOS command line (and, it appears, be in the Scripts folder):
     C:\> cd c:\Python33\Scripts\
    C:\> easy_install pip
  5. I also installed bottle at this point.
     C:\> pip install bottle

Many experienced python developers are recommending using virtualenv. It allows you have a virtual python install where you can pip install anything without blowing up your base python install by accident. You may have to use the performance retarded pymongo as Windows 7 (32-bit) doesn’t have the c libraries needed to build the necessary modules.

Hat tip to khattam for the distribute/easy_install usage.

Log4Mongo in Eclipse: can’t find getTimestamp()

Having added log4mongo to some of my older projects, I remove the old log4j-1.xxxx.jar and replace with log4j-1.2.15.jar. I start a junit test as usual and get an exception:
java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.getTimeStamp()J
at com.google.code.log4mongo.MongoDbAppender.bsonifyLoggingEvent(MongoDbAppender.java:216)
...

Go into the project properties in Eclipse (right-click on the project in the Package Explorer, hit properties), go to Order and Export tab and click on the log4j-1.2.15.jar. Press the Top button. Hit OK and re-run your test. Hey presto, sorted.

I haven’t done enough digging but I think it something to with the commons-logging having a out of date api and being first in the classpath it can findthe latest version of LoggingEvent.