Open Source Content Management Framework

mRFC 0040: Extending MgdSchema classes

  1. Revision history
  2. Background
  3. Extending MgdSchema classes
  4. Copy from MgdSchema classes
  5. Name uniqueness

Extending MgdSchema classes

Revision history

  • 2009-05-04 created by Piotr Pokora

Background

Midgard core shall provide possibility to extend existing and already declared MgdSchema classes or copy their data. Two most important cases shall be taken into account in core's implementation:

  • Extending MgdSchema classes
  • Copy from Mgdschema classes

In this mRFC, Extending or copy MgdSchema class means extending class' on database storage layer.

Extending MgdSchema classes

Extending shall be declared in MgdSchema file with reserved word 'extends'.

<type name="my_note" extends="my_document">

Such inheritance shall add parent's properties to derived type without any need to define them for new type explicitly. Parent's (from which new class extend) properties shall be shared between classes and used as the same storage fields on database layer. In this case, Midgard core shall not make database fields (and especially guids or any other object identifiers) distinction. This should be covered by application which depends on MgdSchema extended classes. Also database integrity (used for replication for example) should be resolved on application level. Metadata shall be shared between classes. In other words, object's property (database field) shall be accessible from parent's class and derived class instance.

TODO: Should we allow multiple child classes?

Copy from MgdSchema classes

Copying shall be declared in MgdSchema file with reserved word 'copy'.

<type name="my_note" copy="my_document">

In such case, a deep copy shall be made. Midgard core shall register parent's properties, exactly the same way as they were declared explicitly in MgdSchema file. There shall be no shared properties available and copied properties shall have own fields created in child's class storage.

Name uniqueness

Properties' name uniqueness shall be implemented explicitly, which means there shall be no implicit or magic implementation which allow to overwrite property being already registered. Any duplicated property name shall be considered an application error.

Back

Designed by Nemein, hosted by Kafit