Use with_metaclass from future.utils for python3 compat.
This commit is contained in:
parent
79437c0e48
commit
8a66fc40a9
11 changed files with 21 additions and 26 deletions
|
|
@ -16,6 +16,7 @@ user.
|
|||
import re
|
||||
from evennia.utils import utils
|
||||
from evennia.utils.utils import to_str, to_unicode
|
||||
from future.utils import with_metaclass
|
||||
|
||||
# ANSI definitions
|
||||
|
||||
|
|
@ -555,7 +556,7 @@ class ANSIMeta(type):
|
|||
super(ANSIMeta, cls).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class ANSIString(unicode):
|
||||
class ANSIString(with_metaclass(ANSIMeta, unicode)):
|
||||
"""
|
||||
String-like object that is aware of ANSI codes.
|
||||
|
||||
|
|
@ -572,7 +573,6 @@ class ANSIString(unicode):
|
|||
for several of the methods that need not be defined directly here.
|
||||
|
||||
"""
|
||||
__metaclass__ = ANSIMeta
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ from evennia.utils import logger
|
|||
from evennia.utils.utils import dbref, get_evennia_pids, to_str
|
||||
|
||||
from .manager import SharedMemoryManager
|
||||
from future.utils import with_metaclass
|
||||
|
||||
AUTO_FLUSH_MIN_INTERVAL = 60.0 * 5 # at least 5 mins between cache flushes
|
||||
|
||||
|
|
@ -200,13 +201,10 @@ class SharedMemoryModelBase(ModelBase):
|
|||
return super(SharedMemoryModelBase, cls).__new__(cls, name, bases, attrs)
|
||||
|
||||
|
||||
class SharedMemoryModel(Model):
|
||||
class SharedMemoryModel(with_metaclass(SharedMemoryModelBase, Model)):
|
||||
"""
|
||||
Base class for idmapped objects. Inherit from `this`.
|
||||
"""
|
||||
# CL: setting abstract correctly to allow subclasses to inherit the default
|
||||
# manager.
|
||||
__metaclass__ = SharedMemoryModelBase
|
||||
|
||||
objects = SharedMemoryManager()
|
||||
|
||||
|
|
@ -415,12 +413,11 @@ class WeakSharedMemoryModelBase(SharedMemoryModelBase):
|
|||
cls._idmapper_recache_protection = False
|
||||
|
||||
|
||||
class WeakSharedMemoryModel(SharedMemoryModel):
|
||||
class WeakSharedMemoryModel(with_metaclass(WeakSharedMemoryModelBase, SharedMemoryModel)):
|
||||
"""
|
||||
Uses a WeakValue dictionary for caching instead of a regular one
|
||||
|
||||
"""
|
||||
__metaclass__ = WeakSharedMemoryModelBase
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ from django.forms.util import flatatt
|
|||
from django.utils.html import format_html
|
||||
|
||||
from evennia.utils.dbserialize import from_pickle, to_pickle
|
||||
from future.utils import with_metaclass
|
||||
|
||||
try:
|
||||
from django.utils.encoding import force_text
|
||||
|
|
@ -167,7 +168,7 @@ class PickledFormField(CharField):
|
|||
raise ValidationError(self.error_messages['invalid'])
|
||||
|
||||
|
||||
class PickledObjectField(_get_subfield_superclass()):
|
||||
class PickledObjectField(with_metaclass(models.SubfieldBase, _get_subfield_superclass())):
|
||||
"""
|
||||
A field that will accept *any* python object and store it in the
|
||||
database. PickledObjectField will optionally compress its values if
|
||||
|
|
@ -177,7 +178,6 @@ class PickledObjectField(_get_subfield_superclass()):
|
|||
can still do lookups using None). This way, it is still possible to
|
||||
use the ``isnull`` lookup type correctly.
|
||||
"""
|
||||
__metaclass__ = models.SubfieldBase # for django < 1.3
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.compress = kwargs.pop('compress', False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue