[Laszlo-dev] For your review: Laszlo Database API spec version 1.1

Oliver Steele steele at laszlosystems.com
Sat Nov 12 16:38:57 PST 2005


This is an excellent start.

I believe this should be split into two specs:
- A REST API for communicating between an OpenLaszlo client  
application and a server.  This is mostly the same as the  
"Interacting with models" section of the existing proposal.
- A declarative syntax for defining server-side models.  This is the  
"Creating models" section of the existing proposal.

I would hope that, over time, this project would grow to include  
components that reflected on the schema in order to provide  
configuration-free master-detail views of database tables.  The  
ability to use those components across multiple server-side  
frameworks (Rails, PHP, Java) makes them more appealing.  I really  
see one of the main benefits of this project as being that it could  
decouple the server side technology from the client-side OpenLaszlo  
programming by defining a wall between them --- the REST protocol ---  
and therefore facilitating the sharing of client-side components  
among developers who use different server-side technologies.

If you buy that that's a benefit, then there are several potential  
audiences for the parts of this spec, and more audiences for the REST  
protocol than for the declarative syntax.  There are at least these  
audiences:
- Rails developers.  Rails is an adequate solution to the problem of  
declaratively specifying an ORM and wiring it to HTTP.  However,  
Rails makes it easy to build, but does not itself specify a standard  
protocol, for reading and manipulating the model programmatically.   
For this audience, the REST protocol is useful because it defines a  
convention that can be supported by tools, plugins, and client-side  
components.  The XML declarative syntax is an alternate and less  
functional solution for specifying something that Rails already  
provides.  Rails + Connector REST Spec implementaton for Rails +  
OpenLaszlo = an end to end solution.
- Server developers.  By implementing or adapting their own ORM to  
the server side of the REST API, they enable it for client-side  
components and applications that are written to the client side of  
the API.
- Client developers.  This is where the declarative syntax is useful,  
in that it allows the developer to write a database-backed  
application without writing or learning an ORM and its associated  
server-side scripting language.

Moving to specifics, I'd like to have a way to snap an OpenLaszlo  
component together with a Rails server.  In my dream world, I could  
do something like this to create, say, a database-backed contact list:

1. Create the database

2. Create, configure, and launch the server;
a. Create the application
   > rails contacts
   > script/generate model Contact
   > script/generate controller Contact
b. Download the mythical laszloonrails plugin into your plugins folder
   > svn export svn://laszloonrails.com/laszloonrails/trunk/ vendor/ 
plugins
c, Edit this line into app/controllers/contact_controller.rb:
   class ContactController < ApplicationController
     laszlo_scaffold :contact
   end
d. Update env/database.yml
e. Launch the server:
   > script/server

3. Create an application:
   <canvas>
     <include href="database-connector"/> <!-- defines <dblist>,  
<dbdetail>, <dbmasterdetail> -->
     <dbmasterdetail baseurl="http://localhost:3000/"/>
   </canvas>

4. ..and request the application URL in the browser.

If I were running PHP instead of Rails, steps (1) and (3-4) would be  
the same, but I'd either write my own PHP code that spoke the API in  
the database spec, or write some XML and use the PHP connector  
library.  if I wanted to extend the server I could (in the Rails  
case) add code to the default models, views, and controllers, or (in  
the PHP connector case) add some :before, :after, and :around  
functions to files that are automatically included.  And if I wanted  
to extend the client, I could unpack <dbmasterdetail> into the  
classes that it's composed of, an unpack or parameterize them, and so  
on.

On Nov 3, 2005, at 5:26 PM, Max Carlson wrote:
> Hi,
>
> I'd like your feedback on the attached revised spec.  Thanks to  
> Henry and Geert for setting me straight on the need for native  
> methods and a more extensible syntax for specifying constraints.   
> This time I'm sending out versions with and without revision  
> tracking on so you can easily see the parts that changed, but still  
> have a readable version. Let me know how it looks.  Once again, I  
> look forward to
> hearing your thoughts and feedback!
>
> Regards,
> Max Carlson
> OpenLaszlo
>
>
> <database connector spec 11-03-05 norevs.pdf>
> <database connector spec 11-03-05.pdf>
> _______________________________________________
> Laszlo-dev mailing list
> Laszlo-dev at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-dev



More information about the Laszlo-dev mailing list