From 4e0b5be962e3fbecf607792c8d827fdf0f1c9b09 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 20 Dec 2014 19:29:38 +0100 Subject: [PATCH] Fixed creation. Time to start cleaning the .dbobj hierarchy. --- src/objects/objects.py | 4 ++-- src/players/player.py | 4 ++-- src/scripts/scripts.py | 4 ++-- src/typeclasses/models.py | 5 +++++ src/utils/idmapper/base.py | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/objects/objects.py b/src/objects/objects.py index 3c41841559..cb43ee9609 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -41,7 +41,7 @@ class Object(ObjectDB): __metaclass__ = TypeclassBase # __init__ is only defined here in order to present docstring to API. - def __init__(self): + def __init__(self, *args, **kwargs): """ This is the root typeclass object, representing all entities that have an actual presence in-game. Objects generally have a @@ -192,7 +192,7 @@ class Object(ObjectDB): this object speaks """ - super(Object, self).__init__() + super(Object, self).__init__(*args, **kwargs) ## methods inherited from the database object (overload them here) diff --git a/src/players/player.py b/src/players/player.py index d799810713..039b5dfba1 100644 --- a/src/players/player.py +++ b/src/players/player.py @@ -29,7 +29,7 @@ class Player(PlayerDB): """ __metaclass__ = TypeclassBase - def __init__(self): + def __init__(self, *args, **kwargs): """ This is the base Typeclass for all Players. Players represent the person playing the game and tracks account info, password @@ -103,7 +103,7 @@ class Player(PlayerDB): at_server_shutdown() """ - super(Player, self).__init__() + super(Player, self).__init__(*args, **kwargs) ## methods inherited from database model diff --git a/src/scripts/scripts.py b/src/scripts/scripts.py index 9454e80922..4aa289481e 100644 --- a/src/scripts/scripts.py +++ b/src/scripts/scripts.py @@ -354,7 +354,7 @@ class Script(ScriptBase): the hooks called by the script machinery. """ - def __init__(self): + def __init__(self, *args, **kwargs): """ This is the base TypeClass for all Scripts. Scripts describe events, timers and states in game, they can have a time component or describe @@ -441,7 +441,7 @@ class Script(ScriptBase): """ - super(Script, self).__init__() + super(Script, self).__init__(*args, **kwargs) def at_script_creation(self): """ diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index 46cb0d76cc..ed077006c9 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -764,11 +764,16 @@ class TypeclassBase(SharedMemoryModelBase): Metaclass which should be set for the root of model proxies that don't define any new fields, like Object, Script etc. """ + def __new__(cls, name, bases, attrs): """ We must define our Typeclasses as proxies. We also store the path directly on the class, this is useful for managers. """ + + attrs["typename"] = cls.__name__ + attrs["path"] = "%s.%s" % (attrs["__module__"], name) + # typeclass proxy setup if "Meta" in attrs: attrs["Meta"].proxy = True diff --git a/src/utils/idmapper/base.py b/src/utils/idmapper/base.py index a0931962e7..c67fb218ae 100755 --- a/src/utils/idmapper/base.py +++ b/src/utils/idmapper/base.py @@ -82,8 +82,8 @@ class SharedMemoryModelBase(ModelBase): document this auto-wrapping in the class header, this could seem very much like magic to the user otherwise. """ - attrs["typename"] = cls.__name__ - attrs["path"] = "%s.%s" % (attrs["__module__"], name) + #attrs["typename"] = cls.__name__ + #attrs["path"] = "%s.%s" % (attrs["__module__"], name) # set up the typeclass handling only if a variable _is_typeclass is set on the class def create_wrapper(cls, fieldname, wrappername, editable=True, foreignkey=False):