<commit_before>package xt.middleware

import scala.collection.mutable.Map

import org.jboss.netty.channel.Channel
import org.jboss.netty.handler.codec.http.{HttpRequest, HttpResponse}

import org.squeryl.{SessionFactory, Session}
import org.squeryl.adapters.{MySQLAdapter, OracleAdapter, PostgreSqlAdapter}
import org.squeryl.PrimitiveTypeMode._

import com.mchange.v2.c3p0.ComboPooledDataSource

/**
 * This middleware:
 */
object Squeryl {
  /**
   * @param driver: postgresql, mysql, or oracle
   */
  def wrap(app: App) = {
    setupDB
    new App {
      def call(channel: Channel, request: HttpRequest, response: HttpResponse, env: Map[String, Any]) {
        // The connection will be closed here after the transaction
        inTransaction {
          //org.squeryl.Session.currentSession.setLogger(s => println(s))
          app.call(channel, request, response, env)
        }
      }
    }
  }
<commit_msg>Use transaction instead of inTransaction<commit_after>package xt.middleware

import scala.collection.mutable.Map

import org.jboss.netty.channel.Channel
import org.jboss.netty.handler.codec.http.{HttpRequest, HttpResponse}

import org.squeryl.{SessionFactory, Session}
import org.squeryl.adapters.{MySQLAdapter, OracleAdapter, PostgreSqlAdapter}
import org.squeryl.PrimitiveTypeMode._

import com.mchange.v2.c3p0.ComboPooledDataSource

/**
 * This middleware:
 */
object Squeryl {
  /**
   * @param driver: postgresql, mysql, or oracle
   */
  def wrap(app: App) = {
    setupDB
    new App {
      def call(channel: Channel, request: HttpRequest, response: HttpResponse, env: Map[String, Any]) {
        // Do not use inTransaction because we want the session to be unbound:
        // http://groups.google.com/group/squeryl/browse_thread/thread/e7fe581f7f5f61f9
        //
        // The connection will be closed here after the transaction
        transaction {
          //org.squeryl.Session.currentSession.setLogger(s => println(s))
          app.call(channel, request, response, env)
        }
      }
    }
  }

{'fraction_non_alphanumeric': 0.10761670761670762, 'fraction_numerical': 0.007371007371007371, 'mean_word_length': 3.3135593220338984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7648460', 'n_tokens_mistral': 648, 'n_tokens_neox': 642, 'n_words': 141}