More flexibility for Midgard schemas
Posted on 2009-10-08 15:36:30 EEST.
Here it is. Well known Midgard MgdSchema is no longer such strict and limited. Since [Mjolnir][2] we will support user defined values which can extend class property even better. Till now, we supported only 'description' keyword, which allowed to add any text which could describe property.
Defining own values is plain and simple:
<type name "my_best_class" table="my_best_class_tbl">
<property name="superproperty" type="string" field="super_property">
<foo>bar</foo>
<private>true</private>
</property>
</type>
Now, with API calls, one is able to get it quickly:
C:
MidgardObjectClass *klass = g_type_class_peek (g_type_from_name ("my_best_class"));
MidgardReflectionProperty *mrp = midgard_reflection_property_new (mgd, klass);
midgard_reflection_property_get_user_value (mrp, "superproperty", "private");
Python:
mrp = midgard.reflection_property ("my_best_class")
print mrp.get_user_value ("superproperty", "private")
or even PHP:
$mrp = new midgard_reflection_property ("my_best_class");
echo $mrp->get_user_value ("superproperty", "private");
Note, that I used private key by purpose. If you are developing Midgard derived application and you need some functionality which can be defined in schema (but it's not yet), or work on such functionality is in progress, and you need to make your application be aware of this (quickly), you can depend on self added values.