Are channel objects and commands attaching to players and not characters (in a multi-session mode with characters), if so how would I make channels work with characters?

40 views
Skip to first unread message

Ashlan

unread,
Aug 16, 2017, 11:31:20 AM8/16/17
to eve...@googlegroups.com
I've been using some code to add characters to channels.  It works but has unexpected side effects.  For example,

channel = find_channel(caller, "Corinth")
channel.connect(caller)

This successfully adds a character/player to a channel but when I use the channels command, it lists the channel as not being subscribed too.  I tried making new test characters and the channel arrangement seemed to carry across characters, which does seem to confirm that it's using players and not characters.  Worse though, I get this error if I try to addcom and delcom a channel again and use aliases for it:

ct test
Traceback (most recent call last):
  File "/home/ubuntu/muddev/evennia/evennia/commands/cmdhandler.py", line 741, in cmdhandler
    error_to.msg(exc.sysarg)
  File "/home/ubuntu/muddev/evennia/evennia/objects/objects.py", line 526, in msg
    session.data_out(text=text, **kwargs)
  File "/home/ubuntu/muddev/evennia/evennia/server/serversession.py", line 378, in data_out
    self.sessionhandler.data_out(self, **kwargs)
  File "/home/ubuntu/muddev/evennia/evennia/server/sessionhandler.py", line 704, in data_out
    **kwargs)
  File "/home/ubuntu/muddev/evennia/evennia/server/amp.py", line 485, in send_MsgServer2Portal
    return self.send_data(MsgServer2Portal, session.sessid, **kwargs)
  File "/home/ubuntu/muddev/evennia/evennia/server/amp.py", line 421, in send_data
    packed_data=dumps((sessid, kwargs))
  File "/home/ubuntu/muddev/evennia/evennia/server/amp.py", line 322, in <lambda>
    dumps = lambda data: to_str(pickle.dumps(to_str(data), pickle.HIGHEST_PROTOCOL))
TypeError: 'NoneType' object is not callable
Looking at this code also seems to suggest it's player specific, although the terms are somewhat vague I've noticed.  From comms.py in /comms/:
Notes:
This will first try Player subscribers and only try Object
if the Player fails.

"""
has_sub = self.subscriptions.has(subscriber)
if not has_sub and hasattr(subscriber, "player"):
# it's common to send an Object when we
# by default only allow Players to subscribe.
has_sub = self.subscriptions.has(subscriber.player)
return has_sub


So what I think I need here (I'm not positive though) is to get channels to attach to character objects and not to players, at which point the default commands will hopefully start performing as I expect.  If people understand what I'm saying here and know what should be changed to get this happening, let me know, thanks :D

Edit: models in /comms/ seems like one possible place where this code could be found but it seems like a pretty difficult issue for me... possibly around here?

for subscriber in make_iter(entity):
if subscriber:
clsname = subscriber.__dbclass__.__name__
# chooses the right type
if clsname == "ObjectDB":
self.obj.db_object_subscriptions.add(subscriber)
elif clsname == "PlayerDB":
self.obj.db_subscriptions.add(subscriber)

Dave Brannigan

unread,
Aug 16, 2017, 3:49:14 PM8/16/17
to eve...@googlegroups.com
Maybe open an issue with the exact sequence of calls/commands you ran. I'm having a little trouble understanding where the final error came from. Line 322 is the creation of a helper function in amp.py - I don't see how it would fail as a result of anything you did in a command. It's not an AttributeError, but a TypeError saying that you tried to do None(). It suggests that either pickle.dumps or to_str was set to have a value of None, which is very strange.

On Wed, Aug 16, 2017 at 11:31 AM, Ashlan <wortham...@gmail.com> wrote:
I've been using some code to add characters to channels.  It works but has unexpected side effects.  For example,

channel = find_channel(caller, "Corinth")
channel.connect(caller)

This successfully adds a character/player to a channel but when I use the channels command, it lists the channel as not being subscribed too.  I tried making new test characters and the channel arrangement seemed to carry across characters, which does seem to confirm that it's using players and not characters.  Worse though, I get this error if I try to addcom and delcom a channel again and use aliases for it:

ct test
Traceback (most recent call last):
  File "/home/ubuntu/muddev/evennia/evennia/commands/cmdhandler.py", line 741, in cmdhandler
    error_to.msg(exc.sysarg)
  File "/home/ubuntu/muddev/evennia/evennia/objects/objects.py", line 526, in msg
    session.data_out(text=text, **kwargs)
  File "/home/ubuntu/muddev/evennia/evennia/server/serversession.py", line 378, in data_out
    self.sessionhandler.data_out(self, **kwargs)
  File "/home/ubuntu/muddev/evennia/evennia/server/sessionhandler.py", line 704, in data_out
    **kwargs)
  File "/home/ubuntu/muddev/evennia/evennia/server/amp.py", line 485, in send_MsgServer2Portal
    return self.send_data(MsgServer2Portal, session.sessid, **kwargs)
  File "/home/ubuntu/muddev/evennia/evennia/server/amp.py", line 421, in send_data
    packed_data=dumps((sessid, kwargs))
  File "/home/ubuntu/muddev/evennia/evennia/server/amp.py", line 322, in <lambda>
    dumps = lambda data: to_str(pickle.dumps(to_str(data), pickle.HIGHEST_PROTOCOL))
TypeError: 'NoneType' object is not callable
So what I think I need here (I'm not positive though) is to get channels to attach to character objects and not to players, at which point the default commands will hopefully start performing as I expect.  If people understand what I'm saying here and know what should be changed to get this happening, let me know, thanks :D

--
You received this message because you are subscribed to the Google Groups "Evennia" group.
To unsubscribe from this group and stop receiving emails from it, send an email to evennia+unsubscribe@googlegroups.com.
To post to this group, send email to eve...@googlegroups.com.
Visit this group at https://groups.google.com/group/evennia.
To view this discussion on the web visit https://groups.google.com/d/msgid/evennia/4890664b-7ae8-45b4-a060-0ea0e98001a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ashlan

unread,
Aug 16, 2017, 9:05:29 PM8/16/17
to eve...@googlegroups.com
What I suspect happened is that trying to add and close the channel with commands (that may be player based), but using code to add character objects to channels (which wasn't getting reflected in the channels list) was creating and removing the alias to use the channels.  So one part of the code thought the alias was still there and another part couldn't find it? Ultimately though I don't actually care about this error since if I can effectively move channel functions over to character objects the error should not come up again.  This is of course if I am understanding everything correctly.

Another option I'm looking at is how most of the channel commands are connected to playercommandset and not to a character command set.
To unsubscribe from this group and stop receiving emails from it, send an email to evennia+u...@googlegroups.com.

Ashlan

unread,
Aug 16, 2017, 9:37:44 PM8/16/17
to Evennia
Ok, problem solved it appears, I just had to change player_caller to False :) Although people who joined channels as players earlier, it's pretty chaotic.

Tehom

unread,
Aug 16, 2017, 9:38:53 PM8/16/17
to Evennia
I can't reproduce the error you got with the steps you listed, so not sure what to say about that. Adding a character with channel.connect(self) worked fine, and everything behaved as expected after that point - addcom and delcom affected the player's connection as expected since they're player commands by default. You could easily change them to be character commands if you wished, or introduce a switch to do the command on a character, whatever.

Ashlan

unread,
Aug 17, 2017, 6:09:17 AM8/17/17
to Evennia
I was actually using channel.connect(caller) and not (self), although now I have a new error after I changed player_caller from True to False in the base channel command classes, which solved some of my issues.

Unfortunately a new problem has no popped up for me, which is that when anyone uses a channel, the channel works and there's no errors in evennia but this error comes up 2-4 times, seemingly randomly, in the terminal:


Traceback (most recent call last):
File "/home/ubuntu/muddev/evennia/evennia/objects/objects.py", line 511, in msg
AttributeError: 'list' object has no attribute 'at_msg_send'

Ashlan

unread,
Aug 17, 2017, 6:45:51 AM8/17/17
to eve...@googlegroups.com
I added this in to determine where the error was coming from exactly and it's at the beginning of the relevant part of objects.py where I put in "first trace", although I'm not sure if the problem is actually originating with this code since it's just default evennia code:

if from_obj:
try:
from_obj.at_msg_send(text=text, to_obj=self, **kwargs)
except Exception:
logger.log_trace("first trace")

It's my best lead so far though!

Judging from the error message of course, the problem seems to be that the object sending the communication is a list for some reason.

Griatch Art

unread,
Aug 18, 2017, 4:45:11 AM8/18/17
to Evennia
Yes, from_obj is a list there, and it should not be. The from_obj is an optional argument passed to the msg() method, so look further up in the traceback to see where it's coming from and trace backwards until you see where from_obj is created. Notably several search functions return lists (even if there is only one found object), so this is a likely source of error. It's hard to tell without seeing the entire code. There could of course be an issue in Evennia, but at least as far as I know people have had no issues with sending messages to Characters.
.
Griatch
Reply all
Reply to author
Forward
0 new messages