diff --git a/.travis/postgresql_settings.py b/.travis/postgresql_settings.py index 292cb9cc70..c12927af3a 100644 --- a/.travis/postgresql_settings.py +++ b/.travis/postgresql_settings.py @@ -40,7 +40,7 @@ SERVERNAME = "testing_mygame" DATABASES = { "default": { - "ENGINE": "django.db.backends.postgresql_psycopg2", + "ENGINE": "django.db.backends.postgresql", "NAME": "evennia", "USER": "evennia", "PASSWORD": "password", diff --git a/evennia/accounts/accounts.py b/evennia/accounts/accounts.py index f1bc45acf6..f3217e88ea 100644 --- a/evennia/accounts/accounts.py +++ b/evennia/accounts/accounts.py @@ -37,7 +37,7 @@ from evennia.scripts.scripthandler import ScriptHandler from evennia.commands.cmdsethandler import CmdSetHandler from evennia.utils.optionhandler import OptionHandler -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from random import getrandbits __all__ = ("DefaultAccount",) diff --git a/evennia/commands/cmdhandler.py b/evennia/commands/cmdhandler.py index 8ccbcbae93..6f8f247a72 100644 --- a/evennia/commands/cmdhandler.py +++ b/evennia/commands/cmdhandler.py @@ -48,7 +48,7 @@ from evennia.comms.channelhandler import CHANNELHANDLER from evennia.utils import logger, utils from evennia.utils.utils import string_suggestions -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ _IN_GAME_ERRORS = settings.IN_GAME_ERRORS diff --git a/evennia/commands/cmdset.py b/evennia/commands/cmdset.py index 5bb3ec8d28..f124bbbb06 100644 --- a/evennia/commands/cmdset.py +++ b/evennia/commands/cmdset.py @@ -27,7 +27,7 @@ Set theory. """ from weakref import WeakKeyDictionary -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from evennia.utils.utils import inherits_from, is_iter __all__ = ("CmdSet",) diff --git a/evennia/commands/cmdsethandler.py b/evennia/commands/cmdsethandler.py index e855d551e9..395c9c2ba3 100644 --- a/evennia/commands/cmdsethandler.py +++ b/evennia/commands/cmdsethandler.py @@ -72,7 +72,7 @@ from evennia.utils import logger, utils from evennia.commands.cmdset import CmdSet from evennia.server.models import ServerConfig -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ __all__ = ("import_cmdset", "CmdSetHandler") diff --git a/evennia/comms/channelhandler.py b/evennia/comms/channelhandler.py index feea9f6e33..98e28786a0 100644 --- a/evennia/comms/channelhandler.py +++ b/evennia/comms/channelhandler.py @@ -27,7 +27,7 @@ from django.conf import settings from evennia.commands import cmdset, command from evennia.utils.logger import tail_log_file from evennia.utils.utils import class_from_module -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ # we must late-import these since any overloads are likely to # themselves be using these classes leading to a circular import. diff --git a/evennia/locks/lockhandler.py b/evennia/locks/lockhandler.py index 22f5844e31..ac8c85abc8 100644 --- a/evennia/locks/lockhandler.py +++ b/evennia/locks/lockhandler.py @@ -107,7 +107,7 @@ to any other identifier you can use. import re from django.conf import settings from evennia.utils import logger, utils -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ __all__ = ("LockHandler", "LockException") diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index d980b88303..25731923e6 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -31,7 +31,7 @@ from evennia.utils.utils import ( list_to_string, to_str, ) -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ _INFLECT = inflect.engine() _MULTISESSION_MODE = settings.MULTISESSION_MODE diff --git a/evennia/scripts/scripthandler.py b/evennia/scripts/scripthandler.py index d2298a7ce2..d924636f8c 100644 --- a/evennia/scripts/scripthandler.py +++ b/evennia/scripts/scripthandler.py @@ -9,7 +9,7 @@ from evennia.scripts.models import ScriptDB from evennia.utils import create from evennia.utils import logger -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ class ScriptHandler(object): diff --git a/evennia/scripts/scripts.py b/evennia/scripts/scripts.py index 42bb1c8797..2f9bb5d5e2 100644 --- a/evennia/scripts/scripts.py +++ b/evennia/scripts/scripts.py @@ -8,7 +8,7 @@ ability to run timers. from twisted.internet.defer import Deferred, maybeDeferred from twisted.internet.task import LoopingCall from django.core.exceptions import ObjectDoesNotExist -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from evennia.typeclasses.models import TypeclassBase from evennia.scripts.models import ScriptDB from evennia.scripts.manager import ScriptManager diff --git a/evennia/server/deprecations.py b/evennia/server/deprecations.py index 45eefd160b..6cf3ab1af7 100644 --- a/evennia/server/deprecations.py +++ b/evennia/server/deprecations.py @@ -115,3 +115,7 @@ def check_warnings(settings): print(" [Devel: settings.IN_GAME_ERRORS is True. Turn off in production.]") if settings.ALLOWED_HOSTS == ["*"]: print(" [Devel: settings.ALLOWED_HOSTS set to '*' (all). Limit in production.]") + for k,v in settings.DATABASES.items(): + if "psycopg" in v.get("ENGINE",None): + print(" [Devel: postgresql_psycopg2 backend is deprecated. This module is now called postgresql") + print(" Switch settings.DATABASES to use \"ENGINE\": \"django.db.backends.postgresql\"") diff --git a/evennia/server/initial_setup.py b/evennia/server/initial_setup.py index 8f7fd3300f..e0845c0859 100644 --- a/evennia/server/initial_setup.py +++ b/evennia/server/initial_setup.py @@ -9,7 +9,7 @@ Everything starts at handle_setup() import time from django.conf import settings -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from evennia.accounts.models import AccountDB from evennia.server.models import ServerConfig from evennia.utils import create, logger diff --git a/evennia/server/server.py b/evennia/server/server.py index 1c1783bef1..2093b5b88c 100644 --- a/evennia/server/server.py +++ b/evennia/server/server.py @@ -38,7 +38,7 @@ from evennia.utils import logger from evennia.comms import channelhandler from evennia.server.sessionhandler import SESSIONS -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ _SA = object.__setattr__ diff --git a/evennia/server/serversession.py b/evennia/server/serversession.py index 6ae0ec4b63..2443758b12 100644 --- a/evennia/server/serversession.py +++ b/evennia/server/serversession.py @@ -23,7 +23,7 @@ _ObjectDB = None _ANSI = None # i18n -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ # Handlers for Session.db/ndb operation diff --git a/evennia/server/sessionhandler.py b/evennia/server/sessionhandler.py index 1bf43746d6..0d099d6d30 100644 --- a/evennia/server/sessionhandler.py +++ b/evennia/server/sessionhandler.py @@ -67,7 +67,7 @@ PSTATUS = chr(18) # ping server or portal status SRESET = chr(19) # server shutdown in reset mode # i18n -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ _SERVERNAME = settings.SERVERNAME _MULTISESSION_MODE = settings.MULTISESSION_MODE diff --git a/evennia/settings_default.py b/evennia/settings_default.py index b2a06e328e..5ecafb75b5 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -245,7 +245,7 @@ IN_GAME_ERRORS = True # ENGINE - path to the the database backend. Possible choices are: # 'django.db.backends.sqlite3', (default) # 'django.db.backends.mysql', -# 'django.db.backends.postgresql_psycopg2', +# 'django.db.backends.postgresql', # 'django.db.backends.oracle' (untested). # NAME - database name, or path to the db file for sqlite3 # USER - db admin (unused in sqlite3) diff --git a/evennia/typeclasses/migrations/0010_delete_old_player_tables.py b/evennia/typeclasses/migrations/0010_delete_old_player_tables.py index 0732f0fe99..32e1f80923 100644 --- a/evennia/typeclasses/migrations/0010_delete_old_player_tables.py +++ b/evennia/typeclasses/migrations/0010_delete_old_player_tables.py @@ -27,7 +27,7 @@ def _drop_table(db_cursor, table_name): db_cursor.execute("SET FOREIGN_KEY_CHECKS=0;") db_cursor.execute("DROP TABLE {table};".format(table=table_name)) db_cursor.execute("SET FOREIGN_KEY_CHECKS=1;") - elif _ENGINE == "postgresql_psycopg2": + elif _ENGINE == "postgresql": db_cursor.execute("ALTER TABLE {table} DISABLE TRIGGER ALL;".format(table=table_name)) db_cursor.execute("DROP TABLE {table};".format(table=table_name)) db_cursor.execute("ALTER TABLE {table} ENABLE TRIGGER ALL;".format(table=table_name)) diff --git a/evennia/utils/dbserialize.py b/evennia/utils/dbserialize.py index b3e55d1ca6..27fc43e1a1 100644 --- a/evennia/utils/dbserialize.py +++ b/evennia/utils/dbserialize.py @@ -28,11 +28,12 @@ except ImportError: from pickle import dumps, loads from django.core.exceptions import ObjectDoesNotExist from django.contrib.contenttypes.models import ContentType -from django.utils.safestring import SafeString, SafeBytes +from django.utils.safestring import SafeString from evennia.utils.utils import uses_database, is_iter, to_str, to_bytes from evennia.utils import logger -__all__ = ("to_pickle", "from_pickle", "do_pickle", "do_unpickle", "dbserialize", "dbunserialize") +__all__ = ("to_pickle", "from_pickle", "do_pickle", + "do_unpickle", "dbserialize", "dbunserialize") PICKLE_PROTOCOL = 2 @@ -116,13 +117,15 @@ def _init_globals(): global _FROM_MODEL_MAP, _TO_MODEL_MAP, _SESSION_HANDLER, _IGNORE_DATETIME_MODELS if not _FROM_MODEL_MAP: _FROM_MODEL_MAP = defaultdict(str) - _FROM_MODEL_MAP.update(dict((c.model, c.natural_key()) for c in ContentType.objects.all())) + _FROM_MODEL_MAP.update(dict((c.model, c.natural_key()) + for c in ContentType.objects.all())) if not _TO_MODEL_MAP: from django.conf import settings _TO_MODEL_MAP = defaultdict(str) _TO_MODEL_MAP.update( - dict((c.natural_key(), c.model_class()) for c in ContentType.objects.all()) + dict((c.natural_key(), c.model_class()) + for c in ContentType.objects.all()) ) _IGNORE_DATETIME_MODELS = [] for src_key, dst_key in settings.ATTRIBUTE_STORED_MODEL_RENAME: @@ -185,7 +188,8 @@ class _SaverMutable(object): ) self._db_obj.value = self else: - logger.log_err("_SaverMutable %s has no root Attribute to save to." % self) + logger.log_err( + "_SaverMutable %s has no root Attribute to save to." % self) def _convert_mutables(self, data): """converts mutables to Saver* variants and assigns ._parent property""" @@ -201,7 +205,8 @@ class _SaverMutable(object): return dat elif dtype == dict: dat = _SaverDict(_parent=parent) - dat._data.update((key, process_tree(val, dat)) for key, val in item.items()) + dat._data.update((key, process_tree(val, dat)) + for key, val in item.items()) return dat elif dtype == set: dat = _SaverSet(_parent=parent) @@ -549,7 +554,7 @@ def to_pickle(data): def process_item(item): """Recursive processor and identification of data""" dtype = type(item) - if dtype in (str, int, float, bool, bytes, SafeString, SafeBytes): + if dtype in (str, int, float, bool, bytes, SafeString): return item elif dtype == tuple: return tuple(process_item(val) for val in item) @@ -577,7 +582,8 @@ def to_pickle(data): except TypeError: return item except Exception: - logger.log_error(f"The object {item} of type {type(item)} could not be stored.") + logger.log_error( + f"The object {item} of type {type(item)} could not be stored.") raise return process_item(data) @@ -609,7 +615,7 @@ def from_pickle(data, db_obj=None): def process_item(item): """Recursive processor and identification of data""" dtype = type(item) - if dtype in (str, int, float, bool, bytes, SafeString, SafeBytes): + if dtype in (str, int, float, bool, bytes, SafeString): return item elif _IS_PACKED_DBOBJ(item): # this must be checked before tuple @@ -638,7 +644,7 @@ def from_pickle(data, db_obj=None): def process_tree(item, parent): """Recursive processor, building a parent-tree from iterable data""" dtype = type(item) - if dtype in (str, int, float, bool, bytes, SafeString, SafeBytes): + if dtype in (str, int, float, bool, bytes, SafeString): return item elif _IS_PACKED_DBOBJ(item): # this must be checked before tuple diff --git a/evennia/utils/evmenu.py b/evennia/utils/evmenu.py index 0bc5b37475..ccf2840f91 100644 --- a/evennia/utils/evmenu.py +++ b/evennia/utils/evmenu.py @@ -187,7 +187,7 @@ _CMD_NOINPUT = cmdhandler.CMD_NOINPUT # Return messages # i18n -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ _ERR_NOT_IMPLEMENTED = _( "Menu node '{nodename}' is either not implemented or " "caused an error. Make another choice." diff --git a/evennia/utils/picklefield.py b/evennia/utils/picklefield.py index c2b5abb98a..084fc6d638 100644 --- a/evennia/utils/picklefield.py +++ b/evennia/utils/picklefield.py @@ -43,7 +43,7 @@ from django.forms.fields import CharField from django.forms.widgets import Textarea from pickle import loads, dumps -from django.utils.encoding import force_text +from django.utils.encoding import force_str DEFAULT_PROTOCOL = 4 @@ -210,10 +210,10 @@ class PickledObjectField(models.Field): """ Returns the default value for this field. - The default implementation on models.Field calls force_text + The default implementation on models.Field calls force_str on the default, which means you can't set arbitrary Python objects as the default. To fix this, we just return the value - without calling force_text on it. Note that if you set a + without calling force_str on it. Note that if you set a callable as a default, the field will still call it. It will *not* try to pickle and encode it. @@ -267,13 +267,13 @@ class PickledObjectField(models.Field): """ if value is not None and not isinstance(value, PickledObject): - # We call force_text here explicitly, so that the encoded string - # isn't rejected by the postgresql_psycopg2 backend. Alternatively, + # We call force_str here explicitly, so that the encoded string + # isn't rejected by the postgresql backend. Alternatively, # we could have just registered PickledObject with the psycopg # marshaller (telling it to store it like it would a string), but # since both of these methods result in the same value being stored, # doing things this way is much easier. - value = force_text(dbsafe_encode(value, self.compress, self.protocol)) + value = force_str(dbsafe_encode(value, self.compress, self.protocol)) return value def value_to_string(self, obj): diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index 49c8af1e7b..cc191fdd53 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -27,7 +27,7 @@ from collections import defaultdict, OrderedDict from twisted.internet import threads, reactor from django.conf import settings from django.utils import timezone -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.apps import apps from evennia.utils import logger @@ -1036,7 +1036,7 @@ def uses_database(name="sqlite3"): shortcut to having to use the full backend name. Args: - name (str): One of 'sqlite3', 'mysql', 'postgresql_psycopg2' + name (str): One of 'sqlite3', 'mysql', 'postgresql' or 'oracle'. Returns: diff --git a/evennia/web/urls.py b/evennia/web/urls.py index 6d9e28f6df..22db55cde6 100644 --- a/evennia/web/urls.py +++ b/evennia/web/urls.py @@ -6,7 +6,7 @@ # http://diveintopython.org/regular_expressions/street_addresses.html#re.matching.2.3 # -from django.conf.urls import url, include +from django.urls import path, include from django.views.generic import RedirectView # Setup the root url tree from / @@ -14,9 +14,10 @@ from django.views.generic import RedirectView urlpatterns = [ # Front page (note that we shouldn't specify namespace here since we will # not be able to load django-auth/admin stuff (will probably work in Django>1.9) - url(r"^", include("evennia.web.website.urls")), # , namespace='website', app_name='website')), + path("", include("evennia.web.website.urls")), # webclient - url(r"^webclient/", include("evennia.web.webclient.urls", namespace="webclient")), + path("webclient/", include("evennia.web.webclient.urls")), # favicon - url(r"^favicon\.ico$", RedirectView.as_view(url="/media/images/favicon.ico", permanent=False)), + path("favicon.ico", RedirectView.as_view( + url="/media/images/favicon.ico", permanent=False)) ] diff --git a/evennia/web/webclient/templates/webclient/base.html b/evennia/web/webclient/templates/webclient/base.html index 46353b18ad..e65467da12 100644 --- a/evennia/web/webclient/templates/webclient/base.html +++ b/evennia/web/webclient/templates/webclient/base.html @@ -6,7 +6,7 @@ with evennia set up automatically and get the Evennia JS lib and JQuery available. --> -{% load staticfiles %} +{% load static %} {{game_name}} diff --git a/evennia/web/webclient/urls.py b/evennia/web/webclient/urls.py index cfb57ad262..4b9d19d631 100644 --- a/evennia/web/webclient/urls.py +++ b/evennia/web/webclient/urls.py @@ -2,8 +2,9 @@ This structures the (simple) structure of the webpage 'application'. """ -from django.conf.urls import * +from django.urls import path from evennia.web.webclient import views as webclient_views app_name = "webclient" -urlpatterns = [url(r"^$", webclient_views.webclient, name="index")] + +urlpatterns = [path("", webclient_views.webclient, name="index")] diff --git a/evennia/web/website/templates/website/_menu.html b/evennia/web/website/templates/website/_menu.html index a947445167..3d6501fb45 100644 --- a/evennia/web/website/templates/website/_menu.html +++ b/evennia/web/website/templates/website/_menu.html @@ -3,7 +3,7 @@ Allow to customize the menu that appears at the top of every Evennia webpage. Copy this file to your game dir's web/template_overrides/website folder and edit it to add/remove links to the menu. {% endcomment %} -{% load staticfiles %} +{% load static %}