changeset 1030:412969bbf05c

merge
author "Luis Henrique Fagundes <lhfagundes@gmail.com>"
date Sun, 30 Oct 2011 20:13:12 -0200
parents 5f93a84e125f (current diff) fd6324f25f87 (diff)
children 72d6fa1184e3
files
diffstat 3 files changed, 22 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sun Oct 30 20:05:21 2011 -0200
+++ b/.hgignore	Sun Oct 30 20:13:12 2011 -0200
@@ -8,6 +8,7 @@
 ^wiki/data/content/
 ^wiki/data/userprofiles/
 ^wiki/data/trash/
+^wiki/index/
 ^instance/
 ^wikiconfig_.+\.py
 ^MoinMoin/translations/.*/LC_MESSAGES/messages.mo$
--- a/MoinMoin/script/__init__.py	Sun Oct 30 20:05:21 2011 -0200
+++ b/MoinMoin/script/__init__.py	Sun Oct 30 20:13:12 2011 -0200
@@ -52,7 +52,7 @@
     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)
 
--- a/MoinMoin/script/maint/moinshell.py	Sun Oct 30 20:05:21 2011 -0200
+++ b/MoinMoin/script/maint/moinshell.py	Sun Oct 30 20:13:12 2011 -0200
@@ -6,10 +6,10 @@
 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.
 
@@ -22,10 +22,10 @@
                         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):
 
 
@@ -34,16 +34,11 @@
 
         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 (
@@ -53,7 +48,6 @@
                        default=not(self.use_ipython)),)
 
     def get_context(self):
-        
         """
         Returns a dict of context variables added to the shell namespace.
         """
@@ -66,11 +60,20 @@
         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
 
-        from IPython import embed
-
-        embed()
-
+        code.interact(self.banner, local=context)