[c-c] fixes for shell w/ pyro instance stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 16 Oct 2009 16:29:46 +0200
branchstable
changeset 3707 78596919ede3
parent 3706 f804bbd0670e
child 3708 95e8c3a9698a
[c-c] fixes for shell w/ pyro instance
cwctl.py
dbapi.py
server/migractions.py
--- a/cwctl.py	Fri Oct 16 15:43:23 2009 +0200
+++ b/cwctl.py	Fri Oct 16 16:29:46 2009 +0200
@@ -741,12 +741,23 @@
     def run(self, args):
         appid = pop_arg(args, 99, msg="No instance specified !")
         if self.config.pyro:
+            from cubicweb import AuthenticationError
             from cubicweb.dbapi import connect
             from cubicweb.server.utils import manager_userpasswd
             from cubicweb.server.migractions import ServerMigrationHelper
-            login, pwd = manager_userpasswd(msg=None)
-            cnx = connect(appid, login=login, password=pwd,
-                          host=self.config.pyro_ns_host, mulcnx=False)
+            while True:
+                try:
+                    login, pwd = manager_userpasswd(msg=None)
+                    cnx = connect(appid, login=login, password=pwd,
+                                  host=self.config.pyro_ns_host, mulcnx=False)
+                except AuthenticationError, ex:
+                    print ex
+                except (KeyboardInterrupt, EOFError):
+                    print
+                    sys.exit(0)
+                else:
+                    break
+            cnx.load_appobjects()
             repo = cnx._repo
             mih = ServerMigrationHelper(None, repo=repo, cnx=cnx,
                                          # hack so it don't try to load fs schema
--- a/dbapi.py	Fri Oct 16 15:43:23 2009 +0200
+++ b/dbapi.py	Fri Oct 16 16:29:46 2009 +0200
@@ -446,7 +446,7 @@
         return self._repo.get_schema()
 
     def load_appobjects(self, cubes=_MARKER, subpath=None, expand=True,
-                      force_reload=None):
+                        force_reload=None):
         config = self.vreg.config
         if cubes is _MARKER:
             cubes = self._repo.get_cubes()
--- a/server/migractions.py	Fri Oct 16 15:43:23 2009 +0200
+++ b/server/migractions.py	Fri Oct 16 16:29:46 2009 +0200
@@ -260,7 +260,8 @@
                         'sql': self.sqlexec,
                         'rql': self.rqlexec,
                         'rqliter': self.rqliter,
-                        'schema': self.repo.schema,
+                        'schema': self.repo.get_schema(),
+                        'cnx': self.cnx,
                         'fsschema': self.fs_schema,
                         'session' : self.session,
                         'repo' : self.repo,