From george.moschovitis at gmail.com Wed Jun 1 07:30:31 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Wed, 1 Jun 2005 14:30:31 +0300 Subject: [Nitro] [ANN] Nitro + Og 0.18.1 Message-ID: Hello everyone, new versions of Nitro and Og where just released! Download: http://rubyforge.org/frs/?group_id=418&release_id=2251 About: http://rubyforge.org/forum/forum.php?forum_id=3142 Please download this latest version, as it contains important bug fixes. regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From nospam at lunacymaze.org Wed Jun 1 15:13:26 2005 From: nospam at lunacymaze.org (Ghislain Mary) Date: Wed, 01 Jun 2005 21:13:26 +0200 Subject: [Nitro] Sqlite bug fix patch for og 0.18.1 Message-ID: <429E08D6.8040208@lunacymaze.org> In this release, all the 'columns' have been renamed to 'fields' to be more sql compliant. However, there's one that should not be changed since it comes from the ruby-sqlite3 library. So here's the patch that fixes this bug: diff -ru og-0.18.1/lib/og/store/sqlite.rb og-0.18.1-modified/lib/og/store/sqlite .rb --- og-0.18.1/lib/og/store/sqlite.rb Fri May 20 13:52:50 2005 +++ og-0.18.1-modified/lib/og/store/sqlite.rb Wed Jun 1 20:53:11 2005 @@ -161,7 +161,7 @@ res = @conn.query "SELECT * FROM #{klass::OGTABLE} LIMIT 1" map = {} - fields = res.fields + fields = res.columns fields.size.times do |i| map[fields[i].intern] = i HTH, Ghislain P.S. Why are the docs still those of 0.17.0 version in the package and those of 0.12.0 version on the web site? From nospam at lunacymaze.org Wed Jun 1 16:13:44 2005 From: nospam at lunacymaze.org (Ghislain Mary) Date: Wed, 01 Jun 2005 22:13:44 +0200 Subject: [Nitro] Sqlite bug fix patch for og 0.18.1 In-Reply-To: <429E08D6.8040208@lunacymaze.org> References: <429E08D6.8040208@lunacymaze.org> Message-ID: <429E16F8.3050501@lunacymaze.org> A better patch may be: diff -ru og-0.18.1/lib/og/store/sqlite.rb og-0.18.1-modified/lib/og/store/sqlite.rb --- og-0.18.1/lib/og/store/sqlite.rb Fri May 20 13:52:50 2005 +++ og-0.18.1-modified/lib/og/store/sqlite.rb Wed Jun 1 22:10:34 2005 @@ -14,6 +14,7 @@ class SQLite3::ResultSet alias_method :blank?, :eof? + alias_method :fields, :columns def each_row each do |row| Ghislain From nospam at lunacymaze.org Wed Jun 1 17:09:08 2005 From: nospam at lunacymaze.org (Ghislain Mary) Date: Wed, 01 Jun 2005 23:09:08 +0200 Subject: [Nitro] Sqlite bug fix patch for og 0.18.1 In-Reply-To: <429E16F8.3050501@lunacymaze.org> References: <429E08D6.8040208@lunacymaze.org> <429E16F8.3050501@lunacymaze.org> Message-ID: <429E23F4.4000102@lunacymaze.org> I found a bug, still in the sqlite store. Here's a little program that shows the wrong behaviour: require 'og' # Enables debug. $DBG = true # A class representing a blog Entry. class Entry property :title, String property :body, String has_many :comments, Comment def initialize(body = nil) @body = body end def to_s @body end end # A class representing a Comment to a blog Entry. class Comment property :body, String belongs_to Entry def initialize(body = nil) @body = body end def to_s @body end end # Initializes Og. manager = Og.setup( :destroy => true, # Destroy tables created from earlier runs. :store => 'sqlite', :name => 'ogtest' ) # Create an Entry. e1 = Entry.create('Body1') p e1 # Test the creation of a Comment. c1 = Comment.create('Comment1') p c1 # Attach a Comment to an Entry. c1.entry = e1 c1.save The problem here is that when created, the Entry has an oid of 0 whereas in the database the oid for this row is 1. So the attachement of a Comment to the Entry has no effect because refering an unknown Entry. Here is a patch incorporating the last one, fixing this problem and also enabling the printing of queries when debug is on: diff -ru og-0.18.1/lib/og/store/sqlite.rb og-0.18.1-modified/lib/og/store/sqlite.rb --- og-0.18.1/lib/og/store/sqlite.rb Fri May 20 13:52:50 2005 +++ og-0.18.1-modified/lib/og/store/sqlite.rb Wed Jun 1 23:00:06 2005 @@ -14,6 +14,7 @@ class SQLite3::ResultSet alias_method :blank?, :eof? + alias_method :fields, :columns def each_row each do |row| @@ -96,6 +97,10 @@ @conn.rollback if @transaction_nesting < 1 end + def last_insert_rowid + conn.query("SELECT last_insert_rowid()").first_value.to_i + end + private def create_table(klass) @@ -182,8 +187,8 @@ klass.class_eval %{ def og_insert(store) #{Aspects.gen_advice_code(:og_insert, klass.advices, :pre) if klass.respond_to?(:advices)} - store.conn.query("#{sql}").close - @#{pk} = store.conn.last_insert_row_id + store.query("#{sql}").close + @#{pk} = store.last_insert_rowid #{Aspects.gen_advice_code(:og_insert, klass.advices, :post) if klass.respond_to?(:advices)} end } Ghislain From george.moschovitis at gmail.com Thu Jun 2 05:39:21 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu, 2 Jun 2005 12:39:21 +0300 Subject: [Nitro] Sqlite bug fix patch for og 0.18.1 In-Reply-To: <429E23F4.4000102@lunacymaze.org> References: <429E08D6.8040208@lunacymaze.org> <429E16F8.3050501@lunacymaze.org> <429E23F4.4000102@lunacymaze.org> Message-ID: Hello, thanks for the reports! I 'll fix it ASAP and send you an updated gem. regards, George. On 6/2/05, Ghislain Mary wrote: > I found a bug, still in the sqlite store. Here's a little program that > shows the wrong behaviour: > > > require 'og' > > # Enables debug. > $DBG = true > > # A class representing a blog Entry. > class Entry > > property :title, String > property :body, String > > has_many :comments, Comment > > def initialize(body = nil) > @body = body > end > > def to_s > @body > end > > end > > > # A class representing a Comment to a blog Entry. > class Comment > > property :body, String > > belongs_to Entry > > def initialize(body = nil) > @body = body > end > > def to_s > @body > end > > end > > > > # Initializes Og. > manager = Og.setup( > :destroy => true, # Destroy tables created from earlier runs. > :store => 'sqlite', > :name => 'ogtest' > ) > > > # Create an Entry. > e1 = Entry.create('Body1') > p e1 > > # Test the creation of a Comment. > c1 = Comment.create('Comment1') > p c1 > > # Attach a Comment to an Entry. > c1.entry = e1 > c1.save > > > The problem here is that when created, the Entry has an oid of 0 whereas > in the database the oid for this row is 1. So the attachement of a > Comment to the Entry has no effect because refering an unknown Entry. > Here is a patch incorporating the last one, fixing this problem and also > enabling the printing of queries when debug is on: > > > diff -ru og-0.18.1/lib/og/store/sqlite.rb > og-0.18.1-modified/lib/og/store/sqlite.rb > --- og-0.18.1/lib/og/store/sqlite.rb Fri May 20 13:52:50 2005 > +++ og-0.18.1-modified/lib/og/store/sqlite.rb Wed Jun 1 23:00:06 2005 > @@ -14,6 +14,7 @@ > > class SQLite3::ResultSet > alias_method :blank?, :eof? > + alias_method :fields, :columns > > def each_row > each do |row| > @@ -96,6 +97,10 @@ > @conn.rollback if @transaction_nesting < 1 > end > > + def last_insert_rowid > + conn.query("SELECT last_insert_rowid()").first_value.to_i > + end > + > private > > def create_table(klass) > @@ -182,8 +187,8 @@ > klass.class_eval %{ > def og_insert(store) > #{Aspects.gen_advice_code(:og_insert, > klass.advices, :pre) if klass.respond_to?(:advices)} > - store.conn.query("#{sql}").close > - @#{pk} = store.conn.last_insert_row_id > + store.query("#{sql}").close > + @#{pk} = store.last_insert_rowid > #{Aspects.gen_advice_code(:og_insert, > klass.advices, :post) if klass.respond_to?(:advices)} > end > } > > > Ghislain > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Fri Jun 3 07:47:29 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Fri, 3 Jun 2005 14:47:29 +0300 Subject: [Nitro] Sqlite bug fix patch for og 0.18.1 In-Reply-To: <429E08D6.8040208@lunacymaze.org> References: <429E08D6.8040208@lunacymaze.org> Message-ID: > P.S. Why are the docs still those of 0.17.0 version in the package and > those of 0.12.0 version on the web site? I am finishing with some projects (powered by nitro) for clients and then I 'll work on www.nitrohq.com. This site will be updated very often. Stay tuned! -g. -- http://nitro.rubyforge.org http://www.joy.gr From nospam at lunacymaze.org Fri Jun 3 13:07:10 2005 From: nospam at lunacymaze.org (Ghislain Mary) Date: Fri, 03 Jun 2005 19:07:10 +0200 Subject: [Nitro] Sqlite bug fix patch for og 0.18.1 In-Reply-To: References: <429E08D6.8040208@lunacymaze.org> Message-ID: <42A08E3E.6030401@lunacymaze.org> George Moschovitis a ?crit : > I am finishing with some projects (powered by nitro) for clients and > then I 'll work on www.nitrohq.com. This site will be updated very > often. Stay tuned! Ok, thanks for the info. Ghislain From brian.takita at gmail.com Fri Jun 3 16:27:46 2005 From: brian.takita at gmail.com (Brian Takita) Date: Fri, 3 Jun 2005 13:27:46 -0700 Subject: [Nitro] sqlserver.rb patch Message-ID: <1d7ddd1105060313277e7324aa@mail.gmail.com> Hello, Here is a patch that adds integrated security to sql server connections. Putting id/passwords in source files can be a security vulnerability which integrated security fixes. Integrated security is an "essential" feature, or at least a best practice, to many shops that use Sql Server. I hope integrated security gets added to the main distribution in some form or another. Thank you, Brian Takita --- sqlserver.orig.rb 2005-06-03 13:13:15.796875000 -0700 +++ sqlserver.rb 2005-06-03 13:15:20.187500000 -0700 @@ -86,7 +86,14 @@ super begin - @conn = DBI.connect("DBI:ADO:Provider=SQLOLEDB;Data Source=#{options[:address]};Initial Catalog=#{options[:name]};User Id=#{options[:user]};Password=#{options[:password]};") + conn_str = "DBI:ADO:Provider=SQLOLEDB;Data Source=#{options[:address]};Initial Catalog=#{options[:name]};" + if config[:integrated_security] == true + conn_str += "Integrated Security=SSPI;" + else + conn_str += "User Id=#{options[:user]};Password=#{options[:password]};" + end + + @conn = DBI.connect(conn_str) rescue => ex # gmosx, FIXME: drak, fix this! if ex.to_s =~ /database .* does not exist/i -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/nitro-general/attachments/20050603/cd2f4869/attachment.html From nospam at lunacymaze.org Fri Jun 3 15:40:54 2005 From: nospam at lunacymaze.org (Ghislain Mary) Date: Fri, 03 Jun 2005 21:40:54 +0200 Subject: [Nitro] Patch for Og 0.17.0 In-Reply-To: References: <200505162046.00293.jperrot@exosec.fr> <200505191817.03584.jperrot@exosec.fr> Message-ID: <42A0B246.7000301@lunacymaze.org> George Moschovitis a ?crit : > Since you are working with the sqlite store, here is another problem. In > lib/og/store/sqlite.rb, try to uncomment this line: > > def close > # FIXME: problems when closing due to unfinalised statements. > # @conn.close > super > end > > And run the tests, any idea how to fix this? Here's a patch to fix this one. This is due to an unfinalized statement. diff -ru og-0.18.1/lib/og/store/sql.rb og-0.18.1-modified/lib/og/store/sql.rb --- og-0.18.1/lib/og/store/sql.rb Tue May 24 14:00:29 2005 +++ og-0.18.1-modified/lib/og/store/sql.rb Fri Jun 3 21:36:25 2005 @@ -575,7 +575,10 @@ # Deserialize one object from the ResultSet. def read_one(res, klass, join_relations = nil) - return nil if res.blank? + if res.blank? + res.close + return nil + end if join_relations join_relations = [join_relations].flatten.collect do |n| diff -ru og-0.18.1/lib/og/store/sqlite.rb og-0.18.1-modified/lib/og/store/sqlite.rb --- og-0.18.1/lib/og/store/sqlite.rb Fri May 20 13:52:50 2005 +++ og-0.18.1-modified/lib/og/store/sqlite.rb Fri Jun 3 21:38:16 2005 @@ -57,8 +58,7 @@ end def close -# FIXME: problems when closing due to unfinalised statements. -# @conn.close + @conn.close super end Ghislain From george.moschovitis at gmail.com Sat Jun 4 03:27:55 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sat, 4 Jun 2005 10:27:55 +0300 Subject: [Nitro] Patch for Og 0.17.0 In-Reply-To: <42A0B246.7000301@lunacymaze.org> References: <200505162046.00293.jperrot@exosec.fr> <200505191817.03584.jperrot@exosec.fr> <42A0B246.7000301@lunacymaze.org> Message-ID: Thank you VERY much! regards, George. > Here's a patch to fix this one. This is due to an unfinalized statement. > > ... > super > end -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Sat Jun 4 03:30:02 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sat, 4 Jun 2005 10:30:02 +0300 Subject: [Nitro] sqlserver.rb patch In-Reply-To: <1d7ddd1105060313277e7324aa@mail.gmail.com> References: <1d7ddd1105060313277e7324aa@mail.gmail.com> Message-ID: Hello, thanks for this patch. Btw, I wonder if you could help me converting the older SQL server Og adapter to the latest Og code. regards, George. On 6/3/05, Brian Takita wrote: > Hello, > > Here is a patch that adds integrated security to sql server connections. > Putting id/passwords in source files can be a security vulnerability which > integrated security fixes. > > Integrated security is an "essential" feature, or at least a best practice, > to many shops that use Sql Server. I hope integrated security gets added to > the main distribution in some form or another. > > Thank you, > Brian Takita > > --- sqlserver.orig.rb 2005-06-03 13:13:15.796875000 -0700 > +++ sqlserver.rb 2005-06-03 13:15:20.187500000 -0700 > @@ -86,7 +86,14 @@ > super > > begin > - @conn = > DBI.connect("DBI:ADO:Provider=SQLOLEDB;Data > Source=#{options[:address]};Initial > Catalog=#{options[:name]};User > Id=#{options[:user]};Password=#{options[:password]};") > + conn_str = "DBI:ADO:Provider=SQLOLEDB;Data > Source=#{options[:address]};Initial > Catalog=#{options[:name]};" > + if config[:integrated_security] == true > + conn_str += "Integrated Security=SSPI;" > + else > + conn_str += "User > Id=#{options[:user]};Password=#{options[:password]};" > + end > + > + @conn = DBI.connect(conn_str) > rescue => ex > # gmosx, FIXME: drak, fix this! > if ex.to_s =~ /database .* does not exist/i > > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > > > -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Sat Jun 4 03:34:58 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sat, 4 Jun 2005 10:34:58 +0300 Subject: [Nitro] Og reloaded, part 2, coming in 0.19.0 Message-ID: Dear friends, after the 0.18.0 bug-fix release, a lot of new features will be added in the forthcoming 0.19.0 release. If you have any ideas or wishes you would like implemented, now is the time to tell me.. Stay tuned for at least one 'exclusive' new feature that I am sure you will appreciate :) regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Sat Jun 4 05:14:23 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Sat, 4 Jun 2005 11:14:23 +0200 Subject: [Nitro] Og reloaded, part 2, coming in 0.19.0 In-Reply-To: References: Message-ID: <200506041114.24019.mneumann@ntecs.de> Am Saturday 04 June 2005 09:34 schrieb George Moschovitis: > Dear friends, > > after the 0.18.0 bug-fix release, a lot of new features will be added > in the forthcoming 0.19.0 release. If you have any ideas or wishes > you would like implemented, now is the time to tell me.. I haven't followed the development of Og recently... is duck-typing already in... if not, that's my wish ;-) Regards, Michael From james_b at neurogami.com Sat Jun 4 09:29:35 2005 From: james_b at neurogami.com (James Britt) Date: Sat, 04 Jun 2005 06:29:35 -0700 Subject: [Nitro] Og reloaded, part 2, coming in 0.19.0 In-Reply-To: <200506041114.24019.mneumann@ntecs.de> References: <200506041114.24019.mneumann@ntecs.de> Message-ID: <42A1ACBF.3050408@neurogami.com> Michael Neumann wrote: > Am Saturday 04 June 2005 09:34 schrieb George Moschovitis: > >>Dear friends, >> >>after the 0.18.0 bug-fix release, a lot of new features will be added >>in the forthcoming 0.19.0 release. If you have any ideas or wishes >>you would like implemented, now is the time to tell me.. > > > I haven't followed the development of Og recently... is duck-typing already > in... if not, that's my wish ;-) Duck typing in what sense? James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys From mneumann at ntecs.de Sat Jun 4 10:11:12 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Sat, 4 Jun 2005 16:11:12 +0200 Subject: [Nitro] Og reloaded, part 2, coming in 0.19.0 In-Reply-To: <42A1ACBF.3050408@neurogami.com> References: <200506041114.24019.mneumann@ntecs.de> <42A1ACBF.3050408@neurogami.com> Message-ID: <200506041611.13465.mneumann@ntecs.de> Am Saturday 04 June 2005 15:29 schrieb James Britt: > Michael Neumann wrote: > > Am Saturday 04 June 2005 09:34 schrieb George Moschovitis: > >>Dear friends, > >> > >>after the 0.18.0 bug-fix release, a lot of new features will be added > >>in the forthcoming 0.19.0 release. If you have any ideas or wishes > >>you would like implemented, now is the time to tell me.. > > > > I haven't followed the development of Og recently... is duck-typing > > already in... if not, that's my wish ;-) > > Duck typing in what sense? That you can have attributes which can contain multiple classes. A bad example follows: class Address # attribute blah can contain either a Name, Customer or etc. property :blah, (Name | Customer | ... ) end This could be implemented by internally generating a property blah_name and blah_customer and a "virtual" blah property that dispachtes to the blah_nameand blah_customer. Of course it can be implemented differently, e.g. storing the class/table name together with the oid attribute (this has the advantage that it doesn't break ordered sequences). Regards, Michael From george.moschovitis at gmail.com Sun Jun 5 03:12:54 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sun, 5 Jun 2005 10:12:54 +0300 Subject: [Nitro] Og reloaded, part 2, coming in 0.19.0 In-Reply-To: <200506041114.24019.mneumann@ntecs.de> References: <200506041114.24019.mneumann@ntecs.de> Message-ID: > I haven't followed the development of Og recently... is duck-typing already > in... if not, that's my wish ;-) I just added SingleTableInheritance, If i remember correctly this is what you more or less mean with duck typing. I 'll checkout your emails again. -g. > > Regards, > > Michael > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Sun Jun 5 03:16:38 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sun, 5 Jun 2005 10:16:38 +0300 Subject: [Nitro] Og reloaded, part 2, coming in 0.19.0 In-Reply-To: <200506041611.13465.mneumann@ntecs.de> References: <200506041114.24019.mneumann@ntecs.de> <42A1ACBF.3050408@neurogami.com> <200506041611.13465.mneumann@ntecs.de> Message-ID: > Of course it can be implemented differently, e.g. > storing the class/table name together with the oid attribute (this has the > advantage that it doesn't break ordered sequences). hm, seems I am right, this looks like STI, as I said this is already in for 0.19.0 and works orthogonally to the other features :) BTW, the current implementation stores the class name along with the pk, I am wondering if storing a hash of the name is a better solution, any comments? -g. -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Sun Jun 5 08:07:34 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Sun, 5 Jun 2005 14:07:34 +0200 Subject: [Nitro] Og reloaded, part 2, coming in 0.19.0 In-Reply-To: References: <200506041611.13465.mneumann@ntecs.de> Message-ID: <200506051407.35007.mneumann@ntecs.de> Am Sunday 05 June 2005 09:16 schrieb George Moschovitis: > > Of course it can be implemented differently, e.g. > > storing the class/table name together with the oid attribute (this has > > the advantage that it doesn't break ordered sequences). > > hm, seems I am right, this looks like STI, as I said this is already > in for 0.19.0 and works orthogonally to the other features :) > > BTW, the current implementation stores the class name along with the > pk, I am wondering if storing a hash of the name is a better solution, > any comments? Or you create an intermediate table called _og_classes, which defines a mapping from classname to a unique id (the pk of the table ;-). This would save memory and is probably faster (?) than using classnames directly. Regards, Michael From george.moschovitis at gmail.com Sun Jun 5 13:17:34 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sun, 5 Jun 2005 20:17:34 +0300 Subject: [Nitro] Og reloaded, part 2, coming in 0.19.0 In-Reply-To: <200506051407.35007.mneumann@ntecs.de> References: <200506041611.13465.mneumann@ntecs.de> <200506051407.35007.mneumann@ntecs.de> Message-ID: Hmm, will investigate this :) Anyway in the latest development code you can do: class Document end class Aritcle < Document end class Photo < Document end and then: docs = Document.all docs[0].class # -> Article docs[1].class # -> Photo or photos = Photo.all (only selects photos) or category.documents # selects all document children or category.documents(:type => Photo) # selects only photos or Document.metadata.subclasses # [Photo, Article] etc etc... This looks very cool (though I am saying it myself :-)) regards, George. On 6/5/05, Michael Neumann wrote: > Am Sunday 05 June 2005 09:16 schrieb George Moschovitis: > > > Of course it can be implemented differently, e.g. > > > storing the class/table name together with the oid attribute (this has > > > the advantage that it doesn't break ordered sequences). > > > > hm, seems I am right, this looks like STI, as I said this is already > > in for 0.19.0 and works orthogonally to the other features :) > > > > BTW, the current implementation stores the class name along with the > > pk, I am wondering if storing a hash of the name is a better solution, > > any comments? > > Or you create an intermediate table called _og_classes, which defines a > mapping from classname to a unique id (the pk of the table ;-). This would > save memory and is probably faster (?) than using classnames directly. > > Regards, > > Michael > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Mon Jun 6 05:44:45 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Mon, 6 Jun 2005 11:44:45 +0200 Subject: [Nitro] Og: Custom selects Message-ID: <200506061144.45572.mneumann@ntecs.de> Hi, How can I issue custom SQL statements, e.g. find an Account object with my own SQL query? I know there's some functions, but I don't now which ATM. How to get the table name of a given class? E.g. class Document end "select * from #{ Document.tablename }" Thanks in advance, Michael From steve at lumos.us Mon Jun 6 20:34:54 2005 From: steve at lumos.us (steve at lumos.us) Date: 06 Jun 2005 17:34:54 -0700 Subject: [Nitro] Oracle missing? References: <8664x74036.fsf@bitty.lumos.us> Message-ID: <86oeajngwh.fsf@bitty.lumos.us> George Moschovitis writes: > Hello Steve, > > I have not converted the 0.16.0 oracle driver to the new 0.17.0 > interface. I could do this over the weekend and send it to you so that > you can test this (I don't have access to an oracle db at the moment). > Perhaps we can get this included in next week's 0.18.0 release. > > regards, > -g. Guess I missed 0.18.0 -- by a lot :-) -- but I'm certainly happy to help with testing. Steve From george.moschovitis at gmail.com Tue Jun 7 03:30:10 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 7 Jun 2005 10:30:10 +0300 Subject: [Nitro] Oracle missing? In-Reply-To: <86oeajngwh.fsf@bitty.lumos.us> References: <8664x74036.fsf@bitty.lumos.us> <86oeajngwh.fsf@bitty.lumos.us> Message-ID: sounds great, please be a bit patient, I am making minor changes to the store api, when I am finished perhaps we can cooperate on the oracle store implementation. regards, George. On 06 Jun 2005 17:34:54 -0700, steve at lumos.us wrote: > George Moschovitis writes: > > Hello Steve, > > > > I have not converted the 0.16.0 oracle driver to the new 0.17.0 > > interface. I could do this over the weekend and send it to you so that > > you can test this (I don't have access to an oracle db at the moment). > > Perhaps we can get this included in next week's 0.18.0 release. > > > > regards, > > -g. > > Guess I missed 0.18.0 -- by a lot :-) -- but I'm certainly happy to > help with testing. > > Steve > > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From jpshack at gmail.com Tue Jun 7 16:33:47 2005 From: jpshack at gmail.com (John-Mason P. Shackelford) Date: Tue, 7 Jun 2005 15:33:47 -0500 Subject: [Nitro] Og and Rails Message-ID: <83f770ff050607133363086843@mail.gmail.com> Greetings, Is anyone using Og with Rails instead of Nitro? -- John-Mason Shackelford Software Developer Pearson Educational Measurement 2510 North Dodge St. Iowa City, IA 52245 ph. 319-354-9200x6214 john-mason.shackelford at pearson.com http://pearsonedmeasurement.com From george.moschovitis at gmail.com Wed Jun 8 03:05:21 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Wed, 8 Jun 2005 10:05:21 +0300 Subject: [Nitro] Og and Rails In-Reply-To: <83f770ff050607133363086843@mail.gmail.com> References: <83f770ff050607133363086843@mail.gmail.com> Message-ID: Haven't heard about anyone using Og with Rails. It is my understanding that Rails is pretty much interwinded with AR. However I will help anyone that tries to use Og with Rails and I am prepared to make some changes to make this easier (as long as those changes are compatible with Og's goals) regards, George. On 6/7/05, John-Mason P. Shackelford wrote: > Greetings, > > Is anyone using Og with Rails instead of Nitro? > > -- > John-Mason Shackelford > > Software Developer > Pearson Educational Measurement > > 2510 North Dodge St. > Iowa City, IA 52245 > ph. 319-354-9200x6214 > john-mason.shackelford at pearson.com > http://pearsonedmeasurement.com > > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Mon Jun 6 05:16:56 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Mon, 6 Jun 2005 12:16:56 +0300 Subject: [Nitro] Patch for Og 0.17.0 In-Reply-To: <42A0B246.7000301@lunacymaze.org> References: <200505162046.00293.jperrot@exosec.fr> <200505191817.03584.jperrot@exosec.fr> <42A0B246.7000301@lunacymaze.org> Message-ID: Gishlain, please email me your ..email address :) -g. -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Mon Jun 6 05:56:00 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Mon, 6 Jun 2005 12:56:00 +0300 Subject: [Nitro] Og: Custom selects In-Reply-To: <200506061144.45572.mneumann@ntecs.de> References: <200506061144.45572.mneumann@ntecs.de> Message-ID: Hello Michael, Document.table Returns the table used to map this class. I am thinking about changin this to schema (to be more compatible with non-sql backends). As for the custom SQL statement. It seems that during the redesign of Og I forgot to to include the older 'select' method. If you can't wait here is how to do it: def select(sql, options) klass = options[:class] read_all(query(sql), klass, options[:include]) end An alternative api will be: store.find(:sql => "SELECT * FROM #{Klass.table}", :class => Klass) I 'll add both methods right now, you will be able to find the updated code in the svn repository. regards, -g. On 6/6/05, Michael Neumann wrote: > Hi, > ... > Michael -- http://nitro.rubyforge.org http://www.joy.gr From nospam at lunacymaze.org Thu Jun 9 18:25:59 2005 From: nospam at lunacymaze.org (Ghislain Mary) Date: Fri, 10 Jun 2005 00:25:59 +0200 Subject: [Nitro] Nitro crashes when using sqlite Message-ID: <42A8C1F7.8040709@lunacymaze.org> Hi all, I am trying to do some stuff with Nitro and when using mysql there's no problem. However, when I try to use sqlite the application works for a very short time and then crashes at an almost random time with errors like the following: deadlock 0x147cdd4: run:-/usr/local/lib/ruby/1.8/timeout.rb:41: [BUG] Bus Error ruby 1.8.2 (2004-12-25) [powerpc-darwin7.9.0] Abort trap or an other variant: deadlock 0x1487770: run:-/usr/local/lib/ruby/1.8/timeout.rb:41: [BUG] Segmentation fault ruby 1.8.2 (2004-12-25) [powerpc-darwin7.9.0] Abort trap These errors also happen on a Pentium IV computer so this does not come from a PPC thing. I don't even know if the error comes from Nitro, Webrick, the sqlite-ruby binding or sqlite itself. Any ideas? Ghislain From nospam at lunacymaze.org Thu Jun 9 19:20:57 2005 From: nospam at lunacymaze.org (Ghislain Mary) Date: Fri, 10 Jun 2005 01:20:57 +0200 Subject: [Nitro] Nitro crashes when using sqlite In-Reply-To: <42A8C1F7.8040709@lunacymaze.org> References: <42A8C1F7.8040709@lunacymaze.org> Message-ID: <42A8CED9.8090206@lunacymaze.org> Ok, I got it to work. I needed to install SWIG before performing the installation of the sqlite3-ruby bindings. Ghislain From george.moschovitis at gmail.com Sun Jun 12 12:26:36 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sun, 12 Jun 2005 19:26:36 +0300 Subject: [Nitro] Nitro crashes when using sqlite In-Reply-To: <42A8CED9.8090206@lunacymaze.org> References: <42A8C1F7.8040709@lunacymaze.org> <42A8CED9.8090206@lunacymaze.org> Message-ID: Nice to hear about that. Perhaps you can privately send me some info of the setup process so I can include this in the docs. -g. On 6/10/05, Ghislain Mary wrote: > Ok, I got it to work. I needed to install SWIG before performing the > installation of the sqlite3-ruby bindings. > > Ghislain > > > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Tue Jun 14 06:19:12 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Tue, 14 Jun 2005 12:19:12 +0200 Subject: [Nitro] Storing binary data Message-ID: <200506141219.13072.mneumann@ntecs.de> Hi, How should I declare a property so that it can hold binary data and is converted back and forth automatically? There are two types in Postgres, BYTEA and BLOB. Which one is preferred in Og? Regards, Michael From george.moschovitis at gmail.com Tue Jun 14 07:29:21 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 14 Jun 2005 14:29:21 +0300 Subject: [Nitro] Storing binary data In-Reply-To: <200506141219.13072.mneumann@ntecs.de> References: <200506141219.13072.mneumann@ntecs.de> Message-ID: Hello Michael when recoding the psql driver I forgot to overide the default mapping to a blob column that was included in earlier versions of the Og-Psql adapter. The prefered way is BYTEA, and this will be fixed in the imminent 0.19.0 release of Og. Do you think than BLOB is better than BYTEA? regards, George. On 6/14/05, Michael Neumann wrote: > Hi, > > How should I declare a property so that it can hold binary data and is > converted back and forth automatically? There are two types in Postgres, > BYTEA and BLOB. Which one is preferred in Og? > > Regards, > > Michael > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Tue Jun 14 07:41:01 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Tue, 14 Jun 2005 13:41:01 +0200 Subject: [Nitro] Storing binary data In-Reply-To: References: <200506141219.13072.mneumann@ntecs.de> Message-ID: <200506141341.02171.mneumann@ntecs.de> Am Tuesday 14 June 2005 13:29 schrieb George Moschovitis: > Hello Michael > > when recoding the psql driver I forgot to overide the default mapping to a > blob column that was included in earlier versions of the Og-Psql adapter. > The prefered way is BYTEA, and this will be fixed in the imminent 0.19.0 > release of Og. Here's my patch/override to enable BYTEA's: class Og::Binary; end # tag for binary properties require 'og/adapters/psql' class Og::PsqlAdapter class << self # # Encodes a string as bytea value. # # for encoding rules see: # http://www.postgresql.org/docs/7.4/static/datatype-binary.html # def encode_bytea(str) str.gsub(/[\000-\037\047\134\177-\377]/) {|b| "\\#{ b[0].to_s(8).rjust(3, '0') }" } end # # Decodes a bytea encoded string. # # for decoding rules see: # http://www.postgresql.org/docs/7.4/static/datatype-binary.html # def decode_bytea(str) str.gsub(/\\(\\|'|[0-3][0-7][0-7])/) {|s| if s.size == 2 then s[1,1] else s[1,3].oct.chr end } end end alias __old_read_prop read_prop alias __old_write_prop write_prop def read_prop(p, idx) if p.klass.ancestors.include?(Og::Binary) return "#{ self.class }.decode_bytea(res.getvalue(tuple, #{idx}))" else __old_read_prop(p, idx) end end def write_prop(p) if p.klass.ancestors.include?(Og::Binary) return %|#\{@#{p.symbol} ? "'#\{#{self.class}.escape(#{self.class}.encode_bytea(@#{p.symbol}))\}'" : 'NULL'\}| else __old_write_prop(p) end end end > Do you think than BLOB is better than BYTEA? Blobs are actually a lot faster (and uses up less storage) for large data I think, as they need not to be encoded and decoded. I'd like to have both ;-) BYTEA is easier to handle than BLOBs, but if you implement BLOBs in a way that they are transparent to the user (as I did in Ruby/DBI), I'd prefer that way. Regards, Michael From george.moschovitis at gmail.com Tue Jun 14 07:58:36 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 14 Jun 2005 14:58:36 +0300 Subject: [Nitro] Storing binary data In-Reply-To: <200506141341.02171.mneumann@ntecs.de> References: <200506141219.13072.mneumann@ntecs.de> <200506141341.02171.mneumann@ntecs.de> Message-ID: Hello Michael, thanks a lot for the patch, I 'll integrate this. I 'll try to add support for blobs in 0.20.0, I 'll have a look at DBI first. At the moment I want to implement, a really really cool feature in Og, stay tuned :) -g. On 6/14/05, Michael Neumann wrote: > Am Tuesday 14 June 2005 13:29 schrieb George Moschovitis: > > Hello Michael > > > > when recoding the psql driver I forgot to overide the default mapping to a > > blob column that was included in earlier versions of the Og-Psql adapter. > > The prefered way is BYTEA, and this will be fixed in the imminent 0.19.0 > > release of Og. > > Here's my patch/override to enable BYTEA's: > > class Og::Binary; end # tag for binary properties > > require 'og/adapters/psql' > class Og::PsqlAdapter > > class << self > # > # Encodes a string as bytea value. > # > # for encoding rules see: > # http://www.postgresql.org/docs/7.4/static/datatype-binary.html > # > > def encode_bytea(str) > str.gsub(/[\000-\037\047\134\177-\377]/) {|b| > "\\#{ b[0].to_s(8).rjust(3, '0') }" } > end > > # > # Decodes a bytea encoded string. > # > # for decoding rules see: > # http://www.postgresql.org/docs/7.4/static/datatype-binary.html > # > def decode_bytea(str) > str.gsub(/\\(\\|'|[0-3][0-7][0-7])/) {|s| > if s.size == 2 then s[1,1] else s[1,3].oct.chr end > } > end > end > > alias __old_read_prop read_prop > alias __old_write_prop write_prop > > def read_prop(p, idx) > if p.klass.ancestors.include?(Og::Binary) > return "#{ self.class }.decode_bytea(res.getvalue(tuple, #{idx}))" > else > __old_read_prop(p, idx) > end > end > > def write_prop(p) > if p.klass.ancestors.include?(Og::Binary) > return %|#\{@#{p.symbol} ? > "'#\{#{self.class}.escape(#{self.class}.encode_bytea(@#{p.symbol}))\}'" : > 'NULL'\}| > else > __old_write_prop(p) > end > end > end > > > > Do you think than BLOB is better than BYTEA? > > Blobs are actually a lot faster (and uses up less storage) for large data I > think, as they need not to be encoded and decoded. I'd like to have both ;-) > BYTEA is easier to handle than BLOBs, but if you implement BLOBs in a way > that they are transparent to the user (as I did in Ruby/DBI), I'd prefer that > way. > > Regards, > > Michael > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Wed Jun 15 08:16:40 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Wed, 15 Jun 2005 15:16:40 +0300 Subject: [Nitro] Storing binary data In-Reply-To: <200506141341.02171.mneumann@ntecs.de> References: <200506141219.13072.mneumann@ntecs.de> <200506141341.02171.mneumann@ntecs.de> Message-ID: Hello Michael, It seems to me that this is a patch for an older version of Og (more than a month old). Out of curiosity, why is that? -g. -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Wed Jun 15 13:27:54 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Wed, 15 Jun 2005 19:27:54 +0200 Subject: [Nitro] Storing binary data In-Reply-To: References: <200506141219.13072.mneumann@ntecs.de> <200506141341.02171.mneumann@ntecs.de> Message-ID: <200506151927.54490.mneumann@ntecs.de> Am Wednesday 15 June 2005 14:16 schrieb George Moschovitis: > Hello Michael, > > It seems to me that this is a patch for an older version of Og (more > than a month old). Yes, it' s for Og 0.16.0. > Out of curiosity, why is that? Just because I am using it and have made some minor changes to it. I'd need to test it out with a newer version, but there's currently no need to "upgrade" and little time ;-) BYTEA columns have one problem. If you fetch an object, the whole data of the BYTEA column is retrieved as well. This might take a long time if the data is big. Two solutions: * lazy column/property loading, e.g. property :data, Og::Binary, :lazy => true would generate the following method: def data if @cached_data @cached_data else @cached_data = exec("select data from tablename where oid=#{self.oid}") end end * BLOBs (they must be implemented lazily too). Regards, Michael From mneumann at ntecs.de Wed Jun 15 13:43:29 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Wed, 15 Jun 2005 19:43:29 +0200 Subject: [Nitro] Og: Custom selects In-Reply-To: References: <200506061144.45572.mneumann@ntecs.de> Message-ID: <200506151943.29868.mneumann@ntecs.de> Am Monday 06 June 2005 11:56 schrieb George Moschovitis: > Hello Michael, > > Document.table > > Returns the table used to map this class. I am thinking about changin > this to schema (to be more compatible with non-sql backends). > > As for the custom SQL statement. It seems that during the redesign of > Og I forgot to to include the older 'select' method. > > If you can't wait here is how to do it: > > def select(sql, options) > klass = options[:class] > read_all(query(sql), klass, options[:include]) > end > > An alternative api will be: > > store.find(:sql => "SELECT * FROM #{Klass.table}", :class => Klass) Would be nice to have something like this: Customer.select {|s| s.category == 'Good' && s.name.like('Maier%') } This would create the SQL automatically for us: "SELECT * FROM #{Customer.table} WHERE category = 'Good' and name like 'Maier%'" And return all matching objects. That's much nicer and cleaner than to create the SQL manually, especially because column names might not always match property names. I really would prefer this way. Currently I'm doing the same at runtime like: Customer.all.select {|c| c.category == 'Good' && s.name =~ /Maier.*/ } But this of course is very slow, as it needs to fetch all objects from the database before selecting those of interest. Regards, Michael From george.moschovitis at gmail.com Thu Jun 16 08:51:36 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu, 16 Jun 2005 15:51:36 +0300 Subject: [Nitro] Og: Custom selects In-Reply-To: <200506151943.29868.mneumann@ntecs.de> References: <200506061144.45572.mneumann@ntecs.de> <200506151943.29868.mneumann@ntecs.de> Message-ID: > Would be nice to have something like this: > > Customer.select {|s| s.category == 'Good' && s.name.like('Maier%') } > > This would create the SQL automatically for us: > > "SELECT * FROM #{Customer.table} WHERE category = 'Good' and name like > 'Maier%'" Hello Michael, this looks nice but I have no idea how to actually convert the block to an sql string. Any tips? regards, -g. -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Thu Jun 16 10:01:08 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Thu, 16 Jun 2005 16:01:08 +0200 Subject: [Nitro] Og: Custom selects In-Reply-To: References: <200506061144.45572.mneumann@ntecs.de> <200506151943.29868.mneumann@ntecs.de> Message-ID: <200506161601.08740.mneumann@ntecs.de> Am Thursday 16 June 2005 14:51 schrieb George Moschovitis: > > Would be nice to have something like this: > > > > Customer.select {|s| s.category == 'Good' && s.name.like('Maier%') } > > > > This would create the SQL automatically for us: > > > > "SELECT * FROM #{Customer.table} WHERE category = 'Good' and name like > > 'Maier%'" > > Hello Michael, > > this looks nice but I have no idea how to actually convert the block > to an sql string. Any tips? Take a look at the Criteria module on RAA. It's quite simple to implement. You simply call the block with a builder object. The builder object then intercepts the method calls (e.g. #category, #==) and builds SQL from this. Eventually, the block returns the builder object which holds the SQL string. Regards, Michael From george.moschovitis at gmail.com Thu Jun 16 10:33:41 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu, 16 Jun 2005 17:33:41 +0300 Subject: [Nitro] Og: Custom selects In-Reply-To: <200506161601.08740.mneumann@ntecs.de> References: <200506061144.45572.mneumann@ntecs.de> <200506151943.29868.mneumann@ntecs.de> <200506161601.08740.mneumann@ntecs.de> Message-ID: Ok, will have a look... thanks for the tip! -g. > Take a look at the Criteria module on RAA. It's quite simple to implement. You > simply call the block with a builder object. The builder object then > intercepts the method calls (e.g. #category, #==) and builds SQL from this. > Eventually, the block returns the builder object which holds the SQL string. -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Thu Jun 16 12:15:03 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Thu, 16 Jun 2005 18:15:03 +0200 Subject: [Nitro] Og: Custom selects In-Reply-To: References: <200506061144.45572.mneumann@ntecs.de> Message-ID: <200506161815.04127.mneumann@ntecs.de> Am Monday 06 June 2005 11:56 schrieben Sie: > Hello Michael, > > Document.table > > Returns the table used to map this class. I am thinking about changin > this to schema (to be more compatible with non-sql backends). > > As for the custom SQL statement. It seems that during the redesign of > Og I forgot to to include the older 'select' method. Now, I'd like to issue a SQL query that returns a simple integer (e.g. a custom SUM(a_column)). How can I do this from within Og? Regards, Michael From george.moschovitis at gmail.com Thu Jun 16 12:53:26 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu, 16 Jun 2005 19:53:26 +0300 Subject: [Nitro] Og: Custom selects In-Reply-To: <200506161815.04127.mneumann@ntecs.de> References: <200506061144.45572.mneumann@ntecs.de> <200506161815.04127.mneumann@ntecs.de> Message-ID: > Now, I'd like to issue a SQL query that returns a simple integer (e.g. a > custom SUM(a_column)). How can I do this from within Og? In the latest version you can do: store.query(sql).first_value.to_i do you think that I should add special helper method that encapsulates this? any suggestions for a name? -g. -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Fri Jun 17 09:02:38 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Fri, 17 Jun 2005 16:02:38 +0300 Subject: [Nitro] [ANN] Nitro + Og 0.19.0, Og reloaded part 2 Message-ID: Dear devs, a *great* new release of Nitro + Og was just uploaded on RubyForge. Read about the new features in the following article: http://rubyforge.org/forum/forum.php?forum_id=3264 As always your remarks, suggestions and patches will be appreciated. regards, George. ps: there will be a part3 :) -- http://nitro.rubyforge.org http://www.joy.gr From Aleksi.Niemela at cs.helsinki.fi Sat Jun 18 07:16:38 2005 From: Aleksi.Niemela at cs.helsinki.fi (Aleksi Niemela) Date: Sat, 18 Jun 2005 14:16:38 +0300 Subject: [Nitro] Idiomatic use for concise Ogging? Message-ID: <42B40296.9090504@cs.helsinki.fi> Actually I had only one question but ended up writing three points. 1) What would be the idiomatic way to write this kind of code (at the end of the mail), so that code would be clean and concise and it would work as supposed. I don't like the fact I have to write '.first'. Also writing 4 lines to get hold of an object (regardless if it does or doesn't exist in database) seems too much. And when the field I'm identifying the object uniquely isn't 'name' to find_by_name the code gets a bit more complicated and even more non-uniform. 2) Anyways, I'd like to share you a "trick" to create assosiations in a concise way when creating new managed objects (at Bar.initialize). Please note that the three other versions to initialize the association don't work (and leave it to value nil in database) but self.=(value) form works. 3) Also, auto-destroying database doesn't work for me, printing this on cygwin: $ ruby test_data.rb dropdb: could not connect to database template1: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? DEBUG: Og manageable classes: [Foo, Bar] INFO: Created table 'ogfoo'. INFO: Created table 'ogbar'. DEBUG: SELECT * FROM ogfoo WHERE name='foo' DEBUG: SELECT * FROM ogbar WHERE name='bar' This is due to the fact a command "dropdb tilannetallenne -U aleksi" is issued, but command like dropdb -U aleksi -W password -h localhost tilannetallenne should have been issued (both password and host real location are important). I didn't write a patch since this approach would not work either for me. Problem is that postgres user aleksi isn't owner of the database so he can't drop it. Better approach would be to find out all tables that were created for managing objects and execute sql to drop those. - Aleksi require 'rubygems' require_gem 'postgres-pr' require_gem 'og' $DBG = true class Foo property :name, String def initialize(name) @name = name end end class Bar property :name, String belongs_to :foo, Foo def initialize(name, foo) @name = name # foo=foo # @foo=foo # foo=(foo) self.foo=(foo) # this does create the association end end config = { :address => "localhost", :destroy => true, :name => "tilannetallenne", :store => "psql", :user => "aleksi", :password => "password", :connection_count => 5 } db = Og::setup(config) f = Foo.find_by_name("foo").first unless f f = Foo.create("foo") end b = Bar.find_by_name("bar").first unless b Bar.create("bar", f) end From george.moschovitis at gmail.com Sat Jun 18 12:19:29 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sat, 18 Jun 2005 19:19:29 +0300 Subject: [Nitro] Idiomatic use for concise Ogging? In-Reply-To: <42B40296.9090504@cs.helsinki.fi> References: <42B40296.9090504@cs.helsinki.fi> Message-ID: Hello Aleksi, > require 'rubygems' > require_gem 'postgres-pr' > require_gem 'og' I suggest you put -rubygems in RUBYOPT and do just a require 'og', looks cleaner. > f = Foo.find_by_name("foo").first You should use Og property metadata: class Foo publice :name, String, :unique => true .. end now you get a better schmema generated (with a unique constrain) and find_by_name is clever anough to return just one object instead of the array: f = Foo.find_by_name('foo') For a full solution how about: b = Foo.create unless Foo.find_by_name('foo') (I don't have access to irb at the moment to verify the above snippet, but I think this or something similar will work) -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Sat Jun 18 12:21:48 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sat, 18 Jun 2005 19:21:48 +0300 Subject: [Nitro] Idiomatic use for concise Ogging? In-Reply-To: <42B40296.9090504@cs.helsinki.fi> References: <42B40296.9090504@cs.helsinki.fi> Message-ID: > Also, auto-destroying database doesn't work for me, printing this on cygwin: > ... > dropdb -U aleksi -W password -h localhost tilannetallenne > > should have been issued (both password and host real location are > important). I didn't write a patch since this approach would not work > either for me. Problem is that postgres user aleksi isn't owner of the > database so he can't drop it. Better approach would be to find out all > tables that were created for managing objects and execute sql to drop those. Thanks for pointing this out to me... I 'll try to find a solution (if anyone has any suggestions, please let me know) -g. -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Sat Jun 18 12:23:22 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sat, 18 Jun 2005 19:23:22 +0300 Subject: [Nitro] Idiomatic use for concise Ogging? In-Reply-To: References: <42B40296.9090504@cs.helsinki.fi> Message-ID: > Anyways, I'd like to share you a "trick" to create assosiations in a > ... > association>=(value) form works. Interesting, I 'll investigate this as well. regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From dcorbin at machturtle.com Sat Jun 18 20:41:02 2005 From: dcorbin at machturtle.com (David Corbin) Date: Sat, 18 Jun 2005 20:41:02 -0400 Subject: [Nitro] Tutorial? Message-ID: <200506182041.02742.dcorbin@machturtle.com> I've been playing around with Rails, and there are numerous things about AR that I'm not fond of. So, I though I'd look at Og. Is there a tutorial anywhere about using Og to get me started faster? Thanks David From james_b at neurogami.com Sat Jun 18 22:16:43 2005 From: james_b at neurogami.com (James Britt) Date: Sat, 18 Jun 2005 19:16:43 -0700 Subject: [Nitro] Tutorial? In-Reply-To: <200506182041.02742.dcorbin@machturtle.com> References: <200506182041.02742.dcorbin@machturtle.com> Message-ID: <42B4D58B.9070501@neurogami.com> David Corbin wrote: > I've been playing around with Rails, and there are numerous things about AR > that I'm not fond of. So, I though I'd look at Og. Is there a tutorial > anywhere about using Og to get me started faster? http://rubygarden.org/index.cgi/Libraries/og_tutorial.rdoc It may be somewhat out of date, as George has added much coolness. James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys From paulha at aracnet.com Sat Jun 18 23:00:18 2005 From: paulha at aracnet.com (PAUL HANCHETT) Date: Sat, 18 Jun 2005 20:00:18 -0700 Subject: [Nitro] Tutorial? In-Reply-To: <42B4D58B.9070501@neurogami.com> References: <200506182041.02742.dcorbin@machturtle.com> <42B4D58B.9070501@neurogami.com> Message-ID: <42B4DFC2.2000601@aracnet.com> What about for the Nitro part? I get that Og is the database part. I'm not so sure I understand all the other pieces of Nitro/Og (not that I've taken a great deal of time to reverse-engineer the examples...) James Britt wrote: > David Corbin wrote: > >> I've been playing around with Rails, and there are numerous things >> about AR that I'm not fond of. So, I though I'd look at Og. Is >> there a tutorial anywhere about using Og to get me started faster? > > > > > > http://rubygarden.org/index.cgi/Libraries/og_tutorial.rdoc > > It may be somewhat out of date, as George has added much coolness. > > James > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/nitro-general/attachments/20050618/412c2f96/attachment.html From james_b at neurogami.com Sun Jun 19 00:09:36 2005 From: james_b at neurogami.com (James Britt) Date: Sat, 18 Jun 2005 21:09:36 -0700 Subject: [Nitro] Tutorial? In-Reply-To: <42B4DFC2.2000601@aracnet.com> References: <200506182041.02742.dcorbin@machturtle.com> <42B4D58B.9070501@neurogami.com> <42B4DFC2.2000601@aracnet.com> Message-ID: <42B4F000.4090601@neurogami.com> PAUL HANCHETT wrote: > What about for the Nitro part? I get that Og is the database part. I'm > not so sure I understand all the other pieces of Nitro/Og (not that I've > taken a great deal of time to reverse-engineer the examples...) I started writing a Nitro tutorial some months ago. I put it on hold while George altered/added features. I'm at the point now where I need to review what I have, revisit the Nitro code, and get it up to date. The last time I ran the tutorial code, the main issues were simply class and constant names. But I don't know that there aren't things that I simply never knew about. James From Aleksi.Niemela at cs.helsinki.fi Sun Jun 19 05:09:14 2005 From: Aleksi.Niemela at cs.helsinki.fi (Aleksi Niemela) Date: Sun, 19 Jun 2005 12:09:14 +0300 Subject: [Nitro] Patch: Unsuccesful target resolving Message-ID: <42B5363A.2080901@cs.helsinki.fi> When code points to a class that doesn't exist Og ends up looping indefinitely. class User property :name, String # has_many :preferences, :Preference # assuming class Preference exist this would work has_many :preferences, :Preference_typo # hangs Og end Here's a patch. It assumes there wouldn't be more than 10 levels of retries (actually I didn't understand for what is the retry for, but still the patch worked for me :). - Aleksi $ diff -u relation.rb~ relation.rb --- relation.rb~ 2005-06-13 23:54:27.535000000 +0300 +++ relation.rb 2005-06-19 12:04:11.187500000 +0300 @@ -72,10 +72,15 @@ c = "::" + c unless c =~ /::/ c.gsub!(/::.*$/, '::') c << target_class.to_s + retries = 0 begin klass = constant(c) rescue c = target_class + retries += 1 + if retries > 10 + raise "Couldn't resolve target: #{target_class.to_s} for #{owner_class.name.dup}" + end retry end @options[:target_class] = klass From george.moschovitis at gmail.com Sun Jun 19 05:09:29 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sun, 19 Jun 2005 12:09:29 +0300 Subject: [Nitro] Tutorial? In-Reply-To: <42B4DFC2.2000601@aracnet.com> References: <200506182041.02742.dcorbin@machturtle.com> <42B4D58B.9070501@neurogami.com> <42B4DFC2.2000601@aracnet.com> Message-ID: The first thing I 'll do is to setup a little wiki for nitro/og discussion. The url will be: http://www.nitrohq.com This will happen some time in the next days. Perhaps James can upload his tutorial on the wiki, and we can collaborate on this. I fully understand that in order for this project to move forward, a community site plus documentation are essential. regards, George. On 6/19/05, PAUL HANCHETT wrote: > What about for the Nitro part? I get that Og is the database part. I'm > not so sure I understand all the other pieces of Nitro/Og (not that I've > taken a great deal of time to reverse-engineer the examples...) -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Sun Jun 19 05:12:36 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sun, 19 Jun 2005 12:12:36 +0300 Subject: [Nitro] Patch: Unsuccesful target resolving In-Reply-To: <42B5363A.2080901@cs.helsinki.fi> References: <42B5363A.2080901@cs.helsinki.fi> Message-ID: Thanks for pointing this out to me, I 'll investigate, thanks for the patch as well :) -g. -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Sun Jun 19 05:58:19 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Sun, 19 Jun 2005 11:58:19 +0200 Subject: [Nitro] Og: Custom selects In-Reply-To: References: <200506061144.45572.mneumann@ntecs.de> <200506161815.04127.mneumann@ntecs.de> Message-ID: <200506191158.19542.mneumann@ntecs.de> Am Thursday 16 June 2005 18:53 schrieb George Moschovitis: > > Now, I'd like to issue a SQL query that returns a simple integer (e.g. a > > custom SUM(a_column)). How can I do this from within Og? > > In the latest version you can do: > > store.query(sql).first_value.to_i what if query returns a result set? for me it would be enough if query would simply return an array (rows) of arrays (columns). > do you think that I should add special helper method that encapsulates > this? any suggestions for a name? I think the bare functionality is enough for now. Regards, MIchael From george.moschovitis at gmail.com Sun Jun 19 06:03:56 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sun, 19 Jun 2005 13:03:56 +0300 Subject: [Nitro] Og: Custom selects In-Reply-To: <200506191158.19542.mneumann@ntecs.de> References: <200506061144.45572.mneumann@ntecs.de> <200506161815.04127.mneumann@ntecs.de> <200506191158.19542.mneumann@ntecs.de> Message-ID: > what if query returns a result set? for me it would be enough if query would > simply return an array (rows) of arrays (columns). I don't want to convert the resultset to an array by default to avoid the conversion penalty, perhaps I should add a special option to query to do this, ie, something like: query(:to_array = > true) any suggestions for better names? -g. -- http://nitro.rubyforge.org http://www.joy.gr From Aleksi.Niemela at cs.helsinki.fi Sun Jun 19 06:39:06 2005 From: Aleksi.Niemela at cs.helsinki.fi (Aleksi Niemela) Date: Sun, 19 Jun 2005 13:39:06 +0300 Subject: [Nitro] Og: Patch: Manage propertywise empty classes Message-ID: <42B54B4A.5000309@cs.helsinki.fi> Code like class Preference # This class is just a placeholder, therefore empty. # It's managed, however and needs some keyword to be noticed as such. # property :name, String managed # without this keyword, there would be no method primary_key end class User # This class is not empty in a sense it will have associations to # another class, but at this point it doesn't contain any properties. # Therefore has_many needs to be defined all the time, # not only after first property definition. # property :name, String has_many :preferences, :Preference end doesn't work currently because 1) User doesn't call property and doesn't get enchanted (with RelationMixins), therefore call to has_many doesn't succeed. 2) Neither class gets managed as they don't declare @__props, and if they did it would be empty. 3) It's not possible to explicitly declare class to be managed even if it's empty. The patch has two parts. First we have to add "stub methods" to bootstrap real meta mixins (and relation mixins) and keyword "managed". This could be accomplished along the lines of following first patch. Please note you have to at least complete the list of methods which will bootstrap enchanting. The second patch completes the functionality by altering finding of classes to manage not to require them to be not empty. I just added comment marker, but I believe the rest of the line should be deleted. (Also the patch might not work as I've already altered manager.rb for other purposes, but I'm sure you got the idea.) - Aleksi $ diff -u ../../../glue-0.18.1/lib/glue/property.rb~ ../../../glue-0.18.1/lib/glue/property.rb --- ../../../glue-0.18.1/lib/glue/property.rb~ 2005-06-13 23:53:15.894375000 +0300 +++ ../../../glue-0.18.1/lib/glue/property.rb 2005-06-19 13:30:01.343750000 +0300 @@ -385,7 +385,24 @@ end end alias_method :property, :prop_accessor + + # Bootstrapping meta mixins from their respective keywords + # and forwarding call to real method. + ['has_many', 'belongs_to' #, ... + ].each do |meta_mixin_name| + module_eval %{ + def #{meta_mixin_name}(*params) + Glue::PropertyUtils.enchant(self) + Glue::PropertyUtils.include_meta_mixins(self) + #{meta_mixin_name}(*params) + end + } + end + def managed + Glue::PropertyUtils.include_meta_mixins(self) + end + # Attach metadata. # Guard against duplicates, no need to keep order. # This method uses closures :) $ diff -u manager.rb~ manager.rb --- manager.rb~ 2005-06-13 23:54:27.535000000 +0300 +++ manager.rb 2005-06-19 13:07:12.890625000 +0300 @@ -122,7 +123,7 @@ classes = [] ObjectSpace.each_object(Class) do |c| - if c.respond_to?(:__props) and (!c.__props.empty?) + if c.respond_to?(:__props) # and (!c.__props.empty?) classes << c end end From george.moschovitis at gmail.com Sun Jun 19 06:54:29 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Sun, 19 Jun 2005 13:54:29 +0300 Subject: [Nitro] Og: Patch: Manage propertywise empty classes In-Reply-To: <42B54B4A.5000309@cs.helsinki.fi> References: <42B54B4A.5000309@cs.helsinki.fi> Message-ID: > 1) User doesn't call property and doesn't get enchanted (with > RelationMixins), therefore call to has_many doesn't succeed. > 2) Neither class gets managed as they don't declare @__props, and if > they did it would be empty. > 3) It's not possible to explicitly declare class to be managed even if > it's empty. you can do the following: class User < Entity # AR style ... end or class User # better solution. include EntityMixin ... end I should have documented this better... However you idea with the 'managed' macro sounds interesting, perhaps I should add this as an alternative. However in most cases it is better to place a property macro in the class to have it automatically managed... regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From dcorbin at machturtle.com Sun Jun 19 08:04:59 2005 From: dcorbin at machturtle.com (David Corbin) Date: Sun, 19 Jun 2005 08:04:59 -0400 Subject: [Nitro] A few questions Message-ID: <200506190804.59435.dcorbin@machturtle.com> After looking a the tutorial, I have few questions: 1) Something rubs me the wrong way about the application dynamically creating the database schema as needed. In some environments, the db user for the application may not even have permissions to create tables and columns. Has any consideration been given to an option to simply generate a schema generation script from the class information? 2) Is there anyway to specify "NOT NULL" without providing the SQL type? 3) Is there something magical about 'db', or does the Database object effectively act like a singleton? How does the object know it's bound to 'db'? 4) When you save, how much does Og save? Mostly I'm interested in the case of A has_one/many B. If I save A, will any dirty B objects be saved? Thanks David From george.moschovitis at gmail.com Mon Jun 20 03:57:45 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Mon, 20 Jun 2005 10:57:45 +0300 Subject: [Nitro] A few questions In-Reply-To: <200506190804.59435.dcorbin@machturtle.com> References: <200506190804.59435.dcorbin@machturtle.com> Message-ID: Hello David, > 1) Something rubs me the wrong way about the application dynamically creating > the database schema as needed. In some environments, the db user for the > application may not even have permissions to create tables and columns. > Has any consideration been given to an option to simply generate a schema > generation script from the class information? this is in the TODO list (relatively easy to implement). > 2) Is there anyway to specify "NOT NULL" without providing the SQL type? hmm, you are correct, I 'll need to add a :notnull option. > 3) Is there something magical about 'db', or does the Database object > effectively act like a singleton? How does the object know it's bound to > 'db'? there is nothing special with db, you can use any variable name you want. > 4) When you save, how much does Og save? Mostly I'm interested in the case of > A has_one/many B. If I save A, will any dirty B objects be saved? at the moment no. There is some code to do this but not yet enabled. A 'build' mode will be available in the next release. regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Mon Jun 20 06:51:03 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Mon, 20 Jun 2005 12:51:03 +0200 Subject: [Nitro] Og polymorphic question Message-ID: <200506201251.04085.mneumann@ntecs.de> Hi, Have a look at this piece of code: class A has_many Comment end class B has_many Comment end class Comment .... end Now, can I simply add an object of type Comment (and not A::Comment or B::Comment) to A and/or B, or not? Regards, Michael From george.moschovitis at gmail.com Mon Jun 20 07:01:25 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Mon, 20 Jun 2005 14:01:25 +0300 Subject: [Nitro] Og polymorphic question In-Reply-To: <200506201251.04085.mneumann@ntecs.de> References: <200506201251.04085.mneumann@ntecs.de> Message-ID: You cannot add a 'standalone' Comment object. Is there a problem with this? -g. On 6/20/05, Michael Neumann wrote: > Hi, > > Have a look at this piece of code: > > class A > has_many Comment > end > > class B > has_many Comment > end > > class Comment > .... > end > > Now, can I simply add an object of type Comment (and not A::Comment or > B::Comment) to A and/or B, or not? > > Regards, > > Michael > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Mon Jun 20 07:19:44 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Mon, 20 Jun 2005 13:19:44 +0200 Subject: [Nitro] Og polymorphic question In-Reply-To: References: <200506201251.04085.mneumann@ntecs.de> Message-ID: <200506201319.44968.mneumann@ntecs.de> Am Monday 20 June 2005 13:01 schrieb George Moschovitis: > You cannot add a 'standalone' Comment object. Is there a problem with this? > -g. Okay I understand that Comment cannot belong to A and B at the same time. But I don't understand why I have to write: a.comments << A::Comment.new(....) instead of: a.comments << Comment.new(...) Am I right that A::Comment is a subclass of Comment? Or maybe I'm totally wrong. How is it implemented? Regards, Michael > On 6/20/05, Michael Neumann wrote: > > Hi, > > > > Have a look at this piece of code: > > > > class A > > has_many Comment > > end > > > > class B > > has_many Comment > > end > > > > class Comment > > .... > > end > > > > Now, can I simply add an object of type Comment (and not A::Comment or > > B::Comment) to A and/or B, or not? > > > > Regards, > > > > Michael > > _______________________________________________ > > Nitro-general mailing list > > Nitro-general at rubyforge.org > > http://rubyforge.org/mailman/listinfo/nitro-general From george.moschovitis at gmail.com Mon Jun 20 07:23:56 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Mon, 20 Jun 2005 14:23:56 +0300 Subject: [Nitro] Nitro Wiki Message-ID: Dear devs, I have installed a simple wiki on www.nitrohq.com. This is an intermediate solution until the final NitroHQ site is ready. I would like to ask everyone on this list to help me organize this wiki and start adding content. Let's get started by adding stuff in the Questions and WishList section. James, perhaps you can upload your Nitro tutorial so we can work on this collaboratively. Your help is really needed in order for this project to move forward. regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Mon Jun 20 07:27:42 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Mon, 20 Jun 2005 14:27:42 +0300 Subject: [Nitro] Og polymorphic question In-Reply-To: <200506201319.44968.mneumann@ntecs.de> References: <200506201251.04085.mneumann@ntecs.de> <200506201319.44968.mneumann@ntecs.de> Message-ID: > Am I right that A::Comment is a subclass of Comment? Or maybe I'm totally > wrong. How is it implemented? Yeah, A::Comment is a subclass of Comment. class A::Comment < Comment; end but if tou add a plain comment to a, Og can't infer the correct table to store the object. Now that I am looking at your example, I think I can somehow implement this... On the other hand, there is soo much to do, perhaps you could help with a little patch? ;-) -g. -- http://nitro.rubyforge.org http://www.joy.gr From nitro at tcb.mailworks.org Mon Jun 20 13:52:56 2005 From: nitro at tcb.mailworks.org (Timothy Brown) Date: Mon, 20 Jun 2005 13:52:56 -0400 Subject: [Nitro] Multiple databases? Message-ID: <1119289976.7870.236768262@webmail.messagingengine.com> Hi: I'd like to create multiple databases with Nitro - e.g., I want some objects to reside in one database, others to reside in a separate database, and have both of them accessible by the same application. What's the best practice way to achieve this? Is it a feature request or possible today? Also, is Ruby serialization/persistence direct-to-disk (non-SQL) supported? From Aleksi.Niemela at cs.helsinki.fi Mon Jun 20 15:49:13 2005 From: Aleksi.Niemela at cs.helsinki.fi (Aleksi Niemela) Date: Mon, 20 Jun 2005 22:49:13 +0300 Subject: [Nitro] Multiple databases? In-Reply-To: <1119289976.7870.236768262@webmail.messagingengine.com> References: <1119289976.7870.236768262@webmail.messagingengine.com> Message-ID: <42B71DB9.7090707@cs.helsinki.fi> Sorry, this mail is perhaps longer than it should. Timothy Brown wrote: >Hi: > >I'd like to create multiple databases with Nitro - e.g., I want some >objects to reside in one database, others to reside in a separate >database, and have both of them accessible by the same application. > > This code should work in theory. There're no design barriers I'm aware of against this. You have to be careful not to let Og find automatically which classes to manage. Or it will get [A,B] for both DB managers and creates tables for both but objects will be created only for the manager instantiated first. The current version of Og::setup doesn't allow pointing out which classes to manage, so here's a bit modified version. George, I guess you should change Og code to something like this method setup. require 'rubygems' require_gem 'postgres-pr' require_gem 'og' $DBG = true class A property :name, String def initialize(name) @name = name end end class B property :name, String def initialize(name) @name = name end end def setup(options = {}, managed_classes = []) m = @@manager = Og::Manager.new(options) m.manage_classes managed_classes return m end config1 = { :address => "localhost", :destroy => true, :name => "testing", :store => "psql", :user => "tester1", :password => "tester1password", :connection_count => 1 } config2 = { :address => "localhost", :destroy => true, :name => "testing2", # note different database :store => "psql", :user => "tester2", # and user :password => "tester2password", :connection_count => 1 } db1 = setup(config1, [A]) db2 = setup(config2, [B]) a_objects = (0..2).map {|i| A.create "foo #{i}" } puts "creating B" b = B.create "bar" puts "finding" p A.all.to_ary p B.all.to_ary But in practise that code doesn't work. I get this error message. I guess George needs to look into this as at least I wasn't able to decipher the origin of the problem. /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:115:in `query': ERROR C42P01 Mrelatio n "ogb_oid_seq" does not exist Fnamespace.c L201 RRangeVarGetRelid (RuntimeError) from /usr/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:33:in `exec' from (eval):4:in `og_insert' from /usr/lib/ruby/gems/1.8/gems/og-0.18.1/lib/og/store.rb:119:in `save' from /usr/lib/ruby/gems/1.8/gems/og-0.18.1/lib/og/entity.rb:58:in `create' from test_multiple_databases.rb:53 To be more precise, my guess is that after this bug has been fixed you can say. db1 = Og::setup(config, [A,B]) # and create tables for both db2 = Og::setup(config2, [A,B]) # classes for both databases a = A.create # goes to db2 as A.ogmanager is pointing to db2 A.ogmanager = db1 a2 = A.create # now goes to db1 and maybe there's no need to change any code and it will work right away to set manager per object basis a3 = A.new # not created, so not saved yet def a3.ogmanager # while normal A objects would go db2 # to current manager, that is db1, this object end a3.name = "foo" a3.save # goes to db2 But I'm diverting from bug hunting. I can't say what is really the problem as strategically placed "pp ogmanager" at entity.rb ClassMethod::create does show both classes have their own manager with their own connections (as you can verify from this output, sorry it's longish). But there are couple of odd things here: 1) with first run there really was no ogb_oid_seq in testing2 database, but after I dropped it and rerun I got it there, so it really exists, and testing database is all ok, all of sequence, table and data in it. 2) as the following output shows, first A.create has correct connections, but in second call the pool is empty (but the creation still succeeds). This leads me to wonder if Glue::Pool is still one to blame, but I can't put my finger on the bug there should it have one. - Aleksi $ ruby test_multiple_databases.rb DEBUG: Table already exists DEBUG: Table already exists # #}, @options= {:address=>"localhost", :destroy=>true, :user=>"tester1", :password=>"tester1password", :connection_count=>1, :store=>"psql", :name=>"testing"}, @pool= [#, @params= {"integer_datetimes"=>"off", "TimeZone"=>"Europe/Helsinki", "server_encoding"=>"LATIN1", "DateStyle"=>"ISO, MDY", "client_encoding"=>"LATIN1", "session_authorization"=>"tester1", "server_version"=>"8.0.1", "is_superuser"=>"off"}>, @db="testing", @host="localhost", @user="tester1">, @options= {:address=>"localhost", :destroy=>true, :user=>"tester1", :password=>"tester1password", :connection_count=>1, :store=>"psql", :name=>"testing"}, @transaction_nesting=0, @typemap= {TrueClass=>"boolean", Time=>"timestamp", Array=>"text", Float=>"float", Integer=>"integer", Date=>"date", Fixnum=>"integer", Hash=>"text", String=>"text", Object=>"text"}>]> # #}, @options= {:address=>"localhost", :destroy=>true, :user=>"tester1", :password=>"tester1password", :connection_count=>1, :store=>"psql", :name=>"testing"}, @pool=[]> # #}, @options= {:address=>"localhost", :destroy=>true, :user=>"tester1", :password=>"tester1password", :connection_count=>1, :store=>"psql", :name=>"testing"}, @pool=[]> creating B # #}, @options= {:address=>"localhost", :destroy=>true, :user=>"tester2", :password=>"tester2password", :connection_count=>1, :store=>"psql", :name=>"testing2"}, @pool= [#, @params= {"integer_datetimes"=>"off", "TimeZone"=>"Europe/Helsinki", "server_encoding"=>"LATIN1", "DateStyle"=>"ISO, MDY", "client_encoding"=>"LATIN1", "session_authorization"=>"tester2", "server_version"=>"8.0.1", "is_superuser"=>"off"}>, @db="testing2", @host="localhost", @user="tester2">, @options= {:address=>"localhost", :destroy=>true, :user=>"tester2", :password=>"tester2password", :connection_count=>1, :store=>"psql", :name=>"testing2"}, @transaction_nesting=0, @typemap= {TrueClass=>"boolean", Time=>"timestamp", Array=>"text", Float=>"float", Integer=>"integer", Date=>"date", Fixnum=>"integer", Hash=>"text", String=>"text", Object=>"text"}>]> From george.moschovitis at gmail.com Mon Jun 20 15:56:42 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Mon, 20 Jun 2005 22:56:42 +0300 Subject: [Nitro] Multiple databases? In-Reply-To: <1119289976.7870.236768262@webmail.messagingengine.com> References: <1119289976.7870.236768262@webmail.messagingengine.com> Message-ID: > Also, is Ruby serialization/persistence direct-to-disk (non-SQL) > supported? Yeap, have a look at the 'memory' store implementation. -g. -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Mon Jun 20 15:59:51 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Mon, 20 Jun 2005 22:59:51 +0300 Subject: [Nitro] Multiple databases? In-Reply-To: <1119289976.7870.236768262@webmail.messagingengine.com> References: <1119289976.7870.236768262@webmail.messagingengine.com> Message-ID: > I'd like to create multiple databases with Nitro - e.g., I want some > objects to reside in one database, others to reside in a separate > database, and have both of them accessible by the same application. > > What's the best practice way to achieve this? Is it a feature request > or possible today? > Hmm there are some minor changes needed to do this. I will add better support for this in the next version 0.20.0. Be patient. If you have any more feature requests let me know. And even better: add them to the Wishlist page on www.nitrohq.com best regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Mon Jun 20 16:11:01 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Mon, 20 Jun 2005 23:11:01 +0300 Subject: [Nitro] Multiple databases? In-Reply-To: <42B71DB9.7090707@cs.helsinki.fi> References: <1119289976.7870.236768262@webmail.messagingengine.com> <42B71DB9.7090707@cs.helsinki.fi> Message-ID: Hello Aleksi, thanks a lot for your detailed post. Be a little patient, I have a much better and simpler solution, will be available in 0.20.0 regards, George. PS: please feel free to add stuff like that in www.nitrohq.com -- http://nitro.rubyforge.org http://www.joy.gr From dcorbin at machturtle.com Mon Jun 20 16:45:33 2005 From: dcorbin at machturtle.com (David Corbin) Date: Mon, 20 Jun 2005 16:45:33 -0400 Subject: [Nitro] A few questions In-Reply-To: References: <200506190804.59435.dcorbin@machturtle.com> Message-ID: <200506201645.33305.dcorbin@machturtle.com> On Monday 20 June 2005 03:57 am, George Moschovitis wrote: > Hello David, > > > 1) Something rubs me the wrong way about the application dynamically > > creating the database schema as needed. In some environments, the db > > user for the application may not even have permissions to create tables > > and columns. Has any consideration been given to an option to simply > > generate a schema generation script from the class information? > > this is in the TODO list (relatively easy to implement). > > 3) Is there something magical about 'db', or does the Database object > > effectively act like a singleton? How does the object know it's bound to > > 'db'? > > there is nothing special with db, you can use any variable name you want. I don't see where (in the tutorial), the classes are linked to a particular database. > > 4) When you save, how much does Og save? Mostly I'm interested in the > > case of A has_one/many B. If I save A, will any dirty B objects be > > saved? > > at the moment no. There is some code to do this but not yet enabled. A > 'build' mode will be available in the next release. This is really key. I think it should be a case of "has_" associations having the ability to specify "traverse and save if dirty". David From Aleksi.Niemela at cs.helsinki.fi Mon Jun 20 17:28:57 2005 From: Aleksi.Niemela at cs.helsinki.fi (Aleksi Niemela) Date: Tue, 21 Jun 2005 00:28:57 +0300 Subject: [Nitro] A few questions In-Reply-To: <200506201645.33305.dcorbin@machturtle.com> References: <200506190804.59435.dcorbin@machturtle.com> <200506201645.33305.dcorbin@machturtle.com> Message-ID: <42B73519.5070000@cs.helsinki.fi> David Corbin wrote: >>>3) Is there something magical about 'db', or does the Database object >>>effectively act like a singleton? How does the object know it's bound to >>>'db'? >>> >>> >>there is nothing special with db, you can use any variable name you want. >> >> > >I don't see where (in the tutorial), the classes are linked to a particular >database. > > Classes which will be managed get binding to certain database (ie. manager which contains a store representing that database) in this sequence of events: 1) class definition with Og keyword "property" or something alike in it (like class A; property :name, String; end) 1.1) that triggers Og meta programming which in turn adds methods like A#name, A#name=, A#find, ... 2) call to Og.setup (at the end of manager.rb) 2.1) which in turn calls in turn Manager#manage_classes which 2.2) manages either given classses or ones it finds through manageable_classes 2.3) which "knows" a class is a managed if it contains attribute __props (and is not empty) 3) and "managing a class" means 3.1) it will be added a comparator method 3.2) and ogmanager will be set for database given for Og.setup 3.3) it's relations to other classes will be enchanted (ie. has_many :article, Article will convert to Klass#articles method etc) Basically the answer to your question is point 2.3, the database object knows which classes to manage by checking for attribute __props. And a class knows to which database it should be saved through it's attribute ogmanager which contains datastore facing database. - Aleksi From mneumann at ntecs.de Mon Jun 20 18:50:10 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Tue, 21 Jun 2005 00:50:10 +0200 Subject: [Nitro] /usr/bin/nitro does not work under Rubygems Message-ID: <200506210050.10747.mneumann@ntecs.de> Hi, It should load the execute 'run.rb' file, but it does not, as in file /usr/lib/ruby/gems/1.8/gems/nitro-0.19.0/bin/nitro, 'Dir.pwd' is different from that in '/usr/bin/nitro', which calls the former. To see the problem yourself, insert 'Dir.pwd' in each of the above mentioned files. Regards, Michael From george.moschovitis at gmail.com Tue Jun 21 02:56:35 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 21 Jun 2005 09:56:35 +0300 Subject: [Nitro] /usr/bin/nitro does not work under Rubygems In-Reply-To: <200506210050.10747.mneumann@ntecs.de> References: <200506210050.10747.mneumann@ntecs.de> Message-ID: Do you (or anyone else) know a solution for this problem? regards, George. On 6/21/05, Michael Neumann wrote: > Hi, > > It should load the execute 'run.rb' file, but it does not, as in > file /usr/lib/ruby/gems/1.8/gems/nitro-0.19.0/bin/nitro, 'Dir.pwd' is > different from that in '/usr/bin/nitro', which calls the former. > > To see the problem yourself, insert 'Dir.pwd' in each of the above mentioned > files. > > Regards, > > Michael > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Tue Jun 21 03:02:31 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 21 Jun 2005 10:02:31 +0300 Subject: [Nitro] A few questions In-Reply-To: <200506201645.33305.dcorbin@machturtle.com> References: <200506190804.59435.dcorbin@machturtle.com> <200506201645.33305.dcorbin@machturtle.com> Message-ID: > I don't see where (in the tutorial), the classes are linked to a particular > database. in the tutorial there is one database, the one defined by Og.setup. For a multiple database setup checkout mysql_to_psql.rb in the og examples. Better support for multiple databases will be added. > This is really key. I think it should be a case of "has_" associations having > the ability to specify "traverse and save if dirty". agreed, it is in the TODO list. -g. -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Tue Jun 21 03:03:50 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 21 Jun 2005 10:03:50 +0300 Subject: [Nitro] A few questions In-Reply-To: <42B73519.5070000@cs.helsinki.fi> References: <200506190804.59435.dcorbin@machturtle.com> <200506201645.33305.dcorbin@machturtle.com> <42B73519.5070000@cs.helsinki.fi> Message-ID: Nicely said, I 'll add your answer to the wiki (if you have any problem with this, remove it!) -g. On 6/21/05, Aleksi Niemela wrote: > David Corbin wrote: > > >>>3) Is there something magical about 'db', or does the Database object > >>>effectively act like a singleton? How does the object know it's bound to > >>>'db'? > >>> > >>> > >>there is nothing special with db, you can use any variable name you want. > >> > >> > > > >I don't see where (in the tutorial), the classes are linked to a particular > >database. > > > > > Classes which will be managed get binding to certain database (ie. > manager which contains a store representing that database) in this > sequence of events: > > 1) class definition with Og keyword "property" or something alike in it > (like class A; property :name, String; end) > 1.1) that triggers Og meta programming which in turn adds methods like > A#name, A#name=, A#find, ... > 2) call to Og.setup (at the end of manager.rb) > 2.1) which in turn calls in turn Manager#manage_classes which > 2.2) manages either given classses or ones it finds through > manageable_classes > 2.3) which "knows" a class is a managed if it contains attribute __props > (and is not empty) > 3) and "managing a class" means > 3.1) it will be added a comparator method > 3.2) and ogmanager will be set for database given for Og.setup > 3.3) it's relations to other classes will be enchanted (ie. has_many > :article, Article will convert to Klass#articles method etc) > > Basically the answer to your question is point 2.3, the database object > knows which classes to manage by checking for attribute __props. And a > class knows to which database it should be saved through it's attribute > ogmanager which contains datastore facing database. > > - Aleksi > > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Tue Jun 21 03:50:13 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 21 Jun 2005 10:50:13 +0300 Subject: [Nitro] Better name? Message-ID: Dear devs, I would like to a convienience like the Helper's in Rails. Ie modules that contain a collection of utility methods that can be mixed in with Controllers. However I don't like the name that much. Does anyone have a better suggestion? regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Tue Jun 21 04:18:27 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Tue, 21 Jun 2005 10:18:27 +0200 Subject: [Nitro] /usr/bin/nitro does not work under Rubygems In-Reply-To: References: <200506210050.10747.mneumann@ntecs.de> Message-ID: <200506211018.27354.mneumann@ntecs.de> Am Tuesday 21 June 2005 08:56 schrieb George Moschovitis: > Do you (or anyone else) know a solution for this problem? I guess the only solution would be to let the Rubygems people fix this issue. It would be easy if we could insert one line into the /usr/bin/nitro file, e.g. ORIG_DIR_PWD = Dir.pwd. Regards, Michael From mneumann at ntecs.de Tue Jun 21 04:22:04 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Tue, 21 Jun 2005 10:22:04 +0200 Subject: [Nitro] Better name? In-Reply-To: References: Message-ID: <200506211022.04280.mneumann@ntecs.de> Am Tuesday 21 June 2005 09:50 schrieb George Moschovitis: > Dear devs, > > I would like to a convienience like the Helper's in Rails. Ie modules > that contain a collection of utility methods that can be mixed in with > Controllers. However I don't like the name that much. Does anyone have > a better suggestion? What's wrong with Helper? It's quite short, descriptive and you can combine it with another word, e.g. ThisHelper, RenderHelper etc. Regards, Michael From george.moschovitis at gmail.com Tue Jun 21 04:36:13 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 21 Jun 2005 11:36:13 +0300 Subject: [Nitro] Better name? In-Reply-To: <200506211022.04280.mneumann@ntecs.de> References: <200506211022.04280.mneumann@ntecs.de> Message-ID: well, ok but perhaps there is a better name. If we don't come up with something better, then Helper stays :) -g. On 6/21/05, Michael Neumann wrote: > Am Tuesday 21 June 2005 09:50 schrieb George Moschovitis: > > Dear devs, > > > > I would like to a convienience like the Helper's in Rails. Ie modules > > that contain a collection of utility methods that can be mixed in with > > Controllers. However I don't like the name that much. Does anyone have > > a better suggestion? > > What's wrong with Helper? It's quite short, descriptive and you can combine it > with another word, e.g. ThisHelper, RenderHelper etc. > > Regards, > > Michael > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From mneumann at ntecs.de Tue Jun 21 04:49:09 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Tue, 21 Jun 2005 10:49:09 +0200 Subject: [Nitro] Better name? In-Reply-To: References: <200506211022.04280.mneumann@ntecs.de> Message-ID: <200506211049.09751.mneumann@ntecs.de> Am Tuesday 21 June 2005 10:36 schrieb George Moschovitis: > well, ok but perhaps there is a better name. If we don't come up with > something better, then Helper stays :) I usually used *Mixin in the past, e.g. RenderMixin. Do you like it better? ;-) Regards, Michael From george.moschovitis at gmail.com Tue Jun 21 04:54:13 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 21 Jun 2005 11:54:13 +0300 Subject: [Nitro] Better name? In-Reply-To: <200506211049.09751.mneumann@ntecs.de> References: <200506211022.04280.mneumann@ntecs.de> <200506211049.09751.mneumann@ntecs.de> Message-ID: Mixin is too general, I am thinking about Utils, e.g. ForumUtils, but perhaps Helper is better.... -g. On 6/21/05, Michael Neumann wrote: > Am Tuesday 21 June 2005 10:36 schrieb George Moschovitis: > > well, ok but perhaps there is a better name. If we don't come up with > > something better, then Helper stays :) > > I usually used *Mixin in the past, e.g. RenderMixin. Do you like it > better? ;-) > > Regards, > > Michael > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From george.moschovitis at gmail.com Tue Jun 21 05:39:56 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 21 Jun 2005 12:39:56 +0300 Subject: [Nitro] Loosing connection to DB Message-ID: Dear devs, I have a Webrick server running as a daemon and connecting to a Mysql Database. Some times, about every 3-4 days I get an error like: Mysql server has gone away. Has anyone seen any similar behaviour or has any idea what may be causing this? thanks in advance for any help George. -- http://nitro.rubyforge.org http://www.joy.gr From dcorbin at machturtle.com Tue Jun 21 06:20:04 2005 From: dcorbin at machturtle.com (David Corbin) Date: Tue, 21 Jun 2005 06:20:04 -0400 Subject: [Nitro] Better name? In-Reply-To: References: Message-ID: <200506210620.04923.dcorbin@machturtle.com> On Tuesday 21 June 2005 03:50 am, George Moschovitis wrote: > Dear devs, > > I would like to a convienience like the Helper's in Rails. Ie modules > that contain a collection of utility methods that can be mixed in with > Controllers. However I don't like the name that much. Does anyone have > a better suggestion? Here here! Helper is a lousy name/suffix. It's almost like say FooObject. In Rails, the Helper classes are really for supporing the view (though they may be mixed in to the controller, I don't know). Something that at least qualifies it like "ViewHelper" would have been bettter than just Helper, IMO. I think I like ViewSupport better, though I'm not thrilled with that. David From james_b at neurogami.com Tue Jun 21 08:46:30 2005 From: james_b at neurogami.com (James Britt) Date: Tue, 21 Jun 2005 05:46:30 -0700 Subject: [Nitro] Better name? In-Reply-To: <200506211049.09751.mneumann@ntecs.de> References: <200506211022.04280.mneumann@ntecs.de> <200506211049.09751.mneumann@ntecs.de> Message-ID: <42B80C26.1040201@neurogami.com> Michael Neumann wrote: > Am Tuesday 21 June 2005 10:36 schrieb George Moschovitis: > >>well, ok but perhaps there is a better name. If we don't come up with >>something better, then Helper stays :) > > > I usually used *Mixin in the past, e.g. RenderMixin. Do you like it > better? ;-) I like that, though Helper seems OK, too. But they *are* mixins, no? Why not just call it that? (One complaint I have with many frameworks is that that they can obscure the underlying details for no good reason, and this interferes with users learning more about the platform. Things that are fairly straightforward get clever or goofy names, and users miss out on a better understanding of their tools.) James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys From alang at cronosys.com Tue Jun 21 09:10:11 2005 From: alang at cronosys.com (Alan Garrison) Date: Tue, 21 Jun 2005 09:10:11 -0400 Subject: [Nitro] Better name? In-Reply-To: <42B80C26.1040201@neurogami.com> References: <200506211022.04280.mneumann@ntecs.de> <200506211049.09751.mneumann@ntecs.de> <42B80C26.1040201@neurogami.com> Message-ID: <42B811B3.80205@cronosys.com> Some interesting/funny synonmyms from dictionary.com: accomplice, shill, buttinski, coach, consultant, guide, mentor, partner, deputy, stooge, secretary, buddy, cohort, sidekick, babysitter, lackey, custodian, valet, waiter, fairy godmother (heh). -- Alan Garrison Cronosys, LLC Phone: 216-221-4600 ext 308 From george.moschovitis at gmail.com Tue Jun 21 09:28:25 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Tue, 21 Jun 2005 16:28:25 +0300 Subject: [Nitro] Better name? In-Reply-To: <42B811B3.80205@cronosys.com> References: <200506211022.04280.mneumann@ntecs.de> <200506211049.09751.mneumann@ntecs.de> <42B80C26.1040201@neurogami.com> <42B811B3.80205@cronosys.com> Message-ID: > fairy godmother (heh). Just what we were looking for :-) -g. -- http://nitro.rubyforge.org http://www.joy.gr From paulha at aracnet.com Tue Jun 21 10:33:25 2005 From: paulha at aracnet.com (PAUL HANCHETT) Date: Tue, 21 Jun 2005 07:33:25 -0700 Subject: [Nitro] Better name? In-Reply-To: <42B811B3.80205@cronosys.com> References: <200506211022.04280.mneumann@ntecs.de> <200506211049.09751.mneumann@ntecs.de> <42B80C26.1040201@neurogami.com> <42B811B3.80205@cronosys.com> Message-ID: <42B82535.4000102@aracnet.com> George, I like shill, buttinski, and stooge. So I recommend you *not* use those! :-) Alan Garrison wrote: > Some interesting/funny synonmyms from dictionary.com: > > accomplice, shill, buttinski, coach, consultant, guide, mentor, > partner, deputy, stooge, secretary, buddy, cohort, sidekick, > babysitter, lackey, custodian, valet, waiter, fairy godmother (heh). > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/nitro-general/attachments/20050621/c2f5d3fc/attachment.html From vanek at acd.net Tue Jun 21 17:39:26 2005 From: vanek at acd.net (Lou Vanek) Date: Tue, 21 Jun 2005 17:39:26 -0400 Subject: [Nitro] Loosing connection to DB In-Reply-To: References: Message-ID: It sounds like the mysql db connection is not being closed after it is used. MySQL has two variables, 'wait_timeout' and 'interactive_timeout' that specify how long a dormant db connection will be allowed to remain open before it is automatically closed by mysql. Both of these variables are usually set to 28800 (i.e. 8 hrs). Wait_timeout is used by connections that are supposed to be short-lived. In my opinion, this should be reset to something more on the order of 90 instead of 28800. show variables like '%timeout%' Interactive_timeout is used by programs like the 'mysql' client program that expects to be connected for long periods of time. I guess the solution is to test the db connection and reconnect if the connection has been terminated by mysql. George Moschovitis wrote: > Dear devs, > > I have a Webrick server running as a daemon and connecting to a Mysql > Database. Some times, > about every 3-4 days I get an error like: > > Mysql server has gone away. > > Has anyone seen any similar behaviour or has any idea what may be causing this? > > thanks in advance for any help > > George. From nitro at tcb.mailworks.org Tue Jun 21 18:44:33 2005 From: nitro at tcb.mailworks.org (TImothy Brown) Date: Tue, 21 Jun 2005 18:44:33 -0400 Subject: [Nitro] Multiple databases? In-Reply-To: References: <1119289976.7870.236768262@webmail.messagingengine.com> <42B71DB9.7090707@cs.helsinki.fi> Message-ID: George, Thanks for the help. Please make sure you cover the case where multiple stores are available (as opposed to just covering multiple sources of PostgreSQL or MySQL, cover a MySQL source, PostgreSQL source, and memory source) Tim On Jun 20, 2005, at 4:11 PM, George Moschovitis wrote: > Hello Aleksi, > > thanks a lot for your detailed post. Be a little patient, I have a > much better and simpler solution, will be available in 0.20.0 > > regards, > George. > > PS: please feel free to add stuff like that in www.nitrohq.com > > -- > http://nitro.rubyforge.org > http://www.joy.gr > > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > > From george.moschovitis at gmail.com Wed Jun 22 04:13:48 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Wed, 22 Jun 2005 11:13:48 +0300 Subject: [Nitro] Loosing connection to DB In-Reply-To: References: Message-ID: Hello, > It sounds like the mysql db connection is not being closed after it is used. this might be the problem, I remember a similar problem with the sqlite adapter. thanks for pointing out! -g. -- http://nitro.rubyforge.org http://www.joy.gr From epiperak at softlab.ece.ntua.gr Wed Jun 22 06:02:40 2005 From: epiperak at softlab.ece.ntua.gr (Emmanuel Piperakis) Date: Wed, 22 Jun 2005 13:02:40 +0300 (EEST) Subject: [Nitro] Basic Stuff... In-Reply-To: References: Message-ID: Hello everyone, I have some basic questions. I am new to Ruby, very new to Nitro, and and some some experience with Rails. I built an app in Rails, and new my version 2 has to be in Nitro. I am a relatively experienced java developer. I give you my background so that you can answer to my questions appropriatly :-) So, let me begin: 1) How does the controller connect to the view? In the blog example does each function in the controller correspond to a view file with the same filename as the function name? (like in rails?) 2) Must there be one controller per table in the db? (I guess not based on the examples, but I must ask) 3) in the run.rb file of blog example: I understand the Localization and Og setup directives, but not the rest. 3a) Where is the api for the Rendering? what is a shader? and why does it get passed the LocalizationShader? 3b) The dispatcher starts 3 controllers? Is the first a default AKA :root? and the rest are named 'xml' and 'api'. Are these specific names denoting something? What is the ApiController for? I can not see it being used somewhere. What is the XmlController for? Why do we need 3? 4) What conf. directives are there and where is the info about them? Sorry for the basic type of questions, but I believe that not everything is obvious to newbies like myself :-/ Thank you in advance.. Emmanouil Piperakis (epiperak at cs.ntua.gr) {To explore is Human, to Create is Devine, To teach is Primal, to Rule is Sin} From george.moschovitis at gmail.com Wed Jun 22 06:19:25 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Wed, 22 Jun 2005 13:19:25 +0300 Subject: [Nitro] Basic Stuff... In-Reply-To: References: Message-ID: Hello, > 1) How does the controller connect to the view? In the blog example does > each function in the controller correspond to a view file with the same > filename as the function name? (like in rails?) yeap the controller works more or less like in rails. So if you have a file called my_action.xhtml you can add a method def my_action end in the controller. unlike Rails you can also have parameters in the action, ie: def my_action(oid) ... end so when you call http://www.mysite.com/my_action/2 oid is initialized to 2 and you dont have to do request['oid'] just oid. But this needs better explaining, wait for a tutorial... please also note that you never add the .xhtml extension in urls, in a way Nitro provides implicit nice urls. > 2) Must there be one controller per table in the db? (I guess not based on > the examples, but I must ask) Not, controllers have nothing to do with DB. > 3a) Where is the api for the Rendering? what is a shader? and why does it > get passed the LocalizationShader? Ignore this for the moment. Better documentation is coming. > 3b) The dispatcher starts 3 controllers? Is the first a default AKA :root? > and the rest are named 'xml' and 'api'. Are these specific names denoting > something? What is the ApiController for? I can not see it being used > somewhere. What is the XmlController for? Why do we need 3? :root is special and denotes '/' if you use the url: http://www.mysite.com/xxxx then the xxxx action in the controller mapped to :root is called if you use the url: http://www.mysite.com/xml/xxx then the xxx action in the controller mapped to xml is called I think this is similar to Rails too... > 4) What conf. directives are there and where is the info about them? Please be patient. I will update the configuration system to be more self explanatory... regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From epiperak at softlab.ece.ntua.gr Wed Jun 22 21:33:12 2005 From: epiperak at softlab.ece.ntua.gr (Emmanuel Piperakis) Date: Thu, 23 Jun 2005 04:33:12 +0300 (EEST) Subject: [Nitro] Basic Stuff... In-Reply-To: References: Message-ID: George thanx for the immediate answer. I will keep on reading the examples. Lets say that I would like to understand the whole structure of Nitro, what part of the code should I start reading? Emmanouil Piperakis (epiperak at cs.ntua.gr) {To explore is Human, to Create is Devine, To teach is Primal, to Rule is Sin} From epiperak at softlab.ece.ntua.gr Thu Jun 23 05:07:37 2005 From: epiperak at softlab.ece.ntua.gr (Emmanuel Piperakis) Date: Thu, 23 Jun 2005 12:07:37 +0300 (EEST) Subject: [Nitro] Basic Stuff... In-Reply-To: References: Message-ID: Does Nitro support dynamic forms? Let me explain a bit what I mean: I have to create something like an excel worksheet; the user will input some number in the (lets say) tenant form (rent, expenses, etc) and then I would like to have a form that I can connect eg the Total_Rent field of the form Cashflow to the sum of all tenants' rents... I was thinking of a form where on the left part I have a pull down combobox with all the available variables that I could assign values to, then = to another combobox with fields like SUM, SUMIF, then third field with available "sumable" fields from other classes eg Tenant.rent Tenant.utility_charges, and so on... This would be like creating a function in excel, but instead in would be with nitro. Do you think is is possible to do so? If yes, do I have to use Ajax architecture to update the form on the fly, (eg to add one more row with another function I press a + sign or something, new row is inserted, with corresponding Var = FUNCTION Parameters comboboxes) Thank you for you time :-) Emmanouil Piperakis (epiperak at cs.ntua.gr) {To explore is Human, to Create is Devine, To teach is Primal, to Rule is Sin} From george.moschovitis at gmail.com Thu Jun 23 06:39:12 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu, 23 Jun 2005 13:39:12 +0300 Subject: [Nitro] Basic Stuff... In-Reply-To: References: Message-ID: If I understand correctly, this isn't something that should be part in a general framework like Nitro. You could *easily* do this form with Nitro and Ruby. You don't *have* to use AJAX but if you do so, you could create a better user experience. Check out: lib/nitro/builder/form.rb and proto/public/js/prototype.js (The Protoype javscript library) in the nitro-0.19.0 distribution for exta help. regards, George. On 6/23/05, Emmanuel Piperakis wrote: > Does Nitro support dynamic forms? > > Let me explain a bit what I mean: > I have to create something like an excel worksheet; the user will input > some number in the (lets say) tenant form (rent, expenses, etc) and then I > would like to have a form that I can connect eg the Total_Rent field of > the form Cashflow to the sum of all tenants' rents... > > I was thinking of a form where on the left part I have a pull down > combobox with all the available variables that I could assign values to, > then = to another combobox with fields like SUM, SUMIF, then third field > with available "sumable" fields from other classes eg Tenant.rent > Tenant.utility_charges, and so on... > > This would be like creating a function in excel, but instead in would be > with nitro. Do you think is is possible to do so? If yes, do I have to use > Ajax architecture to update the form on the fly, (eg to add one more row > with another function I press a + sign or something, new row is inserted, > with corresponding Var = FUNCTION Parameters comboboxes) > > Thank you for you time :-) > > > Emmanouil Piperakis (epiperak at cs.ntua.gr) > {To explore is Human, to Create is Devine, > To teach is Primal, to Rule is Sin} > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://nitro.rubyforge.org http://www.joy.gr From epiperak at softlab.ece.ntua.gr Thu Jun 23 10:49:32 2005 From: epiperak at softlab.ece.ntua.gr (Emmanuel Piperakis) Date: Thu, 23 Jun 2005 17:49:32 +0300 (EEST) Subject: [Nitro] Basic Stuff... In-Reply-To: References: Message-ID: Thank you G. > If I understand correctly, this isn't something that should be part in > a general framework like Nitro. > You could *easily* do this form with Nitro and Ruby. You don't *have* > to use AJAX but if you do so, you could create a better user > experience. > > Check out: > > lib/nitro/builder/form.rb > > and > > proto/public/js/prototype.js (The Protoype javscript library) > > in the nitro-0.19.0 distribution for exta help. > > regards, > George. > > On 6/23/05, Emmanuel Piperakis wrote: >> Does Nitro support dynamic forms? >> >> Let me explain a bit what I mean: >> I have to create something like an excel worksheet; the user will input >> some number in the (lets say) tenant form (rent, expenses, etc) and then I >> would like to have a form that I can connect eg the Total_Rent field of >> the form Cashflow to the sum of all tenants' rents... >> >> I was thinking of a form where on the left part I have a pull down >> combobox with all the available variables that I could assign values to, >> then = to another combobox with fields like SUM, SUMIF, then third field >> with available "sumable" fields from other classes eg Tenant.rent >> Tenant.utility_charges, and so on... >> >> This would be like creating a function in excel, but instead in would be >> with nitro. Do you think is is possible to do so? If yes, do I have to use >> Ajax architecture to update the form on the fly, (eg to add one more row >> with another function I press a + sign or something, new row is inserted, >> with corresponding Var = FUNCTION Parameters comboboxes) >> >> Thank you for you time :-) >> >> >> Emmanouil Piperakis (epiperak at cs.ntua.gr) >> {To explore is Human, to Create is Devine, >> To teach is Primal, to Rule is Sin} >> _______________________________________________ >> Nitro-general mailing list >> Nitro-general at rubyforge.org >> http://rubyforge.org/mailman/listinfo/nitro-general >> > > > -- > http://nitro.rubyforge.org > http://www.joy.gr > > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > Emmanouil Piperakis (epiperak at cs.ntua.gr) {To explore is Human, to Create is Devine, To teach is Primal, to Rule is Sin} From george.moschovitis at gmail.com Fri Jun 24 09:53:32 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Fri, 24 Jun 2005 16:53:32 +0300 Subject: [Nitro] Prototype/Scriptaculous Message-ID: Dear devs, I am working on some wrappers over the Prototype/Scriptaculous javascript libraries. I would like a better name than: remote_form remote_link as used in Rails. perhaps async_link, link_form, bg_link, or something else? Good suggestions will be appreciated... regards, George. -- http://nitro.rubyforge.org http://www.joy.gr From ak at navel.gr Fri Jun 24 10:00:58 2005 From: ak at navel.gr (Anastasios Koutoumanos) Date: Fri, 24 Jun 2005 17:00:58 +0300 Subject: [Nitro] wish: o.options Message-ID: <42BC121A.8030207@navel.gr> an easy one: the options builder should provide sortable list of options when fed with a hash. Unfortunately the current implementation will spit out a set of options in (almost) random order. One idea is to allow for a block (with sorting rules) to be provided to the options builder. Another one (which i would go for) is _not_ take hash as an argument but only arrays and check if each element of the array is a single value or an array of two values - on the later case, use the first value for option.value and the second for the text. An alternative to the second one: allow for one or two arrays, if two are given they should be "parrallel arrays" (of the same size...) Tasos -- Did you joy today? www.JOY.GR !!! From ak at navel.gr Fri Jun 24 10:04:41 2005 From: ak at navel.gr (Anastasios Koutoumanos) Date: Fri, 24 Jun 2005 17:04:41 +0300 Subject: [Nitro] wish: streaming output from nitro Message-ID: <42BC12F9.8010004@navel.gr> An important feature for webapps (missing from many 'frameworks') is the ability to stream the output (html, xml, etc.) to the user's browser _while_ this is generated by the backend. Does Nitro include this functionality? If so, how can it be used? If not, how difficult is it to craft it into the next release? I would say it's of high priority, compared to some other minor improvements, features under consideration... Tasos -- Did you joy today? www.JOY.GR !!! From james_b at neurogami.com Fri Jun 24 10:36:24 2005 From: james_b at neurogami.com (James Britt) Date: Fri, 24 Jun 2005 07:36:24 -0700 Subject: [Nitro] Prototype/Scriptaculous In-Reply-To: References: Message-ID: <42BC1A68.1030501@neurogami.com> George Moschovitis wrote: > Dear devs, > > I am working on some wrappers over the Prototype/Scriptaculous > javascript libraries. Why? James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys From george.moschovitis at gmail.com Fri Jun 24 10:49:30 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Fri, 24 Jun 2005 17:49:30 +0300 Subject: [Nitro] Prototype/Scriptaculous In-Reply-To: <42BC1A68.1030501@neurogami.com> References: <42BC1A68.1030501@neurogami.com> Message-ID: > > I am working on some wrappers over the Prototype/Scriptaculous > > javascript libraries. > > Why? Because I want to use some javascript stuff for a project of mine. I want to make some simple 'Elements' (tags) to streamline the process, ie something like:
Here is a link:
Ping
-g. -- http://www.nitrohq.com http://www.joy.gr From george.moschovitis at gmail.com Fri Jun 24 10:50:56 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Fri, 24 Jun 2005 17:50:56 +0300 Subject: [Nitro] wish: streaming output from nitro In-Reply-To: <42BC12F9.8010004@navel.gr> References: <42BC12F9.8010004@navel.gr> Message-ID: This is possible with the fastcgi adapter. There was a dirty hack that allows you to implement this in Webrick, I 'll have to dig this out... -g. On 6/24/05, Anastasios Koutoumanos wrote: > An important feature for webapps (missing from many 'frameworks') is the > ability to stream the output (html, xml, etc.) to the user's browser > _while_ this is generated by the backend. Does Nitro include this > functionality? If so, how can it be used? If not, how difficult is it to > craft it into the next release? I would say it's of high priority, > compared to some other minor improvements, features under consideration... > > Tasos > > -- Did you joy today? www.JOY.GR !!! > > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://www.nitrohq.com http://www.joy.gr From george.moschovitis at gmail.com Fri Jun 24 10:52:33 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Fri, 24 Jun 2005 17:52:33 +0300 Subject: [Nitro] wish: o.options In-Reply-To: <42BC121A.8030207@navel.gr> References: <42BC121A.8030207@navel.gr> Message-ID: Thanks for the tips, you are right, the options builder needs an update... regards, George. On 6/24/05, Anastasios Koutoumanos wrote: > an easy one: > > the options builder should provide sortable list of options when fed > with a hash. Unfortunately the current implementation will spit out a > set of options in (almost) random order. One idea is to allow for a > block (with sorting rules) to be provided to the options builder. > Another one (which i would go for) is _not_ take hash as an argument but > only arrays and check if each element of the array is a single value or > an array of two values - on the later case, use the first value for > option.value and the second for the text. An alternative to the second > one: allow for one or two arrays, if two are given they should be > "parrallel arrays" (of the same size...) > > Tasos > > -- > Did you joy today? www.JOY.GR !!! > > _______________________________________________ > Nitro-general mailing list > Nitro-general at rubyforge.org > http://rubyforge.org/mailman/listinfo/nitro-general > -- http://www.nitrohq.com http://www.joy.gr From epiperak at softlab.ece.ntua.gr Sun Jun 26 21:08:56 2005 From: epiperak at softlab.ece.ntua.gr (Emmanuel Piperakis) Date: Mon, 27 Jun 2005 04:08:56 +0300 (EEST) Subject: [Nitro] Prototype/Scriptaculous In-Reply-To: References: Message-ID: > I am working on some wrappers over the Prototype/Scriptaculous > javascript libraries. I would like > a better name than: > > remote_form > remote_link > > as used in Rails. > > perhaps async_link, link_form, bg_link, or something else? Good > suggestions will be appreciated... how about ajax_link, sub_link, thread_link (a bit too long)? Emmanouil Piperakis (epiperak at cs.ntua.gr) {To explore is Human, to Create is Devine, To teach is Primal, to Rule is Sin} From james_b at neurogami.com Wed Jun 29 11:11:00 2005 From: james_b at neurogami.com (James Britt) Date: Wed, 29 Jun 2005 08:11:00 -0700 Subject: [Nitro] Nitro Wiki In-Reply-To: References: Message-ID: <42C2BA04.9060304@neurogami.com> George Moschovitis wrote: > Dear devs, > > I have installed a simple wiki on www.nitrohq.com. This is an > intermediate solution until the final NitroHQ site is ready. I would > like to ask everyone on this list to help me organize this wiki and > start adding content. I'm collecting tutorial docs to add to the wiki, but I just noticed that it's a (gasp!) PHP wiki. Eeew. Given the abundance of Ruby wikis, might we consider using one of them? Of course, a *Nitro* powered wiki would be the best. (This always gives me a chuckle: http://weblog.rubyonrails.com/index.php) James From george.moschovitis at gmail.com Wed Jun 29 15:56:27 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Wed, 29 Jun 2005 22:56:27 +0300 Subject: [Nitro] Nitro Wiki In-Reply-To: <42C2BA04.9060304@neurogami.com> References: <42C2BA04.9060304@neurogami.com> Message-ID: As I said, this wiki is temporal. A Nitro based wiki will be available 'real soon now' ! But please upload your content, this will automatically be converted to the nitro wiki. I expect the nitro based wiki to be online at the end of next week. regards, George. -- http://www.nitrohq.com http://www.joy.gr From james_b at neurogami.com Wed Jun 29 20:40:48 2005 From: james_b at neurogami.com (James Britt) Date: Wed, 29 Jun 2005 17:40:48 -0700 Subject: [Nitro] Nitro Wiki In-Reply-To: References: <42C2BA04.9060304@neurogami.com> Message-ID: <42C33F90.3070504@neurogami.com> George Moschovitis wrote: > As I said, this wiki is temporal. A Nitro based wiki will be available > 'real soon now' ! > But please upload your content, this will automatically be converted > to the nitro wiki. I expect the nitro based wiki to be online at the > end of next week. Excellent! I Nitro wiki would, of course, be the best. (And if it supported Textile it would be the bestest!) James From james_b at neurogami.com Wed Jun 29 21:03:46 2005 From: james_b at neurogami.com (James Britt) Date: Wed, 29 Jun 2005 18:03:46 -0700 Subject: [Nitro] A Nitro Challenge Message-ID: <42C344F2.4040405@neurogami.com> There's been some discussion on the ruby-doc mailing list over the relative difficulty in getting new or fixed documentation through the pipeline. For the most part, there have been a fairly small set of people who have taken the time to pick some core or standard libraries and fix or create the documentation. They then bring it to the attention of someone responsible enough to approve the docs and get it committed into the main CVS tree. It seems to have worked well enough for most cases, but lately there have been problems. People come along, enthusiastic about contributing documentation, but do not know where to start. They do not know if anyone is already working on some set of docs, or where to send the docs for review, or how to tell if anyone is even paying attention. There was a proposal to have some sort of proto-docs repository, such that people would have a place to store works in progress, see if there is already work being done, and read or add comments. Part of me thinks a wiki might be sufficient, but I fear the possibility of work getting lost due to wiki spam or abuse. I think I'd like to see a system where main contributors would need a user name and password issued by an admin, but with a fairly open system for reader comments. Naturally, someone suggested that some sort of repository would be easy enough to knock out in Rails, and I'm sure that's true. However, I've been gradually developing a reworking of ruby-doc.org using Nitro, so would prefer a Nitro solution. And I think it might make a nice showcase for Nitro as well. Anyone feel up to this? Any suggestions on design, basic function, development path? I shouldn't be at all complex; just some basic features that are easy to use but hard to abuse. James Britt -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys From george.moschovitis at gmail.com Thu Jun 30 03:04:28 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu, 30 Jun 2005 10:04:28 +0300 Subject: [Nitro] Nitro Wiki In-Reply-To: <42C33F90.3070504@neurogami.com> References: <42C2BA04.9060304@neurogami.com> <42C33F90.3070504@neurogami.com> Message-ID: > I Nitro wiki would, of course, be the best. > (And if it supported Textile it would be the bestest!) Yeap, a RedCloth powered Nitro wiki will be available at the end of next week on www.nitrohq.com -g. -- http://www.nitrohq.com http://www.joy.gr From george.moschovitis at gmail.com Thu Jun 30 03:10:00 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu, 30 Jun 2005 10:10:00 +0300 Subject: [Nitro] A Nitro Challenge In-Reply-To: <42C344F2.4040405@neurogami.com> References: <42C344F2.4040405@neurogami.com> Message-ID: Hello James, this looks like a nice idea. I would like to help (after the nitro deadline of course ;-). I could help with programming and on the visual design of the site. I 'll also try to think about this site over the weekend and come up with ideas. regards, George. On 6/30/05, James Britt wrote: > There's been some discussion on the ruby-doc mailing list over the > .. > development path? I shouldn't be at all complex; just some basic > features that are easy to use but hard to abuse. -- http://www.nitrohq.com http://www.joy.gr From george.moschovitis at gmail.com Thu Jun 30 04:36:59 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu, 30 Jun 2005 11:36:59 +0300 Subject: [Nitro] Nitro Wiki In-Reply-To: References: <42C2BA04.9060304@neurogami.com> <42C33F90.3070504@neurogami.com> Message-ID: Oh, I see you uploaded some stuff on the Wiki ;-) Thanks a lot. I would suggest to the other members of this list to take a look at your text! regards, George. -- http://www.nitrohq.com http://www.joy.gr From mneumann at ntecs.de Thu Jun 30 09:18:24 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Thu, 30 Jun 2005 15:18:24 +0200 Subject: [Nitro] Wee+Nitro status Message-ID: <42C3F120.30903@ntecs.de> Hi George & Co, I've made some progress on merging Wee and Nitro. I can now handle a Wee Component as a Nitro Controller. But my ultimate goal is to be able to call Wee components from within Nitro controllers. The idea is as follows: Each component must have a unique name, e.g. 'pager', or 'pager1', 'pager2' etc... Of course, only the root_components have to be registered. The Session stores the components in a Hash: session[:components] => { 'pager' => Wee::Component... } Inside your Nitro Controller, you can create new components with: make_component 'pager', Wee::Component.new Or once you don't need them any longer, drop them with: drop_component 'pager' Both is just sugar for: session[:components]['pager'] = ... # or session[:components].delete('pager') Except, that for page-full components, the latter might remove the page-id for 'pager' from the URL. Then you can render a component with: render_component 'pager' Additionally you need a special ComponentController, registered under /component. This is needed for the callbacks. I'd like to access the components under: /component/callback/pager Or even better: /component/pager/callback Is there a simple way how I could map that to method 'callback' of the ComponentController with the component name as parameter, e.g. def callback(component_name) # ... end Or as: request.params['component_name'] For pageless components (no backtracking), we're done here. But to make page-full components work, we need to carry around the page-ids of each component in the url, e.g. http://127.0.0.1:9999/blog/show?_pager_pid=8&_pager2_pid=4 When 'render_component' is called for the first time for a component, it's page-id is injected into the URL and carried around until it is removed from the URL. This could be done by: forget_component 'pager' You can of course mix page-full and page-less components. Any ideas for the "?query" names I should use to not interfer with other Nitro apps? _c.pager=page_id _c.pager2=page_id ... _c . "component name" = "page_id" Nitro coders that also use Wee components in their apps, would have to include all those params into each link. This could be done like: