mirror of
https://github.com/evennia/evennia.git
synced 2026-04-17 21:59:06 +02:00
Now solving issues with faulty imports. Still nothing functional.
This commit is contained in:
parent
08d0442f9c
commit
8314d8ba5e
8 changed files with 77 additions and 37 deletions
|
|
@ -14,7 +14,19 @@ class Channel(ChannelDB):
|
|||
This is the base class for all Comms. Inherit from this to create different
|
||||
types of communication channels.
|
||||
"""
|
||||
__metaclass__ = TypeclassBase
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""
|
||||
We must define our Typeclasses as proxies. We also store the path
|
||||
directly on the class, this is useful for managers.
|
||||
"""
|
||||
if hasattr(cls, "Meta"):
|
||||
cls.Meta.proxy = True
|
||||
else:
|
||||
class Meta:
|
||||
proxy = True
|
||||
cls.Meta = Meta
|
||||
return super(TypeclassBase, cls).__new__(*args, **kwargs)
|
||||
|
||||
# helper methods, for easy overloading
|
||||
|
||||
|
|
|
|||
|
|
@ -37,9 +37,21 @@ class Object(ObjectDB):
|
|||
This is the base class for all in-game objects. Inherit from this
|
||||
to create different types of objects in the game.
|
||||
"""
|
||||
__metaclass__ = TypeclassBase
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""
|
||||
We must define our Typeclasses as proxies. We also store the path
|
||||
directly on the class, this is useful for managers.
|
||||
"""
|
||||
if hasattr(cls, "Meta"):
|
||||
cls.Meta.proxy = True
|
||||
else:
|
||||
class Meta:
|
||||
proxy = True
|
||||
cls.Meta = Meta
|
||||
return super(Object, cls).__new__(*args, **kwargs)
|
||||
|
||||
# __init__ is only defined here in order to present docstring to API.
|
||||
def __init__(self, dbobj):
|
||||
def __init__(self):
|
||||
"""
|
||||
This is the root typeclass object, representing all entities
|
||||
that have an actual presence in-game. Objects generally have a
|
||||
|
|
@ -190,7 +202,7 @@ class Object(ObjectDB):
|
|||
this object speaks
|
||||
|
||||
"""
|
||||
super(Object, self).__init__(dbobj)
|
||||
super(Object, self).__init__()
|
||||
|
||||
## methods inherited from the database object (overload them here)
|
||||
|
||||
|
|
|
|||
|
|
@ -162,11 +162,6 @@ class PlayerDB(TypedObject, AbstractUser):
|
|||
_GA(self, "save")()
|
||||
cmdset_storage = property(cmdset_storage_get, cmdset_storage_set, cmdset_storage_del)
|
||||
|
||||
class Meta:
|
||||
"Define Django meta options"
|
||||
verbose_name = "Player"
|
||||
verbose_name_plural = "Players"
|
||||
|
||||
#
|
||||
# PlayerDB main class properties and methods
|
||||
#
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ instead for most things).
|
|||
import datetime
|
||||
from django.conf import settings
|
||||
from src.players.models import PlayerDB
|
||||
from src.typeclasses.models import TypeclassBase
|
||||
from src.comms.models import ChannelDB
|
||||
from src.utils import logger
|
||||
__all__ = ("Player",)
|
||||
|
|
@ -28,9 +27,20 @@ class Player(PlayerDB):
|
|||
"""
|
||||
Base typeclass for all Players.
|
||||
"""
|
||||
__metaclass__ = TypeclassBase
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""
|
||||
We must define our Typeclasses as proxies. We also store the path
|
||||
directly on the class, this is useful for managers.
|
||||
"""
|
||||
if hasattr(cls, "Meta"):
|
||||
cls.Meta.proxy = True
|
||||
else:
|
||||
class Meta:
|
||||
proxy = True
|
||||
cls.Meta = Meta
|
||||
return super(Player, cls).__new__(*args, **kwargs)
|
||||
|
||||
def __init__(self, dbobj):
|
||||
def __init__(self):
|
||||
"""
|
||||
This is the base Typeclass for all Players. Players represent
|
||||
the person playing the game and tracks account info, password
|
||||
|
|
@ -104,7 +114,7 @@ class Player(PlayerDB):
|
|||
at_server_shutdown()
|
||||
|
||||
"""
|
||||
super(Player, self).__init__(dbobj)
|
||||
super(Player, self).__init__()
|
||||
|
||||
## methods inherited from database model
|
||||
|
||||
|
|
|
|||
|
|
@ -113,9 +113,22 @@ class ScriptBase(ScriptDB):
|
|||
Base class for scripts. Don't inherit from this, inherit
|
||||
from the class 'Script' instead.
|
||||
"""
|
||||
__metaclass__ = TypeclassBase
|
||||
#__metaclass__ = TypeclassBase
|
||||
# private methods
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""
|
||||
We must define our Typeclasses as proxies. We also store the path
|
||||
directly on the class, this is useful for managers.
|
||||
"""
|
||||
if hasattr(cls, "Meta"):
|
||||
cls.Meta.proxy = True
|
||||
else:
|
||||
class Meta:
|
||||
proxy = True
|
||||
cls.Meta = Meta
|
||||
return super(ScriptBase, cls).__new__(*args, **kwargs)
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
This has to be located at this level, having it in the
|
||||
|
|
@ -355,7 +368,7 @@ class Script(ScriptBase):
|
|||
the hooks called by the script machinery.
|
||||
"""
|
||||
|
||||
def __init__(self, dbobj):
|
||||
def __init__(self):
|
||||
"""
|
||||
This is the base TypeClass for all Scripts. Scripts describe events,
|
||||
timers and states in game, they can have a time component or describe
|
||||
|
|
@ -442,7 +455,7 @@ class Script(ScriptBase):
|
|||
|
||||
|
||||
"""
|
||||
super(Script, self).__init__(dbobj)
|
||||
super(Script, self).__init__()
|
||||
|
||||
def at_script_creation(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from django.db.models import Q
|
|||
from src.utils import idmapper
|
||||
from src.utils.utils import make_iter, variable_from_module
|
||||
|
||||
__all__ = ("AttributeManager", "TypedObjectManager")
|
||||
__all__ = ("TypedObjectManager", )
|
||||
_GA = object.__getattribute__
|
||||
_Tag = None
|
||||
|
||||
|
|
|
|||
|
|
@ -742,24 +742,23 @@ class PermissionHandler(TagHandler):
|
|||
# imported for access by other
|
||||
from src.utils.idmapper.base import SharedMemoryModelBase
|
||||
|
||||
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 __init__(cls, *args, **kwargs):
|
||||
"""
|
||||
We must define our Typeclasses as proxies. We also store the path
|
||||
directly on the class, this is useful for managers.
|
||||
"""
|
||||
super(TypeclassBase, cls).__init__(*args, **kwargs)
|
||||
class Meta:
|
||||
# this is the important bit
|
||||
proxy = True
|
||||
cls.Meta = Meta
|
||||
# convenience for manager methods
|
||||
#cls.typename = cls.__name__
|
||||
#cls.path = "%s.%s" % (cls.__module__, cls.__name__)
|
||||
#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.
|
||||
# """
|
||||
# if hasattr(cls, "Meta"):
|
||||
# cls.Meta.proxy = True
|
||||
# else:
|
||||
# class Meta:
|
||||
# proxy = True
|
||||
# cls.Meta = Meta
|
||||
# return super(TypeclassBase, cls).__new__(name, bases, attrs)
|
||||
|
||||
|
||||
class TypedObject(SharedMemoryModel):
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ class SharedMemoryModelBase(ModelBase):
|
|||
already has a wrapper of the given name, the automatic creation is skipped. Note: Remember to
|
||||
document this auto-wrapping in the class header, this could seem very much like magic to the user otherwise.
|
||||
"""
|
||||
|
||||
def create_wrapper(cls, fieldname, wrappername, editable=True, foreignkey=False):
|
||||
"Helper method to create property wrappers with unique names (must be in separate call)"
|
||||
def _get(cls, fname):
|
||||
|
|
@ -190,7 +189,6 @@ class SharedMemoryModelBase(ModelBase):
|
|||
#print "wrapping %s -> %s" % (fieldname, wrappername)
|
||||
create_wrapper(cls, fieldname, wrappername, editable=field.editable, foreignkey=foreignkey)
|
||||
|
||||
|
||||
# django patch
|
||||
# Evennia mod, based on Django Ticket #11560: https://code.djangoproject.com/ticket/11560
|
||||
# The actual patch is small and further down.
|
||||
|
|
@ -432,6 +430,7 @@ class SharedMemoryModelBase(ModelBase):
|
|||
super(SharedMemoryModelBase, cls).__init__(*args, **kwargs)
|
||||
cls.typename = cls.__name__
|
||||
cls.path = "%s.%s" % (cls.__module__, cls.__name__)
|
||||
print "shared __init__", cls
|
||||
|
||||
class SharedMemoryModel(Model):
|
||||
# CL: setting abstract correctly to allow subclasses to inherit the default
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue