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");;
function D() {
println("This is D and c is " + this.c);

var a = new A();

var c = new C();

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: : april (108 referals) : december (90 referals) : ecmascript4 (20 referals) : Planet PHP (18 referals) : javascript2 (16 referals) : dmdscript (10 referals) : javascript2, ECMAScript4 and dmdscript. - Alan Knowles - PHP教程|PHP新闻|PHP5|PEAR|PHP框架 - Powered by HappyCMS (6 referals) : Planet D (6 referals) : Planet DebianHK | Debian HK (5 referals) : ecmascript4 google (2 referals) : javascript-2 (2 referals) : javascript2 names namespaces (2 referals) : [ Le KIoSQUE par Drop Zone City ] (1 referals) : Pagina personala Nicu Rancov :: Multiheadlines (1 referals) : | Nederlandse PHP gebruikersgroep (1 referals) : News :: Planet PHP (1 referals) : YourFeeds - Planet PHP (1 referals) : ECMAScript 4 (1 referals) : betting (1 referals) : buspar (1 referals)


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


Tel: +852 3709 2951
Room 2710, Trend Center
29-31 Cheung Lee Street,
Chai Wan
Hong Kong

Copyright 2023 - Roo J Solutions Limited

Powered by the Roo Javascript Library and our Roo bootstrap toolkit