Fixed a bug in amp that made reloading not work.
This commit is contained in:
parent
e36c7d5cc1
commit
2ba16e155e
8 changed files with 39 additions and 43 deletions
|
|
@ -272,10 +272,11 @@ class CmdChannels(MuxPlayerCommand):
|
||||||
# full listing (of channels caller is able to listen to)
|
# full listing (of channels caller is able to listen to)
|
||||||
comtable = prettytable.PrettyTable(["{wsub","{wchannel","{wmy aliases","{wlocks","{wdescription"])
|
comtable = prettytable.PrettyTable(["{wsub","{wchannel","{wmy aliases","{wlocks","{wdescription"])
|
||||||
for chan in channels:
|
for chan in channels:
|
||||||
nicks = [nick for nick in caller.nicks.get(category="channel")]
|
nicks = caller.nicks.get(category="channel")
|
||||||
comtable.add_row([chan in subs and "{gYes{n" or "{rNo{n",
|
if nicks:
|
||||||
|
comtable.add_row([chan in subs and "{gYes{n" or "{rNo{n",
|
||||||
"%s%s" % (chan.key, chan.aliases and "(%s)" % ",".join(chan.aliases) or ""),
|
"%s%s" % (chan.key, chan.aliases and "(%s)" % ",".join(chan.aliases) or ""),
|
||||||
"%s".join(nick.db_nick for nick in nicks if nick.db_real.lower()==clower()),
|
"%s".join(nick.db_nick for nick in make_iter(nicks) if nick.db_real.lower()==clower()),
|
||||||
chan.locks,
|
chan.locks,
|
||||||
chan.desc])
|
chan.desc])
|
||||||
caller.msg("\n{wAvailable channels{n (use {wcomlist{n,{waddcom{n and {wdelcom{n to manage subscriptions):\n%s" % comtable)
|
caller.msg("\n{wAvailable channels{n (use {wcomlist{n,{waddcom{n and {wdelcom{n to manage subscriptions):\n%s" % comtable)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ from src.scripts.models import ScriptDB
|
||||||
from src.objects.models import ObjectDB
|
from src.objects.models import ObjectDB
|
||||||
from src.players.models import PlayerDB
|
from src.players.models import PlayerDB
|
||||||
from src.utils import logger, utils, gametime, create, is_pypy, prettytable
|
from src.utils import logger, utils, gametime, create, is_pypy, prettytable
|
||||||
|
from src.utils.utils import crop
|
||||||
from src.commands.default.muxcommand import MuxCommand
|
from src.commands.default.muxcommand import MuxCommand
|
||||||
|
|
||||||
# delayed imports
|
# delayed imports
|
||||||
|
|
@ -213,24 +214,17 @@ def format_script_list(scripts):
|
||||||
table.align = 'r'
|
table.align = 'r'
|
||||||
for script in scripts:
|
for script in scripts:
|
||||||
nextrep = script.time_until_next_repeat()
|
nextrep = script.time_until_next_repeat()
|
||||||
#print ([script.id,
|
print type(script),
|
||||||
# (not hasattr(script, 'obj') or not script.obj) and "<Global>" or script.obj.key,
|
print script.key
|
||||||
# script.key,
|
|
||||||
# (not hasattr(script, 'interval') or script.interval < 0) and "--" or "%ss" % script.interval,
|
|
||||||
# not nextrep and "--" or "%ss" % nextrep,
|
|
||||||
# (not hasattr(script, 'repeats') or not script.repeats) and "--" or "%i" % script.repeats,
|
|
||||||
# script.persistent and "*" or "-",
|
|
||||||
# script.typeclass_path.rsplit('.', 1)[-1],
|
|
||||||
# script.desc])
|
|
||||||
table.add_row([script.id,
|
table.add_row([script.id,
|
||||||
(not hasattr(script, 'obj') or not script.obj) and "<Global>" or script.obj.key,
|
script.obj.key if (hasattr(script, 'obj') and script.obj) else "<Global>",
|
||||||
script.key,
|
script.key,
|
||||||
(not hasattr(script, 'interval') or script.interval < 0) and "--" or "%ss" % script.interval,
|
script.interval if script.interval > 0 else "--",
|
||||||
not nextrep and "--" or "%ss" % nextrep,
|
"%ss" % nextrep if nextrep else "--",
|
||||||
(not hasattr(script, 'repeats') or not script.repeats) and "--" or "%i" % script.repeats,
|
"%i" % script.repeats if script.repeats else "--",
|
||||||
script.persistent and "*" or "-",
|
"*" if script.persistent else "-",
|
||||||
script.typeclass_path.rsplit('.', 1)[-1],
|
script.typeclass_path.rsplit('.', 1)[-1],
|
||||||
script.desc])
|
crop(script.desc, width=20)])
|
||||||
return "%s" % table
|
return "%s" % table
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,11 @@ _RE = re.compile(r"^\+|-+\+|\+-+|--*|\|", re.MULTILINE)
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
class TestPlayerClass(Player):
|
class TestPlayerClass(Player):
|
||||||
def msg(self, message, **kwargs):
|
def msg(self, text="", **kwargs):
|
||||||
"test message"
|
"test message"
|
||||||
if not self.ndb.stored_msg:
|
if not self.ndb.stored_msg:
|
||||||
self.ndb.stored_msg = []
|
self.ndb.stored_msg = []
|
||||||
self.ndb.stored_msg.append(message)
|
self.ndb.stored_msg.append(text)
|
||||||
def _get_superuser(self):
|
def _get_superuser(self):
|
||||||
"test with superuser flag"
|
"test with superuser flag"
|
||||||
return self.ndb.is_superuser
|
return self.ndb.is_superuser
|
||||||
|
|
|
||||||
|
|
@ -677,7 +677,6 @@ class ObjectDB(TypedObject):
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
kwargs.update(data)
|
kwargs.update(data)
|
||||||
|
|
||||||
|
|
||||||
if _GA(self, 'player'):
|
if _GA(self, 'player'):
|
||||||
# note that we must call the player *typeclass'* msg(), otherwise one couldn't overload it.
|
# note that we must call the player *typeclass'* msg(), otherwise one couldn't overload it.
|
||||||
if not sessid:
|
if not sessid:
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,7 @@ class AMPProtocol(amp.AMP):
|
||||||
"""
|
"""
|
||||||
Access method called by the Server and executed on the Server.
|
Access method called by the Server and executed on the Server.
|
||||||
"""
|
"""
|
||||||
#print "msg server->portal (server side):", sessid, msg, data
|
#print "msg server->portal (server side):", sessid, msg, kwargs
|
||||||
try:
|
try:
|
||||||
return self.callRemote(MsgServer2Portal,
|
return self.callRemote(MsgServer2Portal,
|
||||||
sessid=sessid,
|
sessid=sessid,
|
||||||
|
|
@ -370,7 +370,7 @@ class AMPProtocol(amp.AMP):
|
||||||
data = loads(data)
|
data = loads(data)
|
||||||
server_sessionhandler = self.factory.server.sessions
|
server_sessionhandler = self.factory.server.sessions
|
||||||
|
|
||||||
#print "serveradmin (server side):", sessid, operation, data
|
#print "serveradmin (server side):", sessid, ord(operation), data
|
||||||
|
|
||||||
if operation == PCONN: #portal_session_connect
|
if operation == PCONN: #portal_session_connect
|
||||||
# create a new session and sync it
|
# create a new session and sync it
|
||||||
|
|
@ -395,7 +395,7 @@ class AMPProtocol(amp.AMP):
|
||||||
"""
|
"""
|
||||||
Access method called by the Portal and Executed on the Portal.
|
Access method called by the Portal and Executed on the Portal.
|
||||||
"""
|
"""
|
||||||
#print "serveradmin (portal side):", sessid, operation, data
|
#print "serveradmin (portal side):", sessid, ord(operation), data
|
||||||
data = dumps(data)
|
data = dumps(data)
|
||||||
|
|
||||||
return self.callRemote(ServerAdmin,
|
return self.callRemote(ServerAdmin,
|
||||||
|
|
@ -441,7 +441,7 @@ class AMPProtocol(amp.AMP):
|
||||||
return {}
|
return {}
|
||||||
PortalAdmin.responder(amp_portal_admin)
|
PortalAdmin.responder(amp_portal_admin)
|
||||||
|
|
||||||
def call_remote_PortalAdmin(self, sessid, operation="", **kwargs):
|
def call_remote_PortalAdmin(self, sessid, operation="", data=""):
|
||||||
"""
|
"""
|
||||||
Access method called by the server side.
|
Access method called by the server side.
|
||||||
"""
|
"""
|
||||||
|
|
@ -449,7 +449,7 @@ class AMPProtocol(amp.AMP):
|
||||||
return self.callRemote(PortalAdmin,
|
return self.callRemote(PortalAdmin,
|
||||||
sessid=sessid,
|
sessid=sessid,
|
||||||
operation=operation,
|
operation=operation,
|
||||||
data=dumps(kwargs)).addErrback(self.errback, "PortalAdmin")
|
data=dumps(data)).addErrback(self.errback, "PortalAdmin")
|
||||||
|
|
||||||
# Extra functions
|
# Extra functions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ class AttributeHandler(object):
|
||||||
ret.append(True if _GA(self.obj, self._m2m_fieldname).filter(Q(db_key__iexact=keystr) & category_cond) else False)
|
ret.append(True if _GA(self.obj, self._m2m_fieldname).filter(Q(db_key__iexact=keystr) & category_cond) else False)
|
||||||
return ret[0] if len(ret)==1 else ret
|
return ret[0] if len(ret)==1 else ret
|
||||||
|
|
||||||
def get(self, key, category=None, default=None, return_obj=False, strattr=False,
|
def get(self, key=None, category=None, default=None, return_obj=False, strattr=False,
|
||||||
raise_exception=False, accessing_obj=None, default_access=True):
|
raise_exception=False, accessing_obj=None, default_access=True):
|
||||||
"""
|
"""
|
||||||
Returns the value of the given Attribute or list of Attributes.
|
Returns the value of the given Attribute or list of Attributes.
|
||||||
|
|
@ -316,8 +316,9 @@ class AttributeHandler(object):
|
||||||
for keystr in make_iter(key):
|
for keystr in make_iter(key):
|
||||||
cachekey = "%s%s" % (category if category else "", keystr)
|
cachekey = "%s%s" % (category if category else "", keystr)
|
||||||
attr_obj = get_attr_cache(self.obj, cachekey)
|
attr_obj = get_attr_cache(self.obj, cachekey)
|
||||||
|
key_cond = Q(db_key__iexact=keystr) if key!=None else Q()
|
||||||
if not attr_obj:
|
if not attr_obj:
|
||||||
attr_obj = _GA(self.obj, "db_attributes").filter(Q(db_key__iexact=keystr) & category_cond)
|
attr_obj = _GA(self.obj, "db_attributes").filter(key_cond & category_cond)
|
||||||
if not attr_obj:
|
if not attr_obj:
|
||||||
if raise_exception:
|
if raise_exception:
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
|
|
@ -439,10 +440,10 @@ class NickHandler(AttributeHandler):
|
||||||
"Add a new nick"
|
"Add a new nick"
|
||||||
category = "nick_%s" % category
|
category = "nick_%s" % category
|
||||||
super(NickHandler, self).add(key, replacement, category=category, strattr=True, **kwargs)
|
super(NickHandler, self).add(key, replacement, category=category, strattr=True, **kwargs)
|
||||||
def get(self, key, category="inputline", **kwargs):
|
def get(self, key=None, category="inputline", **kwargs):
|
||||||
"Get the replacement value matching the given key and category"
|
"Get the replacement value matching the given key and category"
|
||||||
category = "nick_%s" % category
|
category = "nick_%s" % category
|
||||||
return super(NickHandler, self).get(key, category=category, strattr=True, **kwargs)
|
return super(NickHandler, self).get(key=key, category=category, strattr=True, **kwargs)
|
||||||
def remove(self, key, category="inputline", **kwargs):
|
def remove(self, key, category="inputline", **kwargs):
|
||||||
"Remove Nick with matching category"
|
"Remove Nick with matching category"
|
||||||
category = "nick_%s" % category
|
category = "nick_%s" % category
|
||||||
|
|
|
||||||
|
|
@ -110,9 +110,10 @@ class SharedMemoryModelBase(ModelBase):
|
||||||
if dbid:
|
if dbid:
|
||||||
try:
|
try:
|
||||||
value = cls._default_manager.get(id=dbid)
|
value = cls._default_manager.get(id=dbid)
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist,e:
|
||||||
# maybe it is just a name that happens to look like a dbid
|
# maybe it is just a name that happens to look like a dbid
|
||||||
pass
|
from src.utils.logger import log_trace
|
||||||
|
log_trace()
|
||||||
#print "_set wrapper:", fname, value, type(value), cls._get_pk_val(cls._meta)
|
#print "_set wrapper:", fname, value, type(value), cls._get_pk_val(cls._meta)
|
||||||
_SA(cls, fname, value)
|
_SA(cls, fname, value)
|
||||||
# only use explicit update_fields in save if we actually have a
|
# only use explicit update_fields in save if we actually have a
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue