[development] object.module (was nodify.module idea: 'everything is a node')

Nedjo Rogers nedjo at islandnet.com
Sun Jan 21 00:42:53 UTC 2007

Dries wrote:

> there might be room for a light-weight container object,  that both nodes, 
> comments, users and taxonomies extend from.

Agreed, this is a much more promising approach than what I outlined--and 
proof once again that some quick, sound advice from the dev list can save a 
lot of useless coding :)

So I'm seeing two stages to implementing this.

1. Write a generic object.inc or object.module. Maybe this has two tables of 
its own:

CREATE TABLE {object} (
  oid int unsigned NOT NULL auto_increment,
  type_id int unsigned NOT NULL default '0',
  PRIMARY KEY  (oid, type_id),
  UNIQUE KEY oid (vid),
  KEY nid (type_id)

CREATE TABLE {object_type} (
  type_id int unsigned NOT NULL auto_increment,
  name varchar(32) NOT NULL default '',
  PRIMARY KEY  (type_id),

with some initial values default for the object types:

INSERT INTO {object_type} (
  values (1, 'node'), (2, 'user'), (3, 'comment'), (4, 'vocabulary'), (5, 

Every object is now uniquely identified not by a single id but by two: the 
object id and the object type id. Modules can register their own custom 
object_types. Possibly other core drupal objects also register: files, 

object.module or object.inc has methods similar to our current ones: 
object_load(), object_save(), object_delete(), and uses a hook_object() 
similar to our current hook_nodeapi(), hook_user, and hook_taxonomy() set. 
The object methods call any implementations specific to the type. E.g., 
object_load() invokes a function $object_type->name .'_load'.

2. Having reworked our existing object handling to extend a base object, we 
then look one by one at the systems currently specific to nodes and consider 
attaching them to the base object instead, so that they still apply to nodes 
but are also applicable to other object types. E.g.:

* node_access table becomes object_access, and gains a field, type_id 
(object type).
* Current nodeapi modules could be optionally rewritten as hook_object 
implementations, so that they can attach their behaviours to any object 
* Possibly, node_revisions becomes object_revisions.

Does this sound right? Doable? For 6.0? 

More information about the development mailing list