Added a fix for running with postgresql-psycopg2. This does not actually resolve the problem as much as circumvent it, so I'm not marking Issue 115 as closed just yet.
This commit is contained in:
parent
f15e26c54a
commit
9e2ad59663
5 changed files with 48 additions and 24 deletions
|
|
@ -242,7 +242,6 @@ class CmdBatchCommands(MuxCommand):
|
||||||
show_curr(caller)
|
show_curr(caller)
|
||||||
else:
|
else:
|
||||||
caller.msg("Running Batch-command processor - Automatic mode for %s (this might take some time) ..." % python_path)
|
caller.msg("Running Batch-command processor - Automatic mode for %s (this might take some time) ..." % python_path)
|
||||||
|
|
||||||
# add the 'safety' cmdset in case the batch processing adds cmdsets to us
|
# add the 'safety' cmdset in case the batch processing adds cmdsets to us
|
||||||
for inum in range(len(commands)):
|
for inum in range(len(commands)):
|
||||||
# loop through the batch file
|
# loop through the batch file
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ def returns_player_list(method):
|
||||||
# there is a 1-1 relation between Users-Players, so we
|
# there is a 1-1 relation between Users-Players, so we
|
||||||
# try to go the other way instead.
|
# try to go the other way instead.
|
||||||
from src.players.models import PlayerDB
|
from src.players.models import PlayerDB
|
||||||
match = PlayerDB.objects.filter(user=user)
|
match = PlayerDB.objects.filter(user__id=user.id)
|
||||||
if match:
|
if match:
|
||||||
players.append(match[0])
|
players.append(match[0])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ other things.
|
||||||
Everything starts at handle_setup()
|
Everything starts at handle_setup()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import django
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core import management
|
from django.core import management
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
@ -84,6 +85,7 @@ def create_objects():
|
||||||
if not god_character.home:
|
if not god_character.home:
|
||||||
god_character.home = limbo_obj
|
god_character.home = limbo_obj
|
||||||
|
|
||||||
|
|
||||||
def create_channels():
|
def create_channels():
|
||||||
"""
|
"""
|
||||||
Creates some sensible default channels.
|
Creates some sensible default channels.
|
||||||
|
|
@ -91,14 +93,32 @@ def create_channels():
|
||||||
print " Creating default channels ..."
|
print " Creating default channels ..."
|
||||||
|
|
||||||
# public channel
|
# public channel
|
||||||
key, aliases, desc, locks = settings.CHANNEL_PUBLIC
|
key1, aliases, desc, locks = settings.CHANNEL_PUBLIC
|
||||||
pchan = create.create_channel(key, aliases, desc, locks=locks)
|
pchan = create.create_channel(key1, aliases, desc, locks=locks)
|
||||||
# mudinfo channel
|
# mudinfo channel
|
||||||
key, aliases, desc, locks = settings.CHANNEL_MUDINFO
|
key2, aliases, desc, locks = settings.CHANNEL_MUDINFO
|
||||||
ichan = create.create_channel(key, aliases, desc, locks=locks)
|
ichan = create.create_channel(key2, aliases, desc, locks=locks)
|
||||||
# connectinfo channel
|
# connectinfo channel
|
||||||
key, aliases, desc, locks = settings.CHANNEL_CONNECTINFO
|
key3, aliases, desc, locks = settings.CHANNEL_CONNECTINFO
|
||||||
cchan = create.create_channel(key, aliases, desc, locks=locks)
|
cchan = create.create_channel(key3, aliases, desc, locks=locks)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: postgresql-psycopg2 has a strange error when trying to connect the user
|
||||||
|
# to the default channels. It works fine from inside the game, but not from
|
||||||
|
# the initial startup. We are temporarily bypassing the problem with the following
|
||||||
|
# fix. See Evennia Issue 151.
|
||||||
|
if ((".".join(str(i) for i in django.VERSION) < "1.2" and settings.DATABASE_ENGINE == "postgresql_psycopg2")
|
||||||
|
or (hasattr(settings, 'DATABASES')
|
||||||
|
and settings.DATABASES.get("default", {}).get('ENGINE', None)
|
||||||
|
== 'django.db.backends.postgresql_psycopg2')):
|
||||||
|
warning = """
|
||||||
|
PostgreSQL-psycopg2 compatability fix:
|
||||||
|
The in-game channels %s, %s and %s were created,
|
||||||
|
but the superuser was not yet connected to them. Please use in-game commands to
|
||||||
|
connect Player #1 to those channels when first logging in.
|
||||||
|
""" % (key1, key2, key3)
|
||||||
|
print warning
|
||||||
|
return
|
||||||
|
|
||||||
# connect the god user to all these channels by default.
|
# connect the god user to all these channels by default.
|
||||||
goduser = get_god_user()
|
goduser = get_god_user()
|
||||||
|
|
@ -209,7 +229,7 @@ def reset_server():
|
||||||
It also checks so the warm-reset mechanism works as it should.
|
It also checks so the warm-reset mechanism works as it should.
|
||||||
"""
|
"""
|
||||||
from src.server.sessionhandler import SESSIONS
|
from src.server.sessionhandler import SESSIONS
|
||||||
print " Initial setup complete. Resetting/reloading Server."
|
print " Initial setup complete. Restarting Server once."
|
||||||
SESSIONS.server.shutdown(mode='reset')
|
SESSIONS.server.shutdown(mode='reset')
|
||||||
|
|
||||||
def handle_setup(last_step):
|
def handle_setup(last_step):
|
||||||
|
|
@ -237,7 +257,8 @@ def handle_setup(last_step):
|
||||||
create_admin_media_links,
|
create_admin_media_links,
|
||||||
import_MUX_help_files,
|
import_MUX_help_files,
|
||||||
at_initial_setup,
|
at_initial_setup,
|
||||||
reset_server]
|
reset_server
|
||||||
|
]
|
||||||
|
|
||||||
if not settings.IMPORT_MUX_HELP:
|
if not settings.IMPORT_MUX_HELP:
|
||||||
# skip importing of the MUX helpfiles, they are
|
# skip importing of the MUX helpfiles, they are
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,7 @@ ATTRIBUTE_CACHE_MAXSIZE = 100
|
||||||
# Evennia Database config
|
# Evennia Database config
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
# Database config syntax for Django 1.2+. You can add several
|
# Database config syntax for Django 1.2+.
|
||||||
# database engines in the dictionary (untested).
|
|
||||||
# ENGINE - path to the the database backend (replace
|
# ENGINE - path to the the database backend (replace
|
||||||
# sqlite3 in the example with the one you want.
|
# sqlite3 in the example with the one you want.
|
||||||
# Supported database engines are
|
# Supported database engines are
|
||||||
|
|
@ -142,7 +141,7 @@ DATABASES = {
|
||||||
'HOST':'',
|
'HOST':'',
|
||||||
'PORT':''
|
'PORT':''
|
||||||
}}
|
}}
|
||||||
# Engine Config style for Django versions < 1.2. See above.
|
# Engine Config style for Django versions < 1.2 only. See above.
|
||||||
DATABASE_ENGINE = 'sqlite3'
|
DATABASE_ENGINE = 'sqlite3'
|
||||||
DATABASE_NAME = os.path.join(GAME_DIR, 'evennia.db3')
|
DATABASE_NAME = os.path.join(GAME_DIR, 'evennia.db3')
|
||||||
DATABASE_USER = ''
|
DATABASE_USER = ''
|
||||||
|
|
|
||||||
|
|
@ -449,7 +449,7 @@ def format_table(table, extra_space=1):
|
||||||
for icol, col in enumerate(table)])
|
for icol, col in enumerate(table)])
|
||||||
return ftable
|
return ftable
|
||||||
|
|
||||||
def run_async(async_func, at_return=None, at_err=None):
|
def run_async(async_func, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
This wrapper will use Twisted's asynchronous features to run a slow
|
This wrapper will use Twisted's asynchronous features to run a slow
|
||||||
function using a separate reactor thread. In effect this means that
|
function using a separate reactor thread. In effect this means that
|
||||||
|
|
@ -467,20 +467,25 @@ def run_async(async_func, at_return=None, at_err=None):
|
||||||
your async_func under sqlite3 you will probably run very slow or even get
|
your async_func under sqlite3 you will probably run very slow or even get
|
||||||
tracebacks.
|
tracebacks.
|
||||||
|
|
||||||
async_func() - function that should be run asynchroneously
|
arg:
|
||||||
at_return(r) - if given, this function will be called when async_func returns
|
async_func - function that should be run asynchroneously
|
||||||
value r at the end of a successful execution
|
|
||||||
at_err(e) - if given, this function is called if async_func fails with an exception e.
|
reserved keywords:
|
||||||
use e.trap(ExceptionType1, ExceptionType2)
|
at_return(r) - if given, this function will be called when async_func returns
|
||||||
|
value r at the end of a successful execution
|
||||||
|
at_err(e) - if given, this function is called if async_func fails with an exception e.
|
||||||
|
use e.trap(ExceptionType1, ExceptionType2)
|
||||||
|
|
||||||
|
all other arguments/keywords will be used as args/kwargs fro async_func.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# create deferred object
|
# create deferred object
|
||||||
|
|
||||||
deferred = threads.deferToThread(async_func)
|
deferred = threads.deferToThread(async_func, *args, **kwargs)
|
||||||
if at_return:
|
if "at_return" in kwargs:
|
||||||
deferred.addCallback(at_return)
|
deferred.addCallback(kwargs["at_return"])
|
||||||
if at_err:
|
if "at_err" in kwargs:
|
||||||
deferred.addErrback(at_err)
|
deferred.addErrback(kwargs["at_err"])
|
||||||
# always add a logging errback as a last catch
|
# always add a logging errback as a last catch
|
||||||
def default_errback(e):
|
def default_errback(e):
|
||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue