Commits

Anonymous committed 412969b Merge

merge

  • Participants
  • Parent commits 5f93a84, fd6324f

Comments (0)

Files changed (3)

 ^wiki/data/content/
 ^wiki/data/userprofiles/
 ^wiki/data/trash/
+^wiki/index/
 ^instance/
 ^wikiconfig_.+\.py
 ^MoinMoin/translations/.*/LC_MESSAGES/messages.mo$

File MoinMoin/script/__init__.py

     manager.add_command("import19", ImportMoin19())
 
     from MoinMoin.script.maint.moinshell import MoinShell
-    manager.add_command("moinshell", MoinShell())
+    manager.add_command("shell", MoinShell())
 
     return manager.run(default_command=default_command)
 

File MoinMoin/script/maint/moinshell.py

 from flaskext.script import Command, Option
 
 from MoinMoin import user
+from MoinMoin.app import before_wiki
 from MoinMoin.util.clock import Clock
 
 class MoinShell(Command):
-
     """
     Runs a Python shell inside Flask application context.
 
                         line by passing the **--no-ipython** flag.
     """
 
-    banner = ''
+    banner = u'Objects "flaskg" and "app" is in context.'
 
     description = 'Runs a Python shell inside Flask application context.'
-    
+
     def __init__(self, banner=None, make_context=None, use_ipython=True):
 
 
 
         if make_context is None:
             def make_context():
-                app = _request_ctx_stack.top.app
-                flaskg.unprotected_storage = app.storage
-                flaskg.groups = app.cfg.groups()
-                flaskg.storage = app.storage
-                flaskg.user = user.User()
-                flaskg.clock = Clock()
+                before_wiki()
                 return dict(app=app, flaskg=flaskg)
 
         self.make_context = make_context
-    
+
     def get_options(self):
 
         return (
                        default=not(self.use_ipython)),)
 
     def get_context(self):
-        
         """
         Returns a dict of context variables added to the shell namespace.
         """
         Runs the shell. Unless no_ipython is True or use_python is False
         then runs IPython shell if that is installed.
         """
-        
+        context = self.get_context()
+        if not no_ipython:
+            try:
+                # IPython < 0.11
+                import IPython
+                sh = IPython.Shell.IPShellEmbed(banner=self.banner)
+                sh(global_ns=dict(), local_ns=context)
+                return
+            except ImportError:
+                # IPython = 0.11
+                import IPython
+                sh = IPython.embed(banner2=self.banner, user_ns=context)
+                sh()
+            finally:
+                pass
 
-        context = self.get_context()
-
-        from IPython import embed
-
-        embed()
-
+        code.interact(self.banner, local=context)