I've been beating my head against the wall trying to figure out how to
append any class to a class. Below is a simple model...
class Resource(Entity):
has_field('name', Unicode)
has_and_belongs_to_many('children', of_kind='Resource',
enable_typechecks=False)
has_and_belongs_to_many('parents', of_kind='Resource',
enable_typechecks=False)
has_one('metaclass', of_kind='MetaClass', enable_typechecks=False)
def __repr__(self):
return '<Resource name="%s">' % self.name
class MetaClass(Entity):
belongs_to('resource', of_kind='Resource')
class File(Entity):
has_field('filename', Unicode)
has_field('hash', String(32))
belongs_to('resource', of_kind='Resource', inverse='asset')
def __repr__(self):
return '<File filename="%s">' % (self.filename)
When I create a resource and append File object to it, it seems to
work just fine, but the flush apparently fails silently -- both
objects get created, but their association goes away...
r=Resource(name='testresource')
r.metaclass=File(filename='yadayada')
r.flush()
Am I missing something? Am I going about this all the wrong way? What
I'm trying to do is create a simple tree of Resource objects that can
have any class assigned to them so someone could write an extension
class with a different definition. What's the best way to go about
writing an Elixir model for extensibility?
Thanks for any information...
Dean
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---