|
From: Alex B. <en...@tu...> - 2001-08-21 01:39:46
|
hi all,
have a look at the attachment, I've made some revisions to the declaration
xml for the entity.
you'll notice some 'major' changes, in particular:
<!--
the manager which should be imported by EntityManager.
the role of an individual Entity Manager is to check
the data before a post to the DB happens. It allows
developers to write complex rules for an entity into
a class.
-->
<entity:manager>FurbeesManager<entity:manager>
I think that explains it: basically a class that will house complex rules
(inter-field relationships) for an entity. Not necessary in most cases, so
it's optional.
I've changed the field definition, it's more simple now because some things
have been 'moved out':
<field>
<!-- the field name -->
<name>furbee_id</name>
<!-- the field label, or "full name" -->
<label>Furbee ID</label>
<!-- the description of the field -->
<desc>Unique ID for ever Furbee</desc>
<!-- the path in the entity -->
<path>furbee_id</path>
<!-- must this field be valid to do a post of this entity? -->
<required>true</required>
<!-- is this the default field in the db table? -->
<default>0</default>
<!-- can the field be null? -->
<notnull>1</notnull>
*** note that 'type' is no longer an array, but is now just the <dbtype> tag
renamed.
<!-- what is the simple, 'database' type of this field? -->
<type>int</type>
<!-- the maximum number of chars allowed in input fields and posts -->
<maxlength>20</maxlength>
<!--
should whitespace be trimmed from the
input before it is validated and processed?
-->
<trim>true</trim>
<!-- a regex pattern which will be run against input -->
<format>/[\s\w_\-\.]{1,20}/</format>
*** hopefully this is clear: processor classes will be passed field
contents, and return the contents of that field after running it through
some conditioning code.
<!--
Processors are classes which will contidion the input somehow.
In this example, the class CharEntitiesProcessor would be
imported by EntityManager and passed the input for this field.
It would return the input run through htmlspecialchars() or maybe
a custom method for encoding xml/html character entities.
-->
<processors>
<processor>CharEntitiesProcessor</processor>
</processors>
*** Validators allow devs to write complex application specific validation
classes for input, and allow "us" (binarycloud core) to build a complete set
of simple 'normal' validators for things like email addresses, phone
numbers, dates, etc. A lot of that code exists already, of course.
<!--
Validators are classes which are imported by entityManager
as requested and run again input. There will be a default
set of validators like EmailValidator, DNASequenceValidator, etc.
These validators will be passed the input of the post in the
sequence they are declared. Each validator will be run against
the input, and return true or false. If false, entitymanager will
return an error.
-->
<validators>
<validator>FASTA_DNASequenceValidator</validator>
<validator>NoTagsValidator</validator>
</validators>
<!--
This is the UI control that will be used by the FormBuilder class
as a default. In this case, an <input type="text" size="20"> would
result.
-->
<uicontrol>
<name>TextField</name>
<params>
<size>20</size>
</params>
</uicontrol>
</field>
I'm liking this now because it has a nice set of default 'simple' validation
rules (maxlength, trim, regex, etc) and plugs for validation of any
complexity in the form of classes. That combined with 'processors' I think
makes this as flexible as it needs to be.
Now's the time for suggestions/comments/flames/rants/etc :)
best,
_alex
--
alex black, ceo
en...@tu...
the turing studio, inc.
http://www.turingstudio.com
vox+510.666.0074
fax+510.666.0093
|