# HG changeset patch # User Sylvain Thénault # Date 1309513864 -7200 # Node ID 83872394b5d92c0524cede71539b5fe4e4e14ba8 # Parent cb6ece9cdb78307bd32da87cb604ed5af315e3ac# Parent d177c0755b10f5b23ec459aa0f295b7bfafbdbfe backport stable diff -r cb6ece9cdb78 -r 83872394b5d9 cwctl.py --- a/cwctl.py Wed Jun 29 16:29:15 2011 +0200 +++ b/cwctl.py Fri Jul 01 11:51:04 2011 +0200 @@ -152,16 +152,17 @@ print '*'*72 if not ASK.confirm('%s instance %r ?' % (self.name, appid)): continue - status = max(status, self.run_arg(appid)) + try: + status = max(status, self.run_arg(appid)) + except (KeyboardInterrupt, SystemExit): + print >> sys.stderr, '%s aborted' % self.name + return 2 # specific error code sys.exit(status) def run_arg(self, appid): cmdmeth = getattr(self, '%s_instance' % self.name) try: status = cmdmeth(appid) - except (KeyboardInterrupt, SystemExit): - print >> sys.stderr, '%s aborted' % self.name - return 2 # specific error code except (ExecutionError, ConfigurationError), ex: print >> sys.stderr, 'instance %s not %s: %s' % ( appid, self.actionverb, ex) diff -r cb6ece9cdb78 -r 83872394b5d9 dbapi.py --- a/dbapi.py Wed Jun 29 16:29:15 2011 +0200 +++ b/dbapi.py Fri Jul 01 11:51:04 2011 +0200 @@ -241,6 +241,7 @@ self.cnx = cnx self.data = {} self.login = login + self.mtime = time() # dbapi session identifier is the same as the first connection # identifier, but may later differ in case of auto-reconnection as done # by the web authentication manager (in cw.web.views.authentication) diff -r cb6ece9cdb78 -r 83872394b5d9 rset.py --- a/rset.py Wed Jun 29 16:29:15 2011 +0200 +++ b/rset.py Fri Jul 01 11:51:04 2011 +0200 @@ -529,17 +529,15 @@ @cached def syntax_tree(self): - """get the syntax tree for the source query. - - :rtype: rql.stmts.Statement - :return: the RQL syntax tree of the originating query + """return the syntax tree (:class:`rql.stmts.Union`) for the originating + query. You can expect it to have solutions computed but it won't be + annotated (you usually don't need that for simple introspection). """ if self._rqlst: rqlst = self._rqlst.copy() # to avoid transport overhead when pyro is used, the schema has been # unset from the syntax tree rqlst.schema = self.req.vreg.schema - self.req.vreg.rqlhelper.annotate(rqlst) else: rqlst = self.req.vreg.parse(self.req, self.rql, self.args) return rqlst diff -r cb6ece9cdb78 -r 83872394b5d9 server/serverctl.py --- a/server/serverctl.py Wed Jun 29 16:29:15 2011 +0200 +++ b/server/serverctl.py Fri Jul 01 11:51:04 2011 +0200 @@ -567,6 +567,15 @@ """ name = 'reset-admin-pwd' arguments = '' + options = ( + ('password', + {'short': 'p', 'type' : 'string', 'metavar' : '', + 'default' : None, + 'help': 'Use this password instead of prompt for one.\n' + '/!\ THIS IS AN INSECURE PRACTICE /!\ \n' + 'the password will appear in shell history'} + ), + ) def run(self, args): """run the command with its specific arguments""" @@ -593,15 +602,18 @@ print " fix your sources file before running this command" cnx.close() sys.exit(1) - # ask for a new password - _, passwd = manager_userpasswd(adminlogin, confirm=True, - passwdmsg='new password for %s' % adminlogin) + if self.config.password is None: + # ask for a new password + msg = 'new password for %s' % adminlogin + _, pwd = manager_userpasswd(adminlogin, confirm=True, passwdmsg=msg) + else: + pwd = self.config.password try: cursor.execute("UPDATE cw_CWUser SET cw_upassword=%(p)s WHERE cw_login=%(l)s", - {'p': dbhelper.binary_value(crypt_password(passwd)), 'l': adminlogin}) + {'p': dbhelper.binary_value(crypt_password(pwd)), 'l': adminlogin}) sconfig = Configuration(options=USER_OPTIONS) sconfig['login'] = adminlogin - sconfig['password'] = passwd + sconfig['password'] = pwd sourcescfg['admin'] = sconfig config.write_sources_file(sourcescfg) except Exception, ex: diff -r cb6ece9cdb78 -r 83872394b5d9 server/test/unittest_rql2sql.py --- a/server/test/unittest_rql2sql.py Wed Jun 29 16:29:15 2011 +0200 +++ b/server/test/unittest_rql2sql.py Fri Jul 01 11:51:04 2011 +0200 @@ -1545,14 +1545,14 @@ ORDER BY ts_rank(appears0.words, to_tsquery('default', 'hip&hop&momo'))*appears0.weight"""), ('Any X ORDERBY FTIRANK(X) WHERE X has_text "toto tata", X name "tutu", X is IN (Basket,Folder)', - """SELECT _X.cw_eid + """SELECT T1.C0 FROM (SELECT _X.cw_eid AS C0, ts_rank(appears0.words, to_tsquery('default', 'toto&tata'))*appears0.weight AS C1 FROM appears AS appears0, cw_Basket AS _X WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=_X.cw_eid AND _X.cw_name=tutu UNION ALL -SELECT _X.cw_eid +SELECT _X.cw_eid AS C0, ts_rank(appears0.words, to_tsquery('default', 'toto&tata'))*appears0.weight AS C1 FROM appears AS appears0, cw_Folder AS _X WHERE appears0.words @@ to_tsquery('default', 'toto&tata') AND appears0.uid=_X.cw_eid AND _X.cw_name=tutu -ORDER BY ts_rank(appears0.words, to_tsquery('default', 'toto&tata'))*appears0.weight"""), +ORDER BY 2) AS T1"""), ('Personne X ORDERBY FTIRANK(X),FTIRANK(S) WHERE X has_text %(text)s, X travaille S, S has_text %(text)s', """SELECT _X.eid diff -r cb6ece9cdb78 -r 83872394b5d9 web/application.py --- a/web/application.py Wed Jun 29 16:29:15 2011 +0200 +++ b/web/application.py Fri Jul 01 11:51:04 2011 +0200 @@ -71,6 +71,8 @@ total += 1 try: last_usage_time = session.cnx.check() + except AttributeError: + last_usage_time = session.mtime except BadConnectionId: self.close_session(session) closed += 1 @@ -228,7 +230,9 @@ self.session_manager.close_session(session) def get_session(self, req, sessionid): - return self.session_manager.get_session(req, sessionid) + session = self.session_manager.get_session(req, sessionid) + session.mtime = time() + return session def open_session(self, req, allow_no_cnx=True): session = self.session_manager.open_session(req, allow_no_cnx=allow_no_cnx) diff -r cb6ece9cdb78 -r 83872394b5d9 web/test/unittest_reledit.py --- a/web/test/unittest_reledit.py Wed Jun 29 16:29:15 2011 +0200 +++ b/web/test/unittest_reledit.py Fri Jul 01 11:51:04 2011 +0200 @@ -48,7 +48,7 @@ rtype) def test_default_forms(self): - self.skip('Need to check if this test should still run post reledit/doreledit merge') + self.skipTest('Need to check if this test should still run post reledit/doreledit merge') doreledit = {'title': """
cubicweb-world-domination