[Checkins] SVN: Products.SQLAlchemyDA/trunk/ - better support for open/close connections

Andreas Jung andreas at andreas-jung.com
Sun May 6 06:41:20 EDT 2007


Log message for revision 75545:
  - better support for open/close connections
  - better UI integration
  

Changed:
  U   Products.SQLAlchemyDA/trunk/__init__.py
  U   Products.SQLAlchemyDA/trunk/da.py
  U   Products.SQLAlchemyDA/trunk/pt/info.zpt

-=-
Modified: Products.SQLAlchemyDA/trunk/__init__.py
===================================================================
--- Products.SQLAlchemyDA/trunk/__init__.py	2007-05-06 10:36:40 UTC (rev 75544)
+++ Products.SQLAlchemyDA/trunk/__init__.py	2007-05-06 10:41:20 UTC (rev 75545)
@@ -33,4 +33,3 @@
 
     allow_class(Session)
     allow_class(Query)
-

Modified: Products.SQLAlchemyDA/trunk/da.py
===================================================================
--- Products.SQLAlchemyDA/trunk/da.py	2007-05-06 10:36:40 UTC (rev 75544)
+++ Products.SQLAlchemyDA/trunk/da.py	2007-05-06 10:41:20 UTC (rev 75545)
@@ -92,7 +92,7 @@
     def getInfo(self):
         """ return a dict with additional information """
         d = self._wrapper.kw
-        d['DSN'] = wrapper.dsn
+        d['DSN'] = self._wrapper.dsn
         return d
 
 
@@ -182,6 +182,22 @@
         return self._wrapper._engine.connection_provider._pool.checkedin() > 0
 
 
+    security.declareProtected(view_management_screens, 'manage_start')
+    def manage_start(self, RESPONSE=None):
+        """ start engine """               
+        try:
+            self.query('BEGIN; COMMIT;');
+            if RESPONSE:
+                msg = 'Database connection opened'
+                RESPONSE.redirect(self.absolute_url() + '/manage_workspace?manage_tabs_message=%s' % msg)
+        except Exception, e:
+            if RESPONSE:
+                msg = 'Database connection could not be opened (%s)' % e
+                RESPONSE.redirect(self.absolute_url() + '/manage_workspace?manage_tabs_message=%s' % msg)
+            else: 
+                raise
+
+
     security.declareProtected(view_management_screens, 'manage_stop')
     def manage_stop(self, RESPONSE=None):
         """ close engine """

Modified: Products.SQLAlchemyDA/trunk/pt/info.zpt
===================================================================
--- Products.SQLAlchemyDA/trunk/pt/info.zpt	2007-05-06 10:36:40 UTC (rev 75544)
+++ Products.SQLAlchemyDA/trunk/pt/info.zpt	2007-05-06 10:41:20 UTC (rev 75545)
@@ -5,26 +5,30 @@
        tal:define="info_d context/getInfo">
     <tbody>
         <tr>
-            <td class="form-label">Name</td>:
+            <td class="form-label">Name</td>
             <td class="list-item" tal:content="context/getId" />
         </tr>
 
         <tr>
-            <td class="form-label">Connected</td>:
+            <td class="form-label">Connected</td>
             <td class="list-item" tal:content="context/connected" />
         </tr>
 
         <tr tal:repeat="k info_d">
-            <td class="form-label" tal:content="k"/>:
+            <td class="form-label" tal:content="k"/>
             <td class="list-item" tal:content="info_d/?k" />
         </tr>
     </tbody>
 </table>
 
-<form action="manage_stop" tal:condition="context/connected">
-    <input type="submit" value="Close connections"/>
+<form action="manage_stop" method="POST" tal:condition="context/connected">
+    <input type="submit" value="Close connections"/> 
 </form>
 
+<form action="manage_start" method="POST" tal:condition="not: context/connected">
+    <input type="submit" value="Open connections"/> 
+</form>
+
 <hr>
 <div style="font-size: 80%; text-align: center" >
 Written by Andreas Jung for <a href="http://www.zopyx.com">ZOPYX Ltd. & Co. KG</a>, D-72070 Tuebingen, Germany.



More information about the Checkins mailing list