Skip to content

rjbalest/ufo

Repository files navigation


UFO: a declarative object system for the web.

Author: Russell Balest
E-mail: russell@balest.com
Copyright (C) 2004 Russell Balest



Forward:
Generically referred to as 'UFO', this is a system for writing object-oriented frameworks for web applications using a declarative model based on XML.  The main function of UFO is to generate code artifacts derived from XML declarations.  These artifacts are things like PHP code and SQL statements for inserts, updates, and table creation in a database, which together implement a simple object model for web applications.  This version of UFO is written in Python and while simple usage requires no knowledge of Python, more advanced usage does require Python programming.  The system is extensible and currently has support for PHP, Postgres, and MySql.  The main use of UFO has been, for me, in generating large amounts of PHP and Sql in order to reduce the amount of manual coding and duplication - thus reducing errors.  Currently, UFO provides me a good starting point by generating alot of initial PHP and SQL code which I can then customize manually where I need to.  The ongoing goal is to refine UFO and improve its declarative capabilities in order to reduce the amount of manual coding.

I began using the term UFO in Summer of 2003, but the basic idea had been evolving since 1997 or earlier, written in various languages along the way from Perl to Tcl/Tk.  The term became thoroughly congealed when, in 2004, I wrote a web application for a startup called 'Uffinity'.  Much of my code was using the prefix 'uf_', and my base object class was 'uf_object'.  So, I started thinking of 'ufo' as short for 'Uffinity Objects', which only reinforced the acronym.  UFO is an application of the Filter system.
 

Simple Usage


 UFO comes with a simple implementation of a program to read an XML file containing a <ufo> definition, and output the PHP class and Sql table creation code.
This program is called parseUfo.py and the simplest usage is:
parseUfo.py <ufoFile>

where:
<ufoFile> is an XML file containing the definition of a UFO such as:

---------------
<ufo>
<class name="device" oid="foreign">
<var name="type" type="enum" constraint="gps_device" label="Device Type"> gps_device </var>
<var name="carrier" type="enum" constraint="wireless_carrier" label="Carrier"> carrier </var>
<var name="phone_number" type="string" constraint="phone_number" label="Phone Number"> phone </var>
</class>
</ufo>
---------------

The above example will produce 3 additional output files: ufo_device.php, ufo_device_base.php, and ufo_device.mysql.   The prefix 'ufo' is configurable and may be set to something more meaningful to your project.   Generally speaking, the ufo_device_base.php file should never be edited manually.  Manual implementations are reserved for the user subclass defined in ufo_device.php, in this example.
The contents of the mysql file is simply the SQL necessary for creation of a table called 'ufo_device', predictably.  The contents of the .php file are much more complicated.  But, basically, a PHP class called ufo_device is defined along with several methods like:  create, load, edit, submit, view, update, and a constructor. 

The persistence methods are created in the ufo_device_base.php file and act to synchronize the PHP object with it's persistent form in the database.  The view method returns html code suitable for viewing, and editing an object.  These methods are callable from http GET and POST methods using the UFO mapping specified later.  In addition, these objects will be instantiated and invoked within a larger framework that includes a security model and a layout model.

About

Ufo web app framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages