[Helma-user] [Helma-dev] Announcing Rabbit

tobias.schaefer at orf.at tobias.schaefer at orf.at
Tue Oct 3 20:15:10 CEST 2006


hi maksim

> I've quickly tried out the instructions on your blog entry and
> successfully got the example app created with the "number,file,text"
> form but still not quite sure what allthe functionality of Rabbit is. I
> guess I'l start going through your code, but if you get a chance to
> quikly wwrite up some instructions or quick demo of hwo to use it that
> would be great.

ok, for a start, here's a short summary of features:

1.) registering prototypes

the method registerPrototype() takes two arguments, the name of the prototype as string and its type properties as vanilla object:

registerPrototype("Item", {
   _parent: "root",
   text: TEXT,
   file: FILE,
   number: NUMBER
});

the above call, as executed in the example, creates the prototype directory Item and a corresponding table T_ITEM in the hsqldb. (db.properties are generated as well.)

it also adds the type.properties file with the following mappings (which could be written in some more meaningful order):

text = ITEM_TEXT
_id = ITEM_ID
rabbit = mountpoint(PropertyMgr)
_db = test
number = ITEM_NUMBER
_parent = root
file = ITEM_FILE
rabbit_xml = ITEM_RABBIT_XML
_table = T_ITEM

finally, it also adds the necessary database columns to the T_ITEM table by transforming the constants TEXT, FILE and NUMBER into valid sql types and executing the resulting sql statement.

2.) resetting protoypes

to start from scratch, resetPrototypes() drops one or more database tables, depending on the amount of arguments. if no argument is given all database tables created via registerPrototype() will be dropped. of course, this will not remove any prototype directories, since they could contain user-generated files not under rabbit's control.

3.) actions for creating and editing

HopObjects can be created via a form accessible from a special URL, e.g.

http://localhost:8080/appname/+Item

displays the form to create a new Item object. after submit, the newly created object will be added to a collection of the parent object as given in the URL path. (in this case it is the default _children collection of Root)

other (hypothetical) URLs follow this scheme, e.g. you also can display the create form via the URL of a previously created Item object:

http://localhost:8080/appname/3/+Item

but be aware that you still have to take care about your object mapping; if Item objects cannot contain other Item objects in a given collection, the addition will fail.

4.) form elements reflect property types

the visual appearance of each form element depends on the type as set in the registerPrototype() call. it is determined by the constants TEXT, FILE, NUMBER. (there's also support for DATE but i am not yet happy with it.)

5.) database columns reflect property types

the types of database columns, too, are set to sql attributes equivalent to the property types (e.g. DATE becomes "timestamp", TEXT "varchar").

6.) special actions for uploaded content

binary content can be stored completely in one object field, no need to map the property to an extra File object or create a relational T_FILE table. 

however, this needed special URL treatment. thus, properties containing files, images and the like can be accessed via a special URL:

http://localhost:8080/appname/5/.file

it's always a period followed by the property's name.

to avoid annoyances with file naming restrictions and provide better portability i decided to put binary content inside the database and not as extra files. i currently base64-encode the binary data and save this in a longvarchar column because i was not able to convince helma to convert a byte[] array for writing it into a binary column...

7.) snippet rendering

rabbit registers a global method called render() which makes use of an extended syntax for rendering only parts of a skin. i described the basics of this method already in the wiki [1].

inside this little snippet rendering engine there's also a (i think) very cool solution to the render/renderAsString dualism. but i have to stop now and will write about this and some more details a little bit later.

ciao,
tobi
 
--
[1] http://dev.helma.org/Wiki/JS-based+implementation+of+snippets+%28aka+subskins%29/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://helma.org/pipermail/helma-user/attachments/20061003/c2c4848c/attachment-0001.html 


More information about the Helma-user mailing list