# RootPrompt.org   Nothing but Unix.[Home] [Features] [Programming] [Mac OS X] [Search]


 MySQL - Web Middleware

Some months ago Matt Young developed a lightweight middle layer between MySql and the web. The purpose was experimentation with web programming without the complexity of a standard middleware layer. He describes the system, and says that the source is available if anyone wants to experiment with the concept. Email Matt Young if you want more info or to ask about the source code.

 (Submitted by Matt Young Tue Oct 7, 2003 )

  Uscript

Some months ago I developed a lightweight middle layer between
MySql and the web. The purpose was experimentation with web programming
without the complexity of a standard middleware layer. I will describe
the system to you, and make the source available if anyone wants
to experiment with the concept.

The syntax is based on URL grammar. My hello program is:

http://address/U?print= Hello World&

or if necessary

http://address/U?print= Content-type: text/html\r\n\r\nHello World&

Either of these copied into the web address of the browser prints
a screen with Hello World.

The system relies on built in URL scripts, URL scripts stored in
MySQL, and the original URL script arriving from the browser.

Language characters:

= Macro assignment
& Macro definition terminator
$ Macro expansion
_ External Macro expansion
% escaping sequence

Syntax:

A Uscript is an arbitrary intermixing of the following:
1) plain text
2) $symbol _symbol
3) symbol= uscript&


The system works as a run time macro language. The language is a
recursive macro define and expand. Plain text is emitted, macros
defined special character define symbols which are expanded.

a macro definition is:

name= arbitrary text&

an expansion is:

$name
or if the macro is predefined in the MySQL data base.
_name

Similiar to M4, the U interpreter contains a formatter. The formatter
is useful for filling in SQL and HTML templates for proper execution.


Predefined macros are stored in the MySql as text in
standard tables. The predefined macros are the special power of
the macro language, and I have developed a collection of special-
HTML and SQL templates which can be expanded as external macros.
The parameters in the templates are substituted by macro expansion.


Macro expansions follow expected recursive rules:

$$name will expand $name then attempt to expand the result as
a macro.

When expansion is complete the resulting text is passed
back to the browser.


The macro processor has access to the web and to MySql. The input
and output from the database is placed into a square buffer(s)
which can be rotated, dot producted, and cross producted in various
manners under a special ioctl macro that controls sql IO.


Other special executive macros are built in.

out , out_exec // Flush the buffer
outb , outb_exec // Flush the buffer
outf , outf_exec // Execute tha macro and flush
form , format // Format the
iop", iop_exec
inner , inner_exec
sqlio , sqlio_exec // Send expanded text to MySQL
mode , mode_exec // Change the mode of the SQL square buffer
parse , parse_exec // Execute the specified u script
blob , blob_exec // Interpret a binary blob
ioctl, ioctl_exec // Modify the operation of the square buffer


Our content can be syndicated: Main page Mac Page

Copyright 1999-2005 Noel Davis. Noel also runs web sites about sailing and kayaking.
All trademarks are the property of their owners.
All articles are owned by their author