genzgd / Lampost-Mud

A Python server and HTML/angular.js client for MUDs and other multi-user virtual worlds
https://lampostmud.org
MIT License
17 stars 6 forks source link

lampost_setup AttributeError #18

Open mjgorman opened 7 years ago

mjgorman commented 7 years ago

python lampost_setup.py -im results in an AttributeError exception being thrown.

Traceback (most recent call last):
  File "lampost_setup.py", line 28, in <module>
    newsetup.new_setup(args)
  File "/usr/lib64/python3.4/site-packages/lampost/setup/newsetup.py", line 41, in new_setup
    app.exec_bootstraps()
  File "/usr/lib64/python3.4/site-packages/lampost/di/app.py", line 29, in exec_bootstraps
    func()
  File "/home/michael/projects/Lampost-Mud/lampmud/mud/mudcore.py", line 27, in _start
    shout_channel = Channel('shout', general=True)
  File "/usr/lib64/python3.4/site-packages/lampost/server/channel.py", line 20, in __init__
    cs.register_channel(self.id, general)
AttributeError: 'Injected' object has no attribute 'register_channel'

I am able to get it to move on by simply wrapping the cs.register_channel in lampost/server/channel.py of lampost_lib

diff --git a/lampost/server/channel.py b/lampost/server/channel.py
index 7c9defa..27dae0e 100644
--- a/lampost/server/channel.py
+++ b/lampost/server/channel.py
@@ -6,7 +6,7 @@ from lampost.util.lputil import timestamp

 ev = Injected('dispatcher')
 db = Injected('datastore')
 cs = Injected('channel_service')
 module_inject(__name__)

@@ -17,7 +17,10 @@ class Channel():
         make_action(self, (channel_type,) + aliases, target_class='cmd_str')
         self.id = "{}_{}".format(channel_type, instance_id) if instance_id else channel_type
         self.tag = tag
-        cs.register_channel(self.id, general)
+        try:
+            cs.register_channel(self.id, general)
+        except Exception as e:
+            print("{0}".format(e)) 

works, and allows user setup, but obviously not a fix for the real issue. I poked around a bit, but I couldn't see an obvious fix as i'm not sure exactly how the Injected class works.

genzgd commented 7 years ago

Thanks for reporting this. I need to rethink the setup approach a bit because way too many things are being automatically imported -- Channels shouldn't be initialized in the setup but they are because of the way the on_app_start decorator works. channel_service is never actually initialized like other services in newsetup.py because it shouldn't be needed.

I'll see if I can a add a temporary fix in newsetup.py in master but just a heads up that the existing angular UI is being replaced (see the lampmud_ui project and the new_ui branch), so things are in a lot of flux right now. I hope to have the new UI completely done in a few weeks.)