Skip to main content.
August 13th, 2008

mootools 1.2 and parent

If I’m in the constructor of an extended mootools class, it’s simple to call the parent:


var Animal = new Class({
initialize: function(name, race) {
this.name = name;
this.race = race;
},
doSomething: function() {
console.debug('make a sound');
}
});

var Cat = new Class({
Extends: Animal,
initialize: function(name) {
this.parent(name, ‘cat’);
}
});
What if you want to call a parent method? The reply lies in the following line of the Extends mutator:


self[key]._parent_ = previous;

So, here’s a small class to use with Implements to have a nice access to the parent methods:


var ParentCall = new Class({
_parent: function(name) {
return this[name]._parent_.bind(this);
}
});

And here we have a brand new cat which uses this:


var Cat = new Class({
Extends: Animal,
Implements: ParentCall,
initialize: function(name) {
this.parent(name, 'cat');
},
doSomething: function() {
this._parent('doSomething')();
console.debug('a "meow", to be exact.');
}
});

Posted by mattia as Uncategorized at 12:58 PM CEST

No Comments »

March 16th, 2008

Two

Long time no see, uh?

Two things. First one; it’s obvious that in C# we have that Assert.Equals(none, “string”) does not raise whether Assert.IsTrue(string.Equals(none, “string”)) raises, right?

Second thing. A small script that, given a set of css you downloaded from a site, reconstruct the tree of dependencies it has (through the url instruction). No, why are you thinking I’m copying someone else’s layout? Bad boys!

cat *.css | grep url | sed ’s/^.*url(\([^”)]*\)).*$/\1/’ | while read path ; do if ! test -f $path ; then mkdir -p `dirname $path` ; wget “http://www.volll.com/css/`dirname`” -O $path ; fi ; done

Caveats: does only consider url(xxx), and not url(”xxx”); works only for relative links.

Posted by mattia as Uncategorized at 10:53 AM CET

No Comments »

January 23rd, 2008

Programmatic add on Zope

Just as a reminder, the generic way to add an element to an object manager (like Folders) it’s:

<container>.manage_addProduct[’<product name>‘].<add method, usually manage_add*product name*>(arguments)

Posted by mattia as zope at 3:51 PM CET

No Comments »

January 5th, 2008

ZMI, firefox and big contents

Well, I download the whole mootools library in compressed form, which is about 42kbytes of text all in a simple line (a big, big, big “eval”). I put into my Zope instance and go editing the object… pity for Firefox: it’s almost impossible, since loading such a big line in a textfield gives considerable problems to the browser, up to blocking it on my old notebook.

So, what to do?

Would you believe that the old, textual “links” program just loaded the whole thing without complaining the little?

Posted by mattia as firefox, zope at 11:55 PM CET

No Comments »

« Previous Entries