Published 2007-07-27 16:59:01

Last week I had a go using my little bindings for something useful, rather than just being a little toy. One of the projects I was working on was a hack to exim4, that logged all incomming and outgoing attachments into mysql and stored them on the filesystem.

The basic idea was that the company needed the ability to review if any sensitive data was being sent out by email. The exim hacks are pretty simple for this (hook into the mime handler). The web viewer uses extjs and PHP at the backend, it's a small addition to their current email management interface.

But one area that was needed was a little cron job that cleaned up the directories and deleted data and files older than 2 weeks (so they dont get too clogged up.)

I thought this would be an interesting test of the mysql and file system bindings. So I threw together a horrifically simplistic version of DataObjects, and a short script that did an SQL query and based on the results deleted records and files.

One issue was that I could not really do the DataObjects thing of overlaying the results, or query options into the dataobject as object variables in javascript are overlaid into the same namespaces as methods, so you could accidentally delete methods if your database had matching names. - So the data just gets put in (dataobject).data.* 

The other issue was that the syntax for javascript while fun and flexible could really do with a class construct. If you look through the specifications for ECMAScript4, There is a huge amount of changes making Javascript as we know it far more Java / PHP5'y.. with interfaces, public private etc. So I had a go at adding some of the new features into the dmdscript core.

I've managed to get class's and include working. although it probably needs quite a bit more testing. This basic syntax now works
include "mytest.ds"; // this is run at compile time (not runtime!)

class A {
function A() {
println("This is the constructor A");

}
var c = 12;
function B() {
println("This is B and c is " + this.c);
}


}
class C extends A
{
function C() {
println("This is the constructor C");
A.prototype.constructor.call(this);
}
function D() {
println("This is D and c is " + this.c);
}
}


var a = new A();
a.B();

var c = new C();
c.B();
c.D();

Will successfully output

Hello from mytest
This is the constructor A
This is B and c is 12
This is the constructor C
This is the constructor A
This is B and c is 12
This is D and c is 12

Now I can start writing tidy little javascript libraries...




Mentioned By:
google.com : april (108 referals)
google.com : december (90 referals)
google.com : ecmascript4 (20 referals)
planet-php.org : Planet PHP (18 referals)
google.com : javascript2 (16 referals)
google.com : dmdscript (10 referals)
www.phpeye.com : javascript2, ECMAScript4 and dmdscript. - Alan Knowles - PHP教程|PHP新闻|PHP5|PEAR|PHP框架 - Powered by HappyCMS (6 referals)
planet.dprogramming.com : Planet D (6 referals)
www.debian.org.hk : Planet DebianHK | Debian HK (5 referals)
google.com : ecmascript4 google (2 referals)
google.com : javascript-2 (2 referals)
google.com : javascript2 names namespaces (2 referals)
www.drop-zone-city.com : [ Le KIoSQUE par Drop Zone City ] (1 referals)
www.aikons.net : Pagina personala Nicu Rancov :: Multiheadlines (1 referals)
phpgg.nl : phpGG.nl | Nederlandse PHP gebruikersgroep (1 referals)
jh-webservice.de : News :: Planet PHP (1 referals)
hghltd.yandex.net : YourFeeds - Planet PHP (1 referals)
google.com : ECMAScript 4 (1 referals)
google.com : betting (1 referals)
google.com : buspar (1 referals)

Comments

Repository?
Are your patches available for downloading? or, evenn better, are sored in some kind of cvs/svn?
#0 - Alexey Zakhlestin ( Link) on 2007-07-31 23:46:18 Delete Comment

Add Your Comment