Skip to content

Commit

Permalink
Update to latest version of everything, including the working big_tab…
Browse files Browse the repository at this point in the history
…le_servlet_store.
  • Loading branch information
olabini committed Mar 23, 2009
1 parent 91a1a33 commit b755ebc
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 54 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application.rb
Expand Up @@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base

# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => 'a1f3524526e38614030fe844529da315'
# protect_from_forgery :secret => 'a1f3524526e38614030fe844529da315'

# See ActionController::Base for details
# Uncomment this to filter the contents of submitted sensitive data parameters
Expand Down
2 changes: 1 addition & 1 deletion appengine-web.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>yarubyblog</application>
<version>1</version>
<version>2</version>
<static-files />
<resource-files />
<sessions-enabled>true</sessions-enabled>
Expand Down
5 changes: 3 additions & 2 deletions config/environment.rb
Expand Up @@ -10,7 +10,7 @@
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

#require 'big_table_servlet_store'
require 'big_table_servlet_store'

Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
Expand Down Expand Up @@ -64,7 +64,8 @@
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rake db:sessions:create")
# config.action_controller.session_store = :big_table_servlet_store

config.action_controller.session_store = :big_table_servlet_store

# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
Expand Down
2 changes: 2 additions & 0 deletions config/warble.rb
Expand Up @@ -75,6 +75,8 @@
# the pool will grow as needed to service requests. It is recommended
# that you fix these values when running a production server!
config.webxml.jruby.min.runtimes = 1
config.webxml.jruby.max.runtimes = 2
config.webxml.jruby.runtime.initializer.threads = 1
# config.webxml.jruby.max.runtimes = 4

# JNDI data source name
Expand Down
101 changes: 51 additions & 50 deletions lib/big_table_servlet_store.rb
@@ -1,52 +1,53 @@
# $servlet_context.log("LOOOOOOOOOOOOOOOOOOOOOOOOOOOADING BigTableServletStore")

# include_class "com.google.appengine.api.datastore.DatastoreServiceFactory"

# class CGI #:nodoc:all
# class Session
# class BigTableServletStore
# DATASTORE = DatastoreServiceFactory.datastore_service
module Google
import com.google.appengine.api.datastore.DatastoreServiceFactory
import com.google.appengine.api.datastore.Entity
import com.google.appengine.api.datastore.KeyFactory
import com.google.appengine.api.datastore.Key
import com.google.appengine.api.datastore.EntityNotFoundException
end

class CGI #:nodoc:all
class Session
class BigTableServletStore
DATASTORE = Google::DatastoreServiceFactory.datastore_service
RAILS_SESSION_ENTITY = "__current_rails_session"
RAILS_SESSION_KEY = "__rails_session_data"

# def initialize(session, option=nil)
# $servlet_context.log("BigTableServletStore.initialize")
# end

# def restore
# $servlet_context.log("BigTableServletStore.restore")
# end

# def update
# $servlet_context.log("BigTableServletStore.update")
# end

# def close
# $servlet_context.log("BigTableServletStore.close")
# end

# def delete
# $servlet_context.log("BigTableServletStore.delete")
# end

# def data
# $servlet_context.log("BigTableServletStore.data")
# end

# def []=(k, v)
# $servlet_context.log("BigTableServletStore.[]=")
# end

# def [](k)
# $servlet_context.log("BigTableServletStore.[]")
# end

# def each(&b)
# $servlet_context.log("BigTableServletStore.each")
# end

# private
# # Attempts to redirect any messages to the data object.
# def method_missing(name, *args, &block)
# end
# end
# end
# end
def initialize(session, option=nil)
@session_id = session.session_id
@key = Google::KeyFactory.create_key(RAILS_SESSION_ENTITY, @session_id)
@data = {}
end
def marshal(data) ActiveSupport::Base64.encode64(Marshal.dump(data)) if data end
def unmarshal(data) Marshal.load(ActiveSupport::Base64.decode64(data)) if data end

# Restore session state from the big table session
def restore
begin
entity = DATASTORE.get(@key)
if entity.has_property(RAILS_SESSION_KEY)
@data = unmarshal(entity.get_property(RAILS_SESSION_KEY))
end
rescue Google::EntityNotFoundException
end

@data
end

def update
entity = Google::Entity.new(RAILS_SESSION_ENTITY, @session_id)
entity.set_property(RAILS_SESSION_KEY, marshal(@data))
DATASTORE.put(entity)
end

def close
update
end

def delete
DATASTORE.delete(@key)
end
end
end
end

0 comments on commit b755ebc

Please sign in to comment.