nitro 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +3 -0
- data/ChangeLog +83 -0
- data/LICENCE +8 -8
- data/README +5 -1
- data/RELEASES +9 -0
- data/Rakefile +43 -23
- data/bin/cluster.rb +15 -12
- data/examples/ndb/README +5 -0
- data/examples/ndb/run.rb +271 -0
- data/examples/simple/README +27 -0
- data/examples/simple/app.rb +2 -2
- data/examples/simple/conf/config.rb +3 -8
- data/examples/simple/conf/debug-config.rb +6 -7
- data/examples/simple/conf/live-config.rb +2 -4
- data/examples/simple/conf/requires.rb +2 -10
- data/examples/simple/ctl +1 -1
- data/examples/simple/env.rb +2 -2
- data/examples/simple/root/article-form.ss +1 -1
- data/examples/simple/root/comments-form.ss +1 -1
- data/examples/tiny/README +15 -0
- data/examples/tiny/app.rb +2 -2
- data/examples/tiny/conf/config.rb +8 -13
- data/examples/tiny/conf/requires.rb +2 -8
- data/examples/tiny/ctl +2 -17
- data/examples/tiny/root/index.sx +1 -1
- data/lib/n/app/cluster.rb +15 -12
- data/lib/n/app/cookie.rb +10 -9
- data/lib/n/app/filters/autologin.rb +5 -4
- data/lib/n/app/fragment.rb +13 -10
- data/lib/n/app/handlers.rb +29 -22
- data/lib/n/app/handlers/code-handler.rb +2 -4
- data/lib/n/app/handlers/page-handler.rb +3 -5
- data/lib/n/app/request-part.rb +2 -7
- data/lib/n/app/request.rb +27 -22
- data/lib/n/app/script.rb +4 -15
- data/lib/n/app/server.rb +11 -7
- data/lib/n/app/session.rb +7 -11
- data/lib/n/app/user.rb +10 -11
- data/lib/n/app/webrick-servlet.rb +23 -10
- data/lib/n/app/webrick.rb +13 -10
- data/lib/n/application.rb +13 -6
- data/lib/n/config.rb +18 -7
- data/lib/n/db.rb +56 -40
- data/lib/n/db/connection.rb +18 -22
- data/lib/n/db/managed.rb +6 -8
- data/lib/n/db/mixins.rb +4 -7
- data/lib/n/db/mysql.rb +6 -3
- data/lib/n/db/psql.rb +15 -10
- data/lib/n/db/tools.rb +5 -9
- data/lib/n/db/utils.rb +11 -8
- data/lib/n/events.rb +14 -10
- data/lib/n/logger.rb +8 -2
- data/lib/n/macros.rb +5 -2
- data/lib/n/parts.rb +13 -10
- data/lib/n/properties.rb +17 -12
- data/lib/n/server.rb +3 -2
- data/lib/n/server/filter.rb +2 -4
- data/lib/n/shaders.rb +11 -13
- data/lib/n/sitemap.rb +23 -20
- data/lib/n/std.rb +15 -4
- data/lib/n/sync/clc.rb +4 -2
- data/lib/n/sync/handler.rb +20 -12
- data/lib/n/sync/server.rb +24 -18
- data/lib/n/ui/date-select.rb +2 -4
- data/lib/n/ui/pager.rb +10 -8
- data/lib/n/ui/popup.rb +5 -4
- data/lib/n/ui/select.rb +3 -4
- data/lib/n/ui/tabs.rb +3 -4
- data/lib/n/utils/array.rb +6 -14
- data/lib/n/utils/cache.rb +3 -7
- data/lib/n/utils/gfx.rb +5 -6
- data/lib/n/utils/hash.rb +7 -12
- data/lib/n/utils/html.rb +8 -4
- data/lib/n/utils/http.rb +10 -6
- data/lib/n/utils/mail.rb +6 -6
- data/lib/n/utils/number.rb +3 -4
- data/lib/n/utils/pool.rb +5 -8
- data/lib/n/utils/string.rb +12 -10
- data/lib/n/utils/template.rb +3 -5
- data/lib/n/utils/time.rb +7 -5
- data/lib/n/utils/uri.rb +5 -4
- data/lib/p/README +1 -0
- data/lib/xsl/xforms.xsl +2 -0
- data/test/n/app/tc_cookie.rb +34 -0
- data/test/n/app/tc_request.rb +70 -0
- data/test/n/app/tc_requestpart.rb +28 -0
- data/test/n/app/tc_session.rb +34 -0
- data/test/n/tc_db.rb +223 -0
- data/test/n/tc_db_mysql.rb +241 -0
- data/test/n/tc_events.rb +44 -0
- data/test/n/tc_properties.rb +68 -0
- data/test/n/tc_sitemap.rb +37 -0
- data/test/n/ui/tc_pager.rb +52 -0
- data/test/n/utils/tc_cache.rb +47 -0
- data/test/n/utils/tc_hash.rb +39 -0
- data/test/n/utils/tc_html.rb +79 -0
- data/test/n/utils/tc_http.rb +18 -0
- data/test/n/utils/tc_number.rb +21 -0
- data/test/n/utils/tc_strings.rb +149 -0
- data/test/n/utils/tc_uri.rb +100 -0
- metadata +49 -22
- data/doc/css.txt +0 -20
- data/doc/ideas.txt +0 -120
- data/doc/pg.txt +0 -47
- data/doc/svn.txt +0 -82
- data/doc/todo.txt +0 -30
- data/examples/simple/conf/overrides.rb +0 -9
- data/examples/simple/logs/access_log +0 -2
- data/examples/simple/logs/apache.log +0 -3
- data/examples/simple/logs/app.log +0 -1
- data/examples/simple/logs/events.log +0 -1
- data/examples/tiny/conf/apache.conf +0 -100
- data/examples/tiny/logs/access_log +0 -9
- data/examples/tiny/logs/apache.log +0 -9
- data/lib/n/db/make-release.sh +0 -26
- data/lib/n/tools/README +0 -11
- data/lib/xsl/ce.xsl +0 -30
- data/lib/xsl/localization.xsl +0 -23
- data/test/run.rb +0 -95
data/lib/n/app/user.rb
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
# = User
|
|
2
|
-
#
|
|
3
|
-
# A user of the Web Application. This is a base object, typically
|
|
4
|
-
# extended by the users part.
|
|
5
|
-
#
|
|
6
|
-
#--
|
|
7
1
|
# code:
|
|
8
|
-
# George Moschovitis <gm@navel.gr>
|
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
|
9
3
|
#
|
|
10
|
-
# (c)
|
|
11
|
-
# $Id: user.rb
|
|
12
|
-
#++
|
|
4
|
+
# (c) 2004 Navel, all rights reserved.
|
|
5
|
+
# $Id: user.rb 99 2004-10-22 09:50:28Z gmosx $
|
|
13
6
|
|
|
14
7
|
require "singleton"
|
|
15
8
|
|
|
@@ -17,6 +10,9 @@ module N
|
|
|
17
10
|
|
|
18
11
|
# = Anonymous User
|
|
19
12
|
#
|
|
13
|
+
# An anonymous user of the Web Application. This is a base
|
|
14
|
+
# object, typically extended by the users part.
|
|
15
|
+
#
|
|
20
16
|
# Implemented as singleton.
|
|
21
17
|
#
|
|
22
18
|
class AnonymousUser
|
|
@@ -38,10 +34,13 @@ class AnonymousUser
|
|
|
38
34
|
end
|
|
39
35
|
|
|
40
36
|
def login
|
|
37
|
+
# nop
|
|
41
38
|
end
|
|
42
39
|
|
|
43
40
|
def logout
|
|
44
|
-
|
|
41
|
+
# nop
|
|
42
|
+
end
|
|
43
|
+
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
end # module
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
# = Webrick Servlet.
|
|
2
|
-
#
|
|
3
1
|
# code:
|
|
4
|
-
# George Moschovitis <gm@navel.gr>
|
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
|
5
3
|
#
|
|
6
4
|
# (c) 2004 Navel, all rights reserved.
|
|
7
|
-
# $Id: webrick-servlet.rb
|
|
5
|
+
# $Id: webrick-servlet.rb 106 2004-10-25 11:31:11Z gmosx $
|
|
8
6
|
|
|
9
7
|
require "drb"
|
|
10
8
|
require "singleton"
|
|
@@ -18,7 +16,7 @@ require "n/app/handlers"
|
|
|
18
16
|
require "n/app/session"
|
|
19
17
|
|
|
20
18
|
# Override WEBrick to suit our needs.
|
|
21
|
-
|
|
19
|
+
#
|
|
22
20
|
module WEBrick
|
|
23
21
|
class HTTPRequest
|
|
24
22
|
alias_method :old_parse_uri, :parse_uri
|
|
@@ -43,6 +41,8 @@ module WEBrick
|
|
|
43
41
|
end
|
|
44
42
|
end
|
|
45
43
|
|
|
44
|
+
# Expose some response variables.
|
|
45
|
+
#
|
|
46
46
|
class HTTPResponse
|
|
47
47
|
attr_writer :header
|
|
48
48
|
attr_writer :cookies
|
|
@@ -53,15 +53,26 @@ module N; module App
|
|
|
53
53
|
|
|
54
54
|
# = WebrickServlet
|
|
55
55
|
#
|
|
56
|
+
# A webrick servlet that implements the Nitro Engine.
|
|
57
|
+
#
|
|
58
|
+
# TODO: Lots of stuff should be factored out!
|
|
59
|
+
#
|
|
56
60
|
class WebrickServlet < WEBrick::HTTPServlet::AbstractServlet
|
|
57
61
|
include WEBrick
|
|
58
62
|
|
|
63
|
+
# Handle a HTTP GET request.
|
|
64
|
+
#
|
|
59
65
|
def do_GET(wreq, wres)
|
|
60
66
|
request = create_request(wreq)
|
|
61
67
|
request.session = create_session(request)
|
|
62
68
|
|
|
63
69
|
extension = N::StringUtils.extension_from_path(request.path)
|
|
64
|
-
handler = $srv_extension_map[extension]
|
|
70
|
+
if handler = $srv_extension_map[extension]
|
|
71
|
+
handler = handler[1]
|
|
72
|
+
else
|
|
73
|
+
$log.error "Cannot handle '#{request.path}'"
|
|
74
|
+
return nil
|
|
75
|
+
end
|
|
65
76
|
|
|
66
77
|
begin
|
|
67
78
|
fragment, script = handler.process(request)
|
|
@@ -117,6 +128,8 @@ class WebrickServlet < WEBrick::HTTPServlet::AbstractServlet
|
|
|
117
128
|
wres.body = request.out_buffer
|
|
118
129
|
end
|
|
119
130
|
|
|
131
|
+
# Just reuse the GET code.
|
|
132
|
+
#
|
|
120
133
|
def do_POST(wreq, wres)
|
|
121
134
|
do_GET(wreq, wres)
|
|
122
135
|
end
|
|
@@ -135,12 +148,13 @@ class WebrickServlet < WEBrick::HTTPServlet::AbstractServlet
|
|
|
135
148
|
request.uri = wreq.unparsed_uri
|
|
136
149
|
request.translated_uri = wreq.path_info
|
|
137
150
|
request.path = wreq.path
|
|
151
|
+
# enforce filename if missing, FIXME: improve this.
|
|
152
|
+
request.path << $index_filename if request.path[-1] == ?/
|
|
138
153
|
# request.path_info = wreq.path_info
|
|
139
154
|
request.query_string = wreq.query_string
|
|
140
155
|
request.method = wreq.request_method
|
|
141
|
-
#
|
|
142
|
-
|
|
143
|
-
request.remote_addr = wreq["X-FORWARDED-FOR"]
|
|
156
|
+
# gmosx: X-FORWARDED-FOR is used in a proxy configuration.
|
|
157
|
+
request.remote_addr = wreq["X-FORWARDED-FOR"] || wreq["REMOTE_ADDR"]
|
|
144
158
|
|
|
145
159
|
# gmosx: remove this ??
|
|
146
160
|
request.in = {}
|
|
@@ -170,7 +184,6 @@ class WebrickServlet < WEBrick::HTTPServlet::AbstractServlet
|
|
|
170
184
|
# INVESTIGATE, FIXME: this is a hack!
|
|
171
185
|
# apache prepends $srv_url and fucks up msie.
|
|
172
186
|
# FIXME: add unit test for this!
|
|
173
|
-
|
|
174
187
|
if ref = request.in["REFERER"]
|
|
175
188
|
split_re = Regexp.new($srv_url) unless split_re
|
|
176
189
|
xref = ref.split(split_re).last
|
data/lib/n/app/webrick.rb
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# code:: gmosx, elathan
|
|
1
|
+
# code:
|
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
|
3
|
+
# * Elias Athanasopoulos <elathan@navel.gr>
|
|
6
4
|
#
|
|
7
5
|
# (c) 2004 Navel, all rights reserved.
|
|
8
|
-
# $Id: webrick.rb
|
|
6
|
+
# $Id: webrick.rb 106 2004-10-25 11:31:11Z gmosx $
|
|
9
7
|
|
|
10
8
|
require "drb"
|
|
11
9
|
require "cgi"
|
|
@@ -24,17 +22,20 @@ module N; module App
|
|
|
24
22
|
# Dont keepalive (or use a VERY SMALL keepalive). Typically this server
|
|
25
23
|
# is used along with a standard http server that handles other resources.
|
|
26
24
|
#
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
# Used temporarily unitl we build our own app server.
|
|
26
|
+
#
|
|
27
|
+
class Webrick < N::App::Server
|
|
29
28
|
include WEBrick
|
|
30
29
|
|
|
30
|
+
# the integrated webrock server.
|
|
31
31
|
attr_accessor :webrick
|
|
32
32
|
|
|
33
33
|
def initialize(name = "WebrickServer")
|
|
34
34
|
super
|
|
35
|
-
initialize_app()
|
|
36
35
|
end
|
|
37
36
|
|
|
37
|
+
# Start the application server.
|
|
38
|
+
#
|
|
38
39
|
def start
|
|
39
40
|
accesslog = WEBrick::BasicLog::new("/dev/null")
|
|
40
41
|
referer = WEBrick::BasicLog::new("/dev/null")
|
|
@@ -42,7 +43,7 @@ class Webrick < N::Server
|
|
|
42
43
|
@webrick = HTTPServer.new(
|
|
43
44
|
:BindAddress => $appsrv_address,
|
|
44
45
|
:Port => $appsrv_port,
|
|
45
|
-
:
|
|
46
|
+
:DocumentRoot => $root_dir,
|
|
46
47
|
# gmosx, FIXME: this shit still logs!!
|
|
47
48
|
:Logger => Log.new(nil, WEBrick::Log::WARN),
|
|
48
49
|
# elathan: amateur...
|
|
@@ -61,6 +62,8 @@ class Webrick < N::Server
|
|
|
61
62
|
@webrick.start()
|
|
62
63
|
end
|
|
63
64
|
|
|
65
|
+
# Stop the application server.
|
|
66
|
+
#
|
|
64
67
|
def stop
|
|
65
68
|
@webrick.stop
|
|
66
69
|
end
|
data/lib/n/application.rb
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# = Application
|
|
2
2
|
#
|
|
3
|
-
#
|
|
3
|
+
# The default Application object of the Framework.
|
|
4
|
+
#
|
|
5
|
+
# code:
|
|
6
|
+
# George Moschovitis <gm@navel.gr>
|
|
7
|
+
# Anastasios Koutoumanos <ak@navel.gr>
|
|
8
|
+
# Elias Athanasopoulos <elathan@navel.gr>
|
|
9
|
+
# Elias Karakoulakis <ekarak@ktismata.com>
|
|
4
10
|
#
|
|
5
11
|
# (c) 2004 Navel, all rights reserved.
|
|
6
|
-
# $Id: application.rb
|
|
12
|
+
# $Id: application.rb 98 2004-10-22 07:36:20Z gmosx $
|
|
7
13
|
|
|
8
14
|
require 'optparse'
|
|
9
15
|
require 'ostruct'
|
|
@@ -15,7 +21,7 @@ module N
|
|
|
15
21
|
|
|
16
22
|
# == Application
|
|
17
23
|
#
|
|
18
|
-
#
|
|
24
|
+
# The default Application object of the Framework.
|
|
19
25
|
#
|
|
20
26
|
class Application
|
|
21
27
|
# credentials of the application
|
|
@@ -31,12 +37,13 @@ class Application
|
|
|
31
37
|
# startup time of the application
|
|
32
38
|
attr_accessor :create_time
|
|
33
39
|
|
|
40
|
+
# is the application daemonized?
|
|
34
41
|
attr_reader :daemonized
|
|
35
42
|
|
|
36
43
|
# the pid of the application
|
|
37
44
|
attr_reader :pid, :pidfile
|
|
38
45
|
|
|
39
|
-
#
|
|
46
|
+
# Intialize method
|
|
40
47
|
#
|
|
41
48
|
def initialize(name = "Unknown")
|
|
42
49
|
@name = name
|
|
@@ -45,8 +52,8 @@ class Application
|
|
|
45
52
|
@status = :stop
|
|
46
53
|
end
|
|
47
54
|
|
|
48
|
-
#
|
|
49
|
-
#
|
|
55
|
+
# Parse the arguments passed to the application.
|
|
56
|
+
# Some standard arguments are handled by default.
|
|
50
57
|
#
|
|
51
58
|
def parse_arguments(args = ARGV)
|
|
52
59
|
|
data/lib/n/config.rb
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
# =
|
|
2
|
-
#
|
|
3
|
-
# Configuration
|
|
1
|
+
# = Configuration
|
|
2
|
+
#
|
|
3
|
+
# Configuration parameters.
|
|
4
4
|
#
|
|
5
5
|
# code:
|
|
6
|
-
# George Moschovitis <gm@navel.gr>
|
|
6
|
+
# * George Moschovitis <gm@navel.gr>
|
|
7
7
|
#
|
|
8
8
|
# (c) 2004 Navel, all rights reserved.
|
|
9
|
-
# $Id: config.rb
|
|
9
|
+
# $Id: config.rb 106 2004-10-25 11:31:11Z gmosx $
|
|
10
10
|
|
|
11
|
+
# the name of the server
|
|
11
12
|
$srv_name = "Nitro"
|
|
12
|
-
$srv_version = "0.1.2"
|
|
13
13
|
|
|
14
|
+
# the version of the server
|
|
15
|
+
$srv_version = "0.2.0"
|
|
16
|
+
|
|
17
|
+
# monitor scripts for changes
|
|
18
|
+
#--
|
|
19
|
+
# gmosx, FIXME: replace this with reload_scripts ??
|
|
20
|
+
#++
|
|
14
21
|
$srv_monitor_scripts = true
|
|
15
|
-
|
|
22
|
+
|
|
23
|
+
# the default file to view in a direcotry
|
|
24
|
+
$index_filename = "index.sx"
|
|
25
|
+
|
|
26
|
+
# seconds till the autologin cookie expires
|
|
16
27
|
$srv_autologin_expires = 60*60*24*30
|
|
17
28
|
|
|
18
29
|
# session timeout (in seconds)
|
data/lib/n/db.rb
CHANGED
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
# = Database
|
|
2
|
-
#
|
|
3
|
-
# An efficient, yet simple Object-Relational Mapper.
|
|
4
|
-
#
|
|
5
|
-
# === Design
|
|
6
|
-
#
|
|
7
|
-
# Keep this class backend agnostic. Put backend specific code in
|
|
8
|
-
# the Connection / Managed class.
|
|
9
|
-
#
|
|
10
|
-
# Try to make the methods work with oids. We do keep
|
|
11
|
-
# a unified id space. Include the N::Sequenced Marker to
|
|
12
|
-
# denote custom id space.
|
|
13
|
-
# Do NOT implement descendants use a root id (rid).
|
|
14
|
-
#
|
|
15
|
-
# For class ids we use the name instead of a hash. Class ids are
|
|
16
|
-
# typically not used in querys, they are stored for completeness.
|
|
17
|
-
# If we store a hash we cannot reclaim the class thus invalidating
|
|
18
|
-
# the point. Instead of .name(), to_s() is used so the methods
|
|
19
|
-
# are more flexible (they accept class names too!!)
|
|
20
|
-
#
|
|
21
|
-
# === WARNING:
|
|
22
|
-
#
|
|
23
|
-
# When creating a new db exec the following:
|
|
24
|
-
# CREATE SEQUENCE oids_seq;
|
|
25
|
-
#
|
|
26
|
-
# or
|
|
27
|
-
#
|
|
28
|
-
# DbTools.create_oids_seq
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
# === Todo
|
|
32
|
-
#
|
|
33
|
-
# - support caching
|
|
34
|
-
# - support prepared statements
|
|
35
|
-
# - foreign keys (delete cascade)
|
|
36
|
-
# - keep attribudes as marshaled!!
|
|
37
|
-
#
|
|
38
1
|
# code:
|
|
39
|
-
# George Moschovitis <gm@navel.gr>
|
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
|
40
3
|
#
|
|
41
4
|
# (c) 2004 Navel, all rights reserved.
|
|
42
|
-
# $Id: db.rb
|
|
5
|
+
# $Id: db.rb 106 2004-10-25 11:31:11Z gmosx $
|
|
43
6
|
|
|
44
7
|
module N;
|
|
45
8
|
|
|
@@ -58,7 +21,59 @@ require "n/db/mixins"
|
|
|
58
21
|
# if true, enables the read only mode
|
|
59
22
|
$db_read_only_mode = false
|
|
60
23
|
|
|
61
|
-
# =
|
|
24
|
+
# = Db
|
|
25
|
+
#
|
|
26
|
+
# An efficient, yet simple Object-Relational Mapper.
|
|
27
|
+
#
|
|
28
|
+
# == Features
|
|
29
|
+
#
|
|
30
|
+
# The library provides the following features:
|
|
31
|
+
#
|
|
32
|
+
# + Object-Relational mapping
|
|
33
|
+
# + Deserialize to Ruby Objects or ResultSets
|
|
34
|
+
# + Deserialize sql join queries to Ruby Objects
|
|
35
|
+
# + Serialize arbitrary ruby object graphs through Marshal
|
|
36
|
+
# + Connection pooling
|
|
37
|
+
# + Thread safety
|
|
38
|
+
# + SQL transactions
|
|
39
|
+
# + Callbacks
|
|
40
|
+
# + Simple support for cascading deletes
|
|
41
|
+
# + Hierarchical structures (preorder traversal, materialized paths)
|
|
42
|
+
# + Works safely as part of distributed application.
|
|
43
|
+
# + Simple implementation < 10k lines of code.
|
|
44
|
+
#
|
|
45
|
+
# === Design
|
|
46
|
+
#
|
|
47
|
+
# Keep this class backend agnostic. Put backend specific code in
|
|
48
|
+
# the Connection / Managed class.
|
|
49
|
+
#
|
|
50
|
+
# Try to make the methods work with oids. We do keep
|
|
51
|
+
# a unified id space. Include the N::Sequenced Marker to
|
|
52
|
+
# denote custom id space.
|
|
53
|
+
# Do NOT implement descendants use a root id (rid).
|
|
54
|
+
#
|
|
55
|
+
# For class ids we use the name instead of a hash. Class ids are
|
|
56
|
+
# typically not used in querys, they are stored for completeness.
|
|
57
|
+
# If we store a hash we cannot reclaim the class thus invalidating
|
|
58
|
+
# the point. Instead of .name(), to_s() is used so the methods
|
|
59
|
+
# are more flexible (they accept class names too!!)
|
|
60
|
+
#
|
|
61
|
+
# Db allows the serialization of arbitrary Ruby objects. Just
|
|
62
|
+
# mark them as Object (or Array or Hash) in the prop_accessor
|
|
63
|
+
# and the engine will serialize a Marshal.dump of the object.
|
|
64
|
+
# Arbitrary object graphs are supported too.
|
|
65
|
+
#
|
|
66
|
+
# === Future
|
|
67
|
+
#
|
|
68
|
+
# * Support multiple DataBase backends (Postgres, MySQL, ...)
|
|
69
|
+
# * Support prepared statements (pgsql)
|
|
70
|
+
# * Support stored procedures (pgsql)
|
|
71
|
+
# * Support caching
|
|
72
|
+
# * Deserialize to OpenStruct
|
|
73
|
+
# * Better documentation
|
|
74
|
+
# * Code cleanup, refactoring
|
|
75
|
+
# * Release as Gem, RPAbase
|
|
76
|
+
# * Foreign keys (cascading delete)
|
|
62
77
|
#
|
|
63
78
|
# === Design:
|
|
64
79
|
#
|
|
@@ -211,6 +226,7 @@ class Db
|
|
|
211
226
|
wrap_method :exec, "sql"
|
|
212
227
|
wrap_method :exec_and_clear, "sql"
|
|
213
228
|
wrap_method :exec_clear, "sql"
|
|
229
|
+
wrap_method :drop_table, "klass"
|
|
214
230
|
end
|
|
215
231
|
|
|
216
232
|
end # module
|
data/lib/n/db/connection.rb
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
# = Database Connection
|
|
2
|
-
#
|
|
3
|
-
# Encapsulates a database connection.
|
|
4
|
-
#
|
|
5
|
-
# === Design
|
|
6
|
-
#
|
|
7
|
-
# Try to make the methods to work with oids.
|
|
8
|
-
# Do NOT implement descendants, use a root id (rid).
|
|
9
|
-
#
|
|
10
|
-
# === Todo
|
|
11
|
-
#
|
|
12
|
-
# - support caching
|
|
13
|
-
# - support prepared statements
|
|
14
|
-
# - foreign keys (delete cascade)
|
|
15
|
-
# - keep attribudes as marshaled!!
|
|
16
|
-
#
|
|
17
|
-
# === Investigate
|
|
18
|
-
#
|
|
19
|
-
# - should we use retry_query ?
|
|
20
|
-
#
|
|
21
1
|
# code:
|
|
22
|
-
# George Moschovitis <gm@navel.gr>
|
|
2
|
+
# * George Moschovitis <gm@navel.gr>
|
|
23
3
|
#
|
|
24
4
|
# (c) 2004 Navel, all rights reserved.
|
|
25
|
-
# $Id: connection.rb
|
|
5
|
+
# $Id: connection.rb 99 2004-10-22 09:50:28Z gmosx $
|
|
26
6
|
|
|
27
7
|
module N;
|
|
28
8
|
|
|
@@ -34,6 +14,22 @@ require "n/utils/time"
|
|
|
34
14
|
#
|
|
35
15
|
# A Connection to the Database.
|
|
36
16
|
#
|
|
17
|
+
# === design
|
|
18
|
+
#
|
|
19
|
+
# try to make the methods to work with oids.
|
|
20
|
+
# do not implement descendants, use a root id (rid).
|
|
21
|
+
#
|
|
22
|
+
# === todo
|
|
23
|
+
#
|
|
24
|
+
# - support caching
|
|
25
|
+
# - support prepared statements
|
|
26
|
+
# - foreign keys (delete cascade)
|
|
27
|
+
# - keep attribudes as marshaled!!
|
|
28
|
+
#
|
|
29
|
+
# === investigate
|
|
30
|
+
#
|
|
31
|
+
# - should we use retry_query ?
|
|
32
|
+
#
|
|
37
33
|
class DbConnection
|
|
38
34
|
include N::DbUtils
|
|
39
35
|
|