Skip to content

DevGuide PerlObjects

Violet edited this page Oct 28, 2010 · 1 revision

MDG: Introduction to Custom Objects

Melody offers a robust system for managing application and user defined data. The primary interface to this system is through the base class MT::Object, which all other objects derive from.

Because all objects inherit from the MT::Object base class that means that all objects will automatically support the following features and behaviors:

  • the methods new, load, save, remove and remove_all are defined automatically

  • all objects will be cached in memcached when properly enabled

  • callbacks into the creation and editing of objects are defined

  • support for storage of that object across all supported databases, including mysql, postgres, SQL Server, Oracle and SQLite

  • upgrades and changes to the underlying database schema are completely automated

Melody Objects actually know nothing at all about how they are stored. They simply know about the data they represent. Melody's data abstraction layer takes care of all of the SQL and database specific issues for you.

In Melody, developers never have to write SQL.

Melody's Data Abstraction Layer: What is MT::Object, MT::ObjectDriver and Data::ObjectDriver?

For the geeks out there let us take a quick diversion to give ourselves a little background on Melody's data abstraction layer. This layer is what allows developers to store and retrieve all manner of data to and from the database without ever needing to know or understand SQL. It is also what makes it possible for Melody to automate database upgrades and easily support multiple databases without developers having to grapple with the idiosyncratic differences between them.

There are a number of key classes that make up this framework, they are:

  • MT::Object - the base class from which all other objects derive. Each MT::Object defines the data model for that specific object.

  • MT::ObjectDriver - a thin wrapper around the core underlying data abstraction backend called Data::ObjectDriver. This is maintained for backwards compatibility.

  • Data::ObjectDriver - an open source data abstraction layer for Perl applications. This is where most of the work is done and is what is primarily responsible for converting API calls to SQL statements. It also provides support for memcached and other low level database features like partitioning (a feature planned for a future release).

Learn More

 


Questions, comments, can't find something? Let us know at our community outpost on Get Satisfaction.

Credits

  • Author: Byrne Reese
  • Edited by: Violet Bliss Dietz
Clone this wiki locally