ruby-session-devel-cvs Mailing List for ruby-session: Got persistance? (Page 2)
Status: Alpha
Brought to you by:
thetitan
You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(14) |
Sep
(2) |
Oct
|
Nov
(5) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(13) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Sean C. <the...@us...> - 2001-08-25 19:55:30
|
Update of /cvsroot/ruby-session/ruby-session
In directory usw-pr-cvs1:/tmp/cvs-serv29314
Modified Files:
LICENSE
Log Message:
Fixd speling erors
Index: LICENSE
===================================================================
RCS file: /cvsroot/ruby-session/ruby-session/LICENSE,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LICENSE 2001/08/25 10:30:57 1.1
+++ LICENSE 2001/08/25 19:55:27 1.2
@@ -14,7 +14,7 @@
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
- must display the following acknowledgement:
+ must display the following acknowledgment:
This product includes software developed by Sean Chittenden
<se...@ch...> and ruby-session's contributors.
|
|
From: Sean C. <the...@us...> - 2001-08-25 19:54:58
|
Update of /cvsroot/ruby-session/ruby-session/src/apache/session
In directory usw-pr-cvs1:/tmp/cvs-serv29031
Modified Files:
file.rb
Log Message:
Added more functionality... should be a good prototype for future persistence
modules
Fixd speling erors
Index: file.rb
===================================================================
RCS file: /cvsroot/ruby-session/ruby-session/src/apache/session/file.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- file.rb 2001/08/25 10:31:52 1.1
+++ file.rb 2001/08/25 19:54:56 1.2
@@ -1,6 +1,6 @@
#!/usr/local/bin/ruby -w
-# ruby-session: Got persistance?
+# ruby-session: Got persistence?
# Copyright 2001
# Sean Chittenden <se...@ch...>. All rights reserved.
@@ -14,10 +14,10 @@
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
-# must display the following acknowledgement:
+# must display the following acknowledgment:
#
# This product includes software developed by Sean Chittenden
-# <se...@ch...> and ruby-tmpl's contributors.
+# <se...@ch...> and ruby-session's contributors.
#
# 4. Neither the name of the software nor the names of its contributors
# may be used to endorse or promote products derived from this software
@@ -47,12 +47,6 @@
protected
- def make_location ()
- @location = File.join(@session_dir, ".ruby-session-#{@session_id}")
- return(@location)
- end
-
-
def _delete ()
begin
File.delete(@location)
@@ -60,8 +54,40 @@
raise RuntimeError, "Unable to delete session #{@session_id}"
end
end
+ # End: def _delete ()
+
+
+ def Session._exist? (location)
+ begin
+ File.stat(location).readable?
+ return(true)
+ rescue Errno::ENOENT
+ return(false)
+ end
+ # End: begin
+ end
+ # End: def Session._exist? ()
+ def _exist? ()
+ return(Session._exist?(@location))
+ end
+ # End: def _exist? ()
+
+
+ def Session._make_location (*args)
+ session_id, session_dir = args.flatten
+ return(File.join(session_dir, ".ruby-session-#{session_id}"))
+ end
+ # End: def Session._make_location ()
+
+
+ def make_location (session_id = @session_id, session_dir = @session_dir)
+ return(Session._make_location(session_id, session_dir))
+ end
+ # End: def make_location ()
+
+
def _persist ()
self.make_location() unless(@location)
@@ -89,6 +115,7 @@
end
end
# End: def _restore ()
+
private
|
|
From: Sean C. <the...@us...> - 2001-08-25 10:31:54
|
Update of /cvsroot/ruby-session/ruby-session/src/apache/session
In directory usw-pr-cvs1:/tmp/cvs-serv2396/src/apache/session
Added Files:
file.rb
Log Message:
Checking in initial work for ruby-session. Has support for file based sessions.
Status: functional
--- NEW FILE: file.rb ---
#!/usr/local/bin/ruby -w
# ruby-session: Got persistance?
# Copyright 2001
# Sean Chittenden <se...@ch...>. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
#
# This product includes software developed by Sean Chittenden
# <se...@ch...> and ruby-tmpl's contributors.
#
# 4. Neither the name of the software nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Please see the LICENSE file for more information regarding the use
# and distribution of this software.
#
# $Id: file.rb,v 1.1 2001/08/25 10:31:52 thetitan Exp $
module Apache
class Session
public
protected
def make_location ()
@location = File.join(@session_dir, ".ruby-session-#{@session_id}")
return(@location)
end
def _delete ()
begin
File.delete(@location)
rescue Errno::ENOENT
raise RuntimeError, "Unable to delete session #{@session_id}"
end
end
def _persist ()
self.make_location() unless(@location)
begin
f = File.new(@location, File::CREAT|File::TRUNC|File::WRONLY|File::EXCL, 0600)
Marshal.dump(@data, f)
f.close()
rescue Errno::EEXIST
self.restore
f = File.new(@location, File::TRUNC|File::WRONLY, 0600)
Marshal.dump(@data, f)
f.close()
end
end
# End: def _persist ()
def _restore ()
begin
f = File.new(@location, File::RDONLY)
@data.update(Marshal.load(f))
f.close
rescue Errno::ENOENT
raise RuntimeError, "Can not restore session '#{@session_id}': session does not valid"
end
end
# End: def _restore ()
private
end
# End: module Session
end
# End: module Apache
|
|
From: Sean C. <the...@us...> - 2001-08-25 10:31:54
|
Update of /cvsroot/ruby-session/ruby-session/src/apache
In directory usw-pr-cvs1:/tmp/cvs-serv2396/src/apache
Added Files:
session.rb
Log Message:
Checking in initial work for ruby-session. Has support for file based sessions.
Status: functional
--- NEW FILE: session.rb ---
#!/usr/local/bin/ruby -w
# ruby-session: Got persistance?
# Copyright 2001
# Sean Chittenden <se...@ch...>. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
#
# This product includes software developed by Sean Chittenden
# <se...@ch...> and ruby-tmpl's contributors.
#
# 4. Neither the name of the software nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Please see the LICENSE file for more information regarding the use
# and distribution of this software.
#
# $Id: session.rb,v 1.1 2001/08/25 10:31:52 thetitan Exp $
module Apache
class Session
attr_accessor :data, :expired, :session_dir, :session_id
attr_reader :location, :session_id_length, :start_time, :type
public
def [] (key)
return(@data[key])
end
def []= (key, value)
return(@data[key] = value)
end
def delete ()
self.make_location unless(@location)
self._delete()
end
def generate ()
require 'digest/md5'
md5digest = Digest::MD5.new
md5digest.update(Time.now.to_f.to_s + rand.to_s + $$.to_s)
@session_id = md5digest.hexdigest
return(@session_id)
end
def persist ()
self.make_location() unless(@location)
@data['__ruby_session_expired__'] = (@expired ? 'y' : 'n')
@data['__ruby_session_start_time__'] = @start_time.to_f.to_s
self._persist()
@data.delete('__ruby_session_expired__')
@data.delete('__ruby_session_start_time__')
end
def restore ()
self.make_location() unless(@location)
self._restore()
@expired = (@data.delete('__ruby_session_expired__') == 'y' ? true : false)
@start_time = Time.at(@data.delete('__ruby_session_start_time__').to_f)
end
# End: def restore ()
def type= (type)
@type = type.downcase
begin
require File.join('apache', 'session', @type)
rescue LoadError
raise LoadError, "Invalid Session Type '#{type}'"
end
end
private
def initialize (options = {})
@data = (options.has_key?('session_data') ? options['session_data'] : {})
@expired = false
@location = nil
@session_dir = (options.has_key?('session_dir') ? options['session_dir'] : '/tmp')
@session_id = nil
@start_time = Time.now
@type = nil
self.type = (options.has_key?('type') ? options['type'] : 'file')
if options.has_key?('session_id')
@session_id = options['session_id']
self.restore()
else
@session_id = self.generate
end
# End: if options.has_key?('session_id')
end
# End: def initialize ()
end
# End: class Session
end
# End: module Apache
|
|
From: Sean C. <the...@us...> - 2001-08-25 10:31:00
|
Update of /cvsroot/ruby-session/ruby-session
In directory usw-pr-cvs1:/tmp/cvs-serv2319
Added Files:
LICENSE
Log Message:
Adding a LICENSE to ruby-session
--- NEW FILE: LICENSE ---
# $Id: LICENSE,v 1.1 2001/08/25 10:30:57 thetitan Exp $
All of the documentation and software included in ruby-session releases is
copyrighted by Sean Chittenden <se...@ch...>
Copyright 2001
Sean Chittenden <se...@ch...>. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by Sean Chittenden
<se...@ch...> and ruby-session's contributors.
4. Neither the name of the software nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
If you have any questions regarding the redistribution of this software,
please contact the author at <se...@ch...>.
|
|
From: Sean C. <the...@us...> - 2001-08-25 02:40:06
|
Update of /cvsroot/ruby-session/ruby-session/src/apache/session In directory usw-pr-cvs1:/tmp/cvs-serv16712/session Log Message: Directory /cvsroot/ruby-session/ruby-session/src/apache/session added to the repository |
|
From: Sean C. <the...@us...> - 2001-08-25 02:39:39
|
Update of /cvsroot/ruby-session/ruby-session/src/apache In directory usw-pr-cvs1:/tmp/cvs-serv16610/apache Log Message: Directory /cvsroot/ruby-session/ruby-session/src/apache added to the repository |
|
From: Sean C. <the...@us...> - 2001-08-24 20:58:15
|
Update of /cvsroot/ruby-session/www/tmpl In directory usw-pr-cvs1:/tmp/cvs-serv16116/tmpl Log Message: Directory /cvsroot/ruby-session/www/tmpl added to the repository |
|
From: Sean C. <the...@us...> - 2001-08-24 20:48:33
|
Update of /cvsroot/ruby-session/ruby-session/src In directory usw-pr-cvs1:/tmp/cvs-serv13687/src Log Message: Directory /cvsroot/ruby-session/ruby-session/src added to the repository |