Changes between Version 1 and Version 2 of TracSqlAlchemyBridgeIntegration
- Timestamp:
- Jul 12, 2008, 10:21:03 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracSqlAlchemyBridgeIntegration
v1 v2 16 16 17 17 Download the zipped source from [download:tracsqlalchemybridgeintegration here]. 18 19 Download from [http://pypi.python.org/ PyPi] from [http://pypi.python.org/pypi/TracSqlAlchemyBridge/ here]. 18 20 19 21 == Source == … … 44 46 def environment_needs_upgrade(self, db): 45 47 cursor = db.cursor() 46 cursor.execute( "SELECT value FROM system WHERE name=%s",48 cursor.execute("SELECT value FROM system WHERE name=%s";, 47 49 (model.name,)) 48 50 value = cursor.fetchone() … … 52 54 else: 53 55 self.found_db_version = int(value[0]) 54 self.log.debug( "%s: Found db version %s, current is %s",56 self.log.debug("%s: Found db version %s, current is %s", 55 57 __package__, self.found_db_version, model.version) 56 return self.found_db_version <model.version58 return self.found_db_version < model.version 57 59 58 60 def upgrade_environment(self, db): … … 61 63 cursor = db.cursor() 62 64 if not self.found_db_version: 63 cursor.execute( "INSERT INTO system (name, value) VALUES (%s, %s)",65 cursor.execute("INSERT INTO system (name, value) VALUES (%s, %s)", 64 66 (model.name, model.version)) 65 67 else: 66 cursor.execute( "UPDATE system SET value=%s WHERE name=%s",68 cursor.execute("UPDATE system SET value=%s WHERE name=%s", 67 69 (model.version, model.name)) 68 70 }}} 69 71 70 Then to use it in your code( (rom the plugin I was developing from which this package was born):72 Then to use it in your code(from the plugin I was developing from which this package was born): 71 73 {{{ 72 74 #!python 73 75 74 #--------8 <------- code cut for readability --------8<-------76 #--------8<------- code cut for readability --------8<------- 75 77 from tsab import session 76 #--------8 <------- code cut for readability --------8<-------78 #--------8<------- code cut for readability --------8<------- 77 79 class L10nModule(Component): 78 #--------8 <------- code cut for readability --------8<-------80 #--------8<------- code cut for readability --------8<------- 79 81 def _list_messages(self, req, catalog_id, locale_name, page): 80 82 Session = session(self.env) … … 105 107 _('Previous Page')) 106 108 return 'l10n_messages.html', data, None 107 #--------8 <------- code cut for readability --------8<-------109 #--------8<------- code cut for readability --------8<------- 108 110 }}} 109 111 … … 116 118 == Author/Contributors == 117 119 118 '''Author:''' [wiki: s0undt3ch] [[BR]]120 '''Author:''' [wiki:mitsuhiko], [wiki:s0undt3ch] [[BR]] 119 121 '''Contributors:'''