nitro 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/ChangeLog +186 -0
  2. data/README +40 -11
  3. data/RELEASES +10 -1
  4. data/Rakefile +5 -4
  5. data/bin/cluster.rb +3 -3
  6. data/{etc/new-project.rb → bin/new_app.rb} +1 -1
  7. data/examples/og/README +4 -0
  8. data/examples/og/run.rb +254 -0
  9. data/examples/simple/app.rb +3 -3
  10. data/examples/simple/conf/config.rb +10 -22
  11. data/examples/simple/conf/debug-config.rb +6 -32
  12. data/examples/simple/conf/live-config.rb +3 -23
  13. data/examples/simple/conf/requires.rb +5 -5
  14. data/examples/simple/env.rb +3 -4
  15. data/examples/simple/lib/articles/entities.rb +17 -15
  16. data/examples/simple/lib/articles/methods.rb +15 -15
  17. data/examples/simple/lib/articles/part.rb +7 -8
  18. data/examples/simple/root/comments.si +1 -1
  19. data/examples/simple/root/index.sx +1 -1
  20. data/examples/simple/root/view-article.sx +1 -2
  21. data/examples/tiny/app.rb +3 -3
  22. data/examples/tiny/conf/config.rb +4 -4
  23. data/examples/tiny/conf/requires.rb +3 -4
  24. data/lib/n/config.rb +50 -3
  25. data/lib/n/logger.rb +14 -2
  26. data/lib/n/og.rb +381 -0
  27. data/lib/n/og/backend.rb +252 -0
  28. data/lib/n/og/backends/mysql.rb +352 -0
  29. data/lib/n/og/backends/psql.rb +351 -0
  30. data/lib/n/og/connection.rb +253 -0
  31. data/lib/n/og/meta.rb +127 -0
  32. data/lib/n/properties.rb +6 -6
  33. data/lib/n/server.rb +4 -7
  34. data/lib/n/server/appserver.rb +58 -0
  35. data/lib/n/{app → server}/cluster.rb +3 -3
  36. data/lib/n/{app → server}/cookie.rb +3 -3
  37. data/lib/n/server/dispatcher.rb +55 -0
  38. data/lib/n/server/{filter.rb → filters.rb} +1 -1
  39. data/lib/n/{app → server}/filters/autologin.rb +5 -5
  40. data/lib/n/{app → server}/fragment.rb +3 -3
  41. data/lib/n/{app → server}/handlers.rb +4 -4
  42. data/lib/n/{app → server}/handlers/code-handler.rb +6 -6
  43. data/lib/n/{app → server}/handlers/page-handler.rb +9 -7
  44. data/lib/n/{app → server}/request.rb +8 -8
  45. data/lib/n/{app/request-part.rb → server/requestpart.rb} +4 -4
  46. data/lib/n/{app → server}/script.rb +5 -5
  47. data/lib/n/{app → server}/server.rb +1 -1
  48. data/lib/n/{app → server}/session.rb +5 -5
  49. data/lib/n/{app → server}/user.rb +1 -1
  50. data/lib/n/{app/webrick-servlet.rb → server/webrick.rb} +77 -20
  51. data/lib/n/shaders.rb +3 -2
  52. data/lib/n/std.rb +5 -32
  53. data/test/n/{app → server}/tc_cookie.rb +2 -2
  54. data/test/n/server/tc_filters.rb +38 -0
  55. data/test/n/{app → server}/tc_request.rb +6 -6
  56. data/test/n/{app → server}/tc_requestpart.rb +3 -3
  57. data/test/n/{app → server}/tc_session.rb +2 -2
  58. data/test/n/tc_og.rb +178 -0
  59. data/test/n/ui/tc_pager.rb +3 -3
  60. metadata +41 -65
  61. data/examples/ndb/README +0 -5
  62. data/examples/ndb/run.rb +0 -271
  63. data/lib/n/app/webrick.rb +0 -73
  64. data/lib/n/db.rb +0 -233
  65. data/lib/n/db/README +0 -232
  66. data/lib/n/db/connection.rb +0 -365
  67. data/lib/n/db/managed.rb +0 -233
  68. data/lib/n/db/mixins.rb +0 -279
  69. data/lib/n/db/mysql.rb +0 -345
  70. data/lib/n/db/psql.rb +0 -383
  71. data/lib/n/db/tools.rb +0 -106
  72. data/lib/n/db/utils.rb +0 -102
  73. data/lib/n/server/PLAYBACK.txt +0 -8
  74. data/lib/n/server/RESEARCH.txt +0 -13
  75. data/test/n/tc_db.rb +0 -223
  76. data/test/n/tc_db_mysql.rb +0 -241
@@ -8,7 +8,7 @@
8
8
  # * George Moschovitis <gm@navel.gr>
9
9
  #
10
10
  # (c) 2004 Navel, all rights reserved.
11
- # $Id: app.rb 101 2004-10-22 12:35:39Z gmosx $
11
+ # $Id: app.rb 112 2004-10-27 10:59:55Z gmosx $
12
12
 
13
13
  $:.unshift "simple/lib"
14
14
  $:.unshift "../lib"
@@ -17,11 +17,11 @@ $:.unshift "../lib"
17
17
  $DBG = true
18
18
  $DBG ? (require "simple/conf/debug-config") : (require "simple/conf/live-config")
19
19
 
20
- require "n/app/webrick"
20
+ require "n/server/webrick"
21
21
 
22
22
  module App
23
23
 
24
- class Server < N::App::Webrick
24
+ class Server < N::Webrick
25
25
  include App::Config
26
26
  end
27
27
 
@@ -8,41 +8,32 @@
8
8
  # * George Moschovitis <gm@navel.gr>
9
9
  #
10
10
  # (c) 2004 Navel, all rights reserved.
11
- # $Id: config.rb 106 2004-10-25 11:31:11Z gmosx $
11
+ # $Id: config.rb 124 2004-11-01 12:34:17Z gmosx $
12
12
 
13
13
  require "n/std"
14
14
  require "n/properties"
15
15
  require "n/logger"
16
16
  require "n/config"
17
+ require "n/og"
18
+ require "n/server/cluster"
19
+
20
+ require "simple/conf/requires"
17
21
 
18
22
  $name = "Simple"
19
23
  $root_dir = "simple/root"
20
24
 
21
- # Main logger
22
-
23
- $log = Logger.new("simple/logs/app.log", 10);
24
-
25
- # Events logger
26
-
27
- $elog = Logger.new("simple/logs/events.log", "weekly");
28
-
29
- require "n/db"
30
- require "n/app/cluster"
31
-
32
- require "simple/conf/requires"
33
-
34
25
  $srv_extension_map = {
35
26
  "sx" => ["text/html",
36
- # N::App::AutoLoginFilter.new(
37
- N::App::PageHandler.new
27
+ # N::AutoLoginFilter.new(
28
+ N::PageHandler.new
38
29
  # )
39
30
  ],
40
31
  "si" => ["text/html",
41
- N::App::PageHandler.new
32
+ N::PageHandler.new
42
33
  ],
43
34
  "rx" => ["text/html",
44
- # N::App::AutoLoginFilter.new(
45
- N::App::CodeHandler.new
35
+ # N::AutoLoginFilter.new(
36
+ N::CodeHandler.new
46
37
  # )
47
38
  ]
48
39
  }
@@ -61,10 +52,7 @@ module Config
61
52
  def initialize_sitemap
62
53
  end
63
54
 
64
- #
65
- #
66
55
  def initialize_shaders
67
- # $default_shader = N::NilShader.new
68
56
  $default_shader = N::Shader.new("simple", "#{$root_dir}/shader/shader.xsl")
69
57
  end
70
58
 
@@ -6,47 +6,21 @@
6
6
  # * George Moschovitis <gm@navel.gr>
7
7
  #
8
8
  # (c) 2004 Navel, all rights reserved.
9
- # $Id: debug-config.rb 106 2004-10-25 11:31:11Z gmosx $
9
+ # $Id: debug-config.rb 118 2004-11-01 10:13:42Z gmosx $
10
10
 
11
11
  require "simple/conf/config"
12
12
 
13
- puts "DEBUG configuration\n\n"
14
-
15
- # If set to true disables xsl caching. Usefull when debugging xsls.
16
-
17
- $reload_xsl = true
18
-
19
- # If set to true disables script compilation. Usefull when debugging
20
- # statically included scripts.
21
-
22
- $reload_scripts = true
23
-
24
- # Logger (redirect to STDERR)
25
-
26
- $log = Logger.new(STDERR);
27
- $log.level = Logger::DEBUG
28
-
29
- # Events logger
30
-
31
- $elog = Logger.new(STDERR);
32
- $elog.level = Logger::INFO
33
-
34
13
  # Database
35
14
 
36
- $db = N::Db.new(
15
+ $og = N::Og.new(
37
16
  :address => "localhost",
38
17
  :database => "simple",
39
18
  :user => "postgres",
40
19
  :password => "navelrulez",
41
- # gmosx: NEVER set to 1 to avoid deadlocks!
42
- :connection_count => 5
20
+ :connection_count => 2
43
21
  )
44
22
 
45
- $srv_address = $appsrv_address = "127.0.0.1"
46
- $srv_port = 8080
47
- $appsrv_port = 9090
48
- $srv_url = "http://#$srv_address:#$srv_port"
23
+ $og.get_connection
24
+ $og.manage(N::Article)
25
+ $og.manage(N::Comment)
49
26
 
50
- # gmosx: no error page in debug mode to avoid loops when there
51
- # is a bug in the handler code or the shader.
52
- $error_page_url = nil
@@ -6,41 +6,21 @@
6
6
  # * George Moschovitis <gm@navel.gr>
7
7
  #
8
8
  # (c) 2004 Navel, all rights reserved.
9
- # $Id: live-config.rb 101 2004-10-22 12:35:39Z gmosx $
9
+ # $Id: live-config.rb 118 2004-11-01 10:13:42Z gmosx $
10
10
 
11
11
  require "simple/conf/config"
12
12
 
13
- puts "LIVE configuration\n\n"
14
-
15
- # If set to true disables xsl caching. Usefull when debugging xsls.
16
-
17
- $reload_xsl = false
18
-
19
- # If set to true disables script compilation. Usefull when debugging
20
- # statically included scripts.
21
-
22
- $reload_scripts = false
23
-
24
13
  # Logger
25
14
 
15
+ $log = Logger.new("simple/logs/app.log", 10);
26
16
  $log.level = Logger::INFO
27
17
 
28
- # Events logger
29
-
30
- $elog.level = Logger::INFO
31
-
32
18
  # Database
33
19
 
34
- $db = N::Db.new(
20
+ $og = N::Og.new(
35
21
  :address => "localhost",
36
22
  :database => "simple",
37
23
  :user => "postgres",
38
24
  :password => "navelrulez",
39
25
  :connection_count => 20
40
26
  )
41
-
42
- $appsrv_address = "127.0.0.1"
43
- $appsrv_port = 9090
44
- $srv_url = "http://127.0.0.1:8080"
45
- #$srv_url = "http://192.168.0.3:8080"
46
-
@@ -8,12 +8,12 @@
8
8
  # * George Moschovitis <gm@navel.gr>
9
9
  #
10
10
  # (c) 2004 Navel, all rights reserved.
11
- # $Id: requires.rb 101 2004-10-22 12:35:39Z gmosx $
11
+ # $Id: requires.rb 118 2004-11-01 10:13:42Z gmosx $
12
12
 
13
13
  require "n/std"
14
14
  require "n/properties"
15
15
 
16
- require "n/db"
16
+ require "n/og"
17
17
  require "n/l10n"
18
18
  require "n/logger"
19
19
  require "n/parts"
@@ -35,9 +35,9 @@ require "n/ui/pager"
35
35
  require "n/ui/tabs"
36
36
  require "n/ui/date-select"
37
37
 
38
- require "n/app/cluster"
39
- require "n/app/handlers/page-handler"
40
- require "n/app/handlers/code-handler"
38
+ require "n/server/cluster"
39
+ require "n/server/handlers/page-handler"
40
+ require "n/server/handlers/code-handler"
41
41
 
42
42
  require "articles/part"
43
43
 
@@ -7,7 +7,7 @@
7
7
  # * George Moschovitis <gm@navel.gr>
8
8
  #
9
9
  # (c) 2004 Navel, all rights reserved.
10
- # $Id: env.rb 101 2004-10-22 12:35:39Z gmosx $
10
+ # $Id: env.rb 124 2004-11-01 12:34:17Z gmosx $
11
11
 
12
12
  $:.unshift ".."
13
13
  $:.unshift "simple/lib"
@@ -16,14 +16,13 @@ $:.unshift "../lib"
16
16
  $DBG = true
17
17
  $DBG ? (require "simple/conf/debug-config") : (require "simple/conf/live-config")
18
18
 
19
- require "n/app/server"
20
- require "n/db/tools" # very useful :)
19
+ require "n/server/server"
21
20
 
22
21
  $drb_lm_server = "druby://:10000"
23
22
 
24
23
  module App
25
24
 
26
- class Server < N::App::Server
25
+ class Server < N::AppServer
27
26
  include App::Config
28
27
  end
29
28
 
@@ -1,35 +1,37 @@
1
- # = Entities for the Articles part.
2
- #
3
- #--
4
1
  # code:
5
- # George Moschovitis <gm@navel.gr>
2
+ # * George Moschovitis <gm@navel.gr>
6
3
  #
7
4
  # (c) 2004 Navel, all rights reserved.
8
- # $Id: entities.rb 87 2004-10-19 17:27:45Z gmosx $
9
- #++
5
+ # $Id: entities.rb 118 2004-11-01 10:13:42Z gmosx $
10
6
 
11
7
  module N
12
8
 
9
+ # gmosx: forward declaration, can we avoid this?
10
+ class Comment; end
11
+
13
12
  # = Article
14
13
  #
15
14
  class Article
16
- include N::Entity
17
- include N::CreateTime
18
- manage {
19
15
  prop_accessor String, :title
20
16
  prop_accessor String, :body
21
- }
17
+ prop_accessor Time, :create_time
18
+ has_many N::Comment, :comments
19
+
20
+ def initialize
21
+ @create_time = Time.now
22
+ end
22
23
  end
23
24
 
24
25
  # = Comment
25
26
  #
26
27
  class Comment
27
- include N::Entity
28
- include N::Child
29
- include N::CreateTime
30
- manage {
31
28
  prop_accessor String, :body
32
- }
29
+ prop_accessor Time, :create_time
30
+ belongs_to N::Article, :article
31
+
32
+ def initialize
33
+ @create_time = Time.now
34
+ end
33
35
  end
34
36
 
35
37
  end # module
@@ -1,24 +1,24 @@
1
- # = Methods for the Articles part.
2
- #
3
- #--
4
1
  # code:
5
- # George Moschovitis <gm@navel.gr>
2
+ # * George Moschovitis <gm@navel.gr>
6
3
  #
7
4
  # (c) 2004 Navel, all rights reserved.
8
- # $Id: methods.rb 84 2004-10-19 13:57:01Z gmosx $
9
- #++
5
+ # $Id: methods.rb 118 2004-11-01 10:13:42Z gmosx $
10
6
 
11
7
  module P
12
8
 
9
+ # = ArticlesMethods
10
+ #
11
+ # Methods for the Articles part.
12
+ #
13
13
  module ArticlesMethods
14
14
 
15
15
  # Add an article
16
16
  #
17
17
  def add_article(request)
18
- if request.delete("add_article")
18
+ if request["add_article"]
19
19
  article = N::Article.new
20
20
  request.update_entity(article)
21
- $db << article
21
+ article.save!
22
22
  request.redirect("index.sx")
23
23
  end
24
24
  end
@@ -26,27 +26,27 @@ module ArticlesMethods
26
26
  # Delete an article
27
27
  #
28
28
  def del_article(request)
29
- if oid = request.delete("del_article_oid")
30
- $db.delete(oid.to_i, N::Article)
29
+ if oid = request["del_article_oid"]
30
+ N::Article.delete(oid)
31
31
  end
32
32
  end
33
33
 
34
34
  # Add a comment
35
35
  #
36
36
  def add_comment(request)
37
- if pid = request.delete("add_comment_pid")
37
+ if pid = request["add_comment_pid"]
38
38
  comment = N::Comment.new
39
- comment.pid = pid
39
+ comment.article = pid
40
40
  request.update_entity(comment)
41
- $db << comment
41
+ comment.save!
42
42
  end
43
43
  end
44
44
 
45
45
  # Delete a comment
46
46
  #
47
47
  def del_comment(request)
48
- if oid = request.delete("del_comment_oid")
49
- $db.delete(oid.to_i, N::Comment)
48
+ if oid = request["del_comment_oid"]
49
+ N::Comment.delete(oid)
50
50
  end
51
51
  end
52
52
 
@@ -1,12 +1,8 @@
1
- # = Simple Articles part.
2
- #
3
- #--
4
1
  # code:
5
- # George Moschovitis <gm@navel.gr>
2
+ # * George Moschovitis <gm@navel.gr>
6
3
  #
7
4
  # (c) 2004 Navel, all rights reserved.
8
- # $Id: part.rb 87 2004-10-19 17:27:45Z gmosx $
9
- #++
5
+ # $Id: part.rb 118 2004-11-01 10:13:42Z gmosx $
10
6
 
11
7
  require "articles/lc-en"
12
8
  require "articles/entities"
@@ -14,6 +10,10 @@ require "articles/methods"
14
10
 
15
11
  module P
16
12
 
13
+ # = Articles
14
+ #
15
+ # A simple articles part.
16
+ #
17
17
  class Articles < N::Part
18
18
  extend P::ArticlesMethods
19
19
 
@@ -23,7 +23,7 @@ class Articles < N::Part
23
23
  @name = "articles"
24
24
  @title = "Articles"
25
25
  @body = "Simple articles management"
26
- @version = "$Id: part.rb 87 2004-10-19 17:27:45Z gmosx $"
26
+ @version = "$Id: part.rb 118 2004-11-01 10:13:42Z gmosx $"
27
27
  @path = ""
28
28
  super
29
29
  end
@@ -55,4 +55,3 @@ end
55
55
  end # module
56
56
 
57
57
  a = P::Articles.instance
58
-
@@ -10,7 +10,7 @@
10
10
  P::Articles.del_comment(request)
11
11
 
12
12
  parent = request[:comments_parent]
13
- comments = $db.children(parent, N::Comment)
13
+ comments = parent.comments
14
14
  ?>
15
15
 
16
16
  <?r if comments ?>
@@ -17,7 +17,7 @@
17
17
  # methods:
18
18
  P::Articles.del_article(request)
19
19
 
20
- articles = $db.get_all(N::Article)
20
+ articles = N::Article.all
21
21
  ?>
22
22
 
23
23
  <!-- x:page is a trivial template, used as an example -->
@@ -5,8 +5,7 @@
5
5
  xmlns:xl="http://www.w3.org/1999/xlink">
6
6
 
7
7
  <?r
8
- oid = request["oid"]
9
- article = $db.get(oid, N::Article)
8
+ article = Article[request["oid"]]
10
9
  ?>
11
10
 
12
11
  <x:page>
data/examples/tiny/app.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  # * George Moschovitis <gm@navel.gr>
9
9
  #
10
10
  # (c) 2004 Navel, all rights reserved.
11
- # $Id: app.rb 101 2004-10-22 12:35:39Z gmosx $
11
+ # $Id: app.rb 112 2004-10-27 10:59:55Z gmosx $
12
12
 
13
13
  $:.unshift "../lib"
14
14
 
@@ -16,11 +16,11 @@ $:.unshift "../lib"
16
16
  $DBG = true
17
17
 
18
18
  require "tiny/conf/config"
19
- require "n/app/webrick"
19
+ require "n/server/webrick"
20
20
 
21
21
  module App
22
22
 
23
- class Server < N::App::Webrick
23
+ class Server < N::Webrick
24
24
  include App::Config
25
25
  end
26
26