MacPython Logo from __future__ import *

buy music albums Silver Apples buy mp3 albums Tarrus Riley buy tracks mp3 Kravits buy Reaper albums mp3 buy Kravits albums music buy music Evita CD online albums mp3 Silver Apples download Madonna CD music buy tracks music Kravits download music albums Silver Apples

2005-10-24

MochiKit 1.0

Filed under: AJAX, MochiKit, javascript — bob @ 7:44 pm

I've been putting in a lot of time into MochiKit lately getting it ready for this release: 1.0 [download]. This version number carries a certain connotation, but honestly MochiKit's first release was beyond 1.0 quality compared to the rest of what's out there in this space. It's stable, and we just tagged the latest MochiBot release with what's currently in there (which was a couple checkins before 1.0).

The first thing MochiKit 1.0 brings is a bunch of little bugfixes. There weren't all that many to begin with, but I think they're basically all covered at this point. The rounded corners code still has some rough edges (hah), but it works if you use it as intended and MochiKit isn't about bling at this point.

Everyone loves examples, so here's the new ones:

Interpreter:
An interactive JavaScript interpreter, much like python when run with no arguments. Very useful!
MochiRegExp:
A "live" RegExp explorer, good for debugging those gnarly JavaScript RegExps. RegExps without named groups or a verbose flag suck, you need this.

One API change has been made though (basically a bugfix): MochiKit.Async's sendXMLHttpRequest and anything that uses it will now call the errback chain under ANY error. This means that if the web server is down or if the user has gone to another page or started closing the browser, then you'll get an error. From what I've seen, the error under both of these conditions is going to be an XMLHttpRequestError with undefined status. That's right, you won't be able to discern one from the other, so don't do anything obtrusive (like an alert) if you see an XMLHttpRequestError in your errback! The best thing to do is just log or ignore these errors.

MochiKit.Base has a new updatetree(self, obj[, ...]) function to update an object tree, in order to support new MochiKit.DOM updateNodeAttributes functionality (below).

MochiKit.DOM's updateNodeAttributes now uses updatetree if it sees object values, so you can now set style attributes inline:

var div = DIV({"style": {"display": "block"}}, "div contents here...");

MochiKit.DateTime's isoTimestamp now uses one of the ugliest regexps I've ever written in order to parse ANY ISO 8601 timestamp. It doesn't attempt to validate, so it will accept a large subset of incorrectly formatted ISO 8601-ish timestamps. RegExps in JavaScript are so bad that I had to write MochiRegExp to get this right!

MochiKit.Format grew a couple new functions:

  • truncToFixed(aNumber, precision): Truncate a number to the given precision (does NOT round).

  • roundToFixed(aNumber, precision): Round a number to the given precision (because Safari's Number methods are mostly broken)

  • numberFormatter(pattern, placeholder="", locale="default") and formatLocale(locale="default") brings Java style number formatting to JavaScript:

    assert( percentFormat(1.234567) == "123.46%" );
    assert( numberFormatter("###,###%")(125) == "12,500%" );
    assert( numberFormatter("##.000")(1.25) == "1.250" );
    

2005-10-08

xattr - Python extended filesystem attributes

Filed under: macosx, python — bob @ 10:30 am

xattr is a Python wrapper for the extended attributes APIs available in Darwin 8.0+ (Mac OS X 10.4) and Linux 2.6+. 0.2 added Linux compatibility, and API compatibility with the GPL pyxattr module. Unlike pyxattr, xattr supports both Darwin and Linux, has a dict-like API, and it is MIT licensed.

Usage looks like this:

>>> import xattr
>>> x = xattr.xattr('tiger_8a428_userdvd.dmg')
>>> x
<xattr file='tiger_8a428_userdvd.dmg'>
>>> x.keys()
[u'com.apple.diskimages.recentcksum']
>>> dict(x)
{u'com.apple.diskimages.recentcksum': 'i:969254 ...more stuff'}
>>> x['com.apple.diskimages.recentcksum']
'i:969254 ...more stuff'
>>> x['com.apple.adc'] = 'select'
>>> dict(x)
{u'com.apple.adc': 'select',
 u'com.apple.diskimages.recentcksum': 'i:969254 ...more stuff'}
>>> del x['com.apple.adc']
>>> dict(x)
{u'com.apple.diskimages.recentcksum': 'i:969254 ...more stuff'}    

You can download xattr 0.2 from http://pythonmac.org/packages/ for Tiger's Python 2.3.5 or Python 2.4.1 (installed on Tiger).

svn trunk:
http://svn.red-bean.com/bob/xattr/trunk/
0.2 source:
http://svn.red-bean.com/bob/xattr/releases/xattr-0.2/

MochiKit 0.90 released

Filed under: AJAX, MochiKit, javascript — bob @ 9:59 am

MochiKit 0.90 has been released! This release includes a new feature, some bug fixes.

The new feature in 0.90 is JSON serialization and evaluation support via serializeJSON, evalJSON and registerJSON.

2005-10-08 v0.90

  • Fixed ISO compliance with toISODate
  • Added missing operator.sub
  • Placated Mozilla's strict warnings a bit
  • Added JSON serialization and unserialization support to MochiKit.Base: serializeJSON, evalJSON, registerJSON. This is very similar to the repr API.
  • Fixed a bug in the script loader that failed in some scenarios when a script tag did not have a "src" attribute (thanks Ian!)
  • Added new MochiKit.DOM createDOMFunc aliases: H1, H2, H3, BR, HR, TEXTAREA, P, FORM
  • Use encodeURIComponent / decodeURIComponent for MochiKit.Base urlEncode and parseQueryString, when available.

Powered by WordPress