mirror of
https://github.com/evennia/evennia.git
synced 2026-04-07 00:45:22 +02:00
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)
|
||||
else:
|
||||
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
|
||||
for inum in range(len(commands)):
|
||||
# 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
|
||||
# try to go the other way instead.
|
||||
from src.players.models import PlayerDB
|
||||
match = PlayerDB.objects.filter(user=user)
|
||||
match = PlayerDB.objects.filter(user__id=user.id)
|
||||
if match:
|
||||
players.append(match[0])
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ other things.
|
|||
Everything starts at handle_setup()
|
||||
"""
|
||||
|
||||
import django
|
||||
from django.contrib.auth.models import User
|
||||
from django.core import management
|
||||
from django.conf import settings
|
||||
|
|
@ -84,6 +85,7 @@ def create_objects():
|
|||
if not god_character.home:
|
||||
god_character.home = limbo_obj
|
||||
|
||||
|
||||
def create_channels():
|
||||
"""
|
||||
Creates some sensible default channels.
|
||||
|
|
@ -91,14 +93,32 @@ def create_channels():
|
|||
print " Creating default channels ..."
|
||||
|
||||
# public channel
|
||||
key, aliases, desc, locks = settings.CHANNEL_PUBLIC
|
||||
pchan = create.create_channel(key, aliases, desc, locks=locks)
|
||||
key1, aliases, desc, locks = settings.CHANNEL_PUBLIC
|
||||
pchan = create.create_channel(key1, aliases, desc, locks=locks)
|
||||
# mudinfo channel
|
||||
key, aliases, desc, locks = settings.CHANNEL_MUDINFO
|
||||
ichan = create.create_channel(key, aliases, desc, locks=locks)
|
||||
key2, aliases, desc, locks = settings.CHANNEL_MUDINFO
|
||||
ichan = create.create_channel(key2, aliases, desc, locks=locks)
|
||||
# connectinfo channel
|
||||
key, aliases, desc, locks = settings.CHANNEL_CONNECTINFO
|
||||
cchan = create.create_channel(key, aliases, desc, locks=locks)
|
||||
key3, aliases, desc, locks = settings.CHANNEL_CONNECTINFO
|
||||
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.
|
||||
goduser = get_god_user()
|
||||
|
|
@ -209,7 +229,7 @@ def reset_server():
|
|||
It also checks so the warm-reset mechanism works as it should.
|
||||
"""
|
||||
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')
|
||||
|
||||
def handle_setup(last_step):
|
||||
|
|
@ -237,7 +257,8 @@ def handle_setup(last_step):
|
|||
create_admin_media_links,
|
||||
import_MUX_help_files,
|
||||
at_initial_setup,
|
||||
reset_server]
|
||||
reset_server
|
||||
]
|
||||
|
||||
if not settings.IMPORT_MUX_HELP:
|
||||
# skip importing of the MUX helpfiles, they are
|
||||
|
|
|
|||
|
|
@ -121,8 +121,7 @@ ATTRIBUTE_CACHE_MAXSIZE = 100
|
|||
# Evennia Database config
|
||||
######################################################################
|
||||
|
||||
# Database config syntax for Django 1.2+. You can add several
|
||||
# database engines in the dictionary (untested).
|
||||
# Database config syntax for Django 1.2+.
|
||||
# ENGINE - path to the the database backend (replace
|
||||
# sqlite3 in the example with the one you want.
|
||||
# Supported database engines are
|
||||
|
|
@ -142,7 +141,7 @@ DATABASES = {
|
|||
'HOST':'',
|
||||
'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_NAME = os.path.join(GAME_DIR, 'evennia.db3')
|
||||
DATABASE_USER = ''
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ def format_table(table, extra_space=1):
|
|||
for icol, col in enumerate(table)])
|
||||
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
|
||||
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
|
||||
tracebacks.
|
||||
|
||||
async_func() - function that should be run asynchroneously
|
||||
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)
|
||||
arg:
|
||||
async_func - function that should be run asynchroneously
|
||||
|
||||
reserved keywords:
|
||||
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
|
||||
|
||||
deferred = threads.deferToThread(async_func)
|
||||
if at_return:
|
||||
deferred.addCallback(at_return)
|
||||
if at_err:
|
||||
deferred.addErrback(at_err)
|
||||
deferred = threads.deferToThread(async_func, *args, **kwargs)
|
||||
if "at_return" in kwargs:
|
||||
deferred.addCallback(kwargs["at_return"])
|
||||
if "at_err" in kwargs:
|
||||
deferred.addErrback(kwargs["at_err"])
|
||||
# always add a logging errback as a last catch
|
||||
def default_errback(e):
|
||||
from src.utils import logger
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue