Hey, campineros. And many good handshakes to zimbatm for getting some patches applied. So, yeah, I''d really like to get rid of any serious dependancies with this 1.6 release. Anything that''s not in stdlib has to go. Of course, camping-omnibus will still assume the whole ActiveRecord, Markaby, Mongrel setup that''s in the history books. Metaid can be removed and replaced with: def Object.meta_def n,&b (class<<self;self;end).instance_eval{define_method n,&b};end Markaby''s going to take much more work. Part of the issue is: how does an app tell Camping that it needs to use Markaby without screwing up the other apps? My hunch is we''ll use some eval''d code to override render per-App like you see in camping/db.rb. The default will be plain strings: def render *a,&b;s=send(*a,&b);s=send(:layout){s} if /^_/!~a[0]. to_s and m.respond_to?:layout;s;end And, well, as for ActiveSupport, Camping only uses the supra- flexi-careless-hash, so we need a replacement. I''m not too hot on [symbol] and [string] equivalence. But I do like to call the query string vars like methods. What do you think about using OpenStruct instead? I''ve been testing with this: class H < OpenStruct def u h;for k,v in h;@table[k.to_sym]=v;new_ostruct_member(k);end def self.[] *a;new *a;end en Or, you know, just Hash is okay, right folks? _why
> I''m not too hot on [symbol] and [string] equivalence. But I do like > to call the query string vars like methods. What do you think about > using OpenStruct instead? > > I''ve been testing with this: > > class H < OpenStruct > def u h;for k,v in h;@table[k.to_sym]=v;new_ostruct_member(k);end > def self.[] *a;new *a;end > en >I''m a fan! -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/camping-list/attachments/20070925/6fb1bf83/attachment.bin
On Sep 26, 2007, at 12:26 AM, why the lucky stiff wrote:> class H < OpenStructHow about class H < (HashWithIndifferentAccess rescue Hash) for the lesser among us (who always include and require)? -- Julian ''Julik'' Tarkhanov please send all personal mail to me at julik.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/camping-list/attachments/20070926/b5f38c06/attachment-0001.html
On Tue, 25 Sep 2007 17:26:37 -0500, why the lucky stiff <why at whytheluckystiff.net> wrote:> I''m not too hot on [symbol] and [string] equivalence. But I do like > to call the query string vars like methods. What do you think about > using OpenStruct instead? > > I''ve been testing with this: > > class H < OpenStruct > def u h;for k,v in h;@table[k.to_sym]=v;new_ostruct_member(k);end > def self.[] *a;new *a;end > en > > Or, you know, just Hash is okay, right folks?I''d be fine with just Hash. OpenStruct is cool and all, but if this is to be used for query parameters you''re going to have to be really paranoid about key names (e.g. imagine a query with a variable named new_ostruct_member). -mental
Regular hashes are good. Would need to make a decision whether to prefer string or symbol keys. String is easier to support; Symbol looks prettier in your editor. Evan On 9/25/07, Julian ''Julik'' Tarkhanov <julian.tarkhanov at gmail.com> wrote:> > > On Sep 26, 2007, at 12:26 AM, why the lucky stiff wrote: > > > class H < OpenStruct > > How about > > class H < (HashWithIndifferentAccess rescue Hash) > > for the lesser among us (who always include and require)? > > -- > Julian ''Julik'' Tarkhanov > please send all personal mail to me at julik.nl > > > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-- Evan Weaver Cloudburst, LLC
On Sep 26, 2007, at 12:45 AM, Evan Weaver wrote:> Symbol looks prettier in your editor.How do you parametrize symbols into a QS or pass them from a browser? I''d say strings will do with an optional HWIA for the ones who do. I do smoke ActiveSupport, at least because of all the unicody goodness we''ve put in there. -- Julian ''Julik'' Tarkhanov please send all personal mail to me at julik.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/camping-list/attachments/20070926/cc96887d/attachment.html
On Sep 26, 2007, at 12:42 AM, MenTaLguY wrote:> you''re going to have to be really > paranoid about key names (e.g. imagine a query with a variable named > new_ostruct_member).>> @table[k.to_sym]=v;new_ostruct_member(k)this might already be a server crasher. you know how many unique to_syms you can do before the table is full? -- Julian ''Julik'' Tarkhanov please send all personal mail to me at julik.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/camping-list/attachments/20070926/3d5052ef/attachment.html
On Wed, 26 Sep 2007 01:30:34 +0200, Julian ''Julik'' Tarkhanov <julian.tarkhanov at gmail.com> wrote:>> you''re going to have to be really >> paranoid about key names (e.g. imagine a query with a variable named >> new_ostruct_member). > >>> @table[k.to_sym]=v;new_ostruct_member(k) > > this might already be a server crasher. you know how many unique > to_syms you can do before the table is full?Ah, yeah, good catch. Actually any approach which let you access query parameters as methods would have that problem -- behind the scenes, every uniquely named method introduces a symbol. This is even a potential issue for approaches using method_missing, since in MRI, rb_call wants an ID (normally obtained via rb_to_id). -mental
On Sep 26, 2007, at 2:05 AM, MenTaLguY wrote:> behind the > scenes, every uniquely named method introduces a symbol.yep. but then it''s _you_ who calls that accessor, not some John Doe who sends you a POST :-) -- Julian ''Julik'' Tarkhanov please send all personal mail to me at julik.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/camping-list/attachments/20070926/5cd2ee4a/attachment.html
On 9/25/07, Julian ''Julik'' Tarkhanov <julian.tarkhanov at gmail.com> wrote:> this might already be a server crasher. you know how many unique to_syms you > can do before the table is full?As far as I can tell, sym_tbl is just a regular st_table, so it''s an expanding array similar to the Ruby heap. So there''s no danger of hard crash. If your camping process runs for a month you should end up with no more than 10 or 20 extra mbs of memory used in anything but a deliberately pathological situation. Evan -- Evan Weaver Cloudburst, LLC
On Tue, Sep 25, 2007 at 05:05:04PM -0700, MenTaLguY wrote:> Ah, yeah, good catch. Actually any approach which let you access > query parameters as methods would have that problem -- behind the > scenes, every uniquely named method introduces a symbol. This is > even a potential issue for approaches using method_missing, since > in MRI, rb_call wants an ID (normally obtained via rb_to_id).Right, okay. Well the current approach uses method_missing. I say we just go with Hash and then have a specific option for using HashWithIndifferentAccess. I like this alot better, because it means you can just set the option and things work just like 1.5 and backwards. Camping.goes :Tepee Tepee.include HashWithIndifferentAccess Tepee.include Markaby Err... or something. Let''s use Strings for Hash keys, since HWIA uses Strings internally, which is likely to be nicer for ActiveRecord and because of symbol memory concerns, lastly. _why
2007/9/26, why the lucky stiff <why at whytheluckystiff.net>:> Hey, campineros. And many good handshakes to zimbatm for getting > some patches applied.You''re welcome !> Markaby''s going to take much more work. Part of the issue is: how > does an app tell Camping that it needs to use Markaby without > screwing up the other apps? My hunch is we''ll use some eval''d code > to override render per-App like you see in camping/db.rb.Adding method_missing to the views would be enough to proxy the calls to Markaby. You''d still need to propagate the controller''s instance variables to the view tough. One solution is to add the View into the controller. The disadvantages is that it greaten the chances of method clashes and that the distinction between Helper and Base module would be null. The advantage is that method_missing could be reused, like it is for the NotFound and ServerError classes.> And, well, as for ActiveSupport, Camping only uses the supra- > flexi-careless-hash, so we need a replacement.I suggest that H is a child of Hash. Extensions can extend it to provide method_missing goodness or anything else. The only concern I have is about case-sensitiveness. I am not sure if the http headers are normalized on input or not. -- Cheers, zimbatm
On Sep 26, 2007, at 4:24 AM, Evan Weaver wrote:> As far as I can tell, sym_tbl is just a regular st_table, so it''s an > expanding array similar to the Ruby heap.Oddly enough, this: c = 0 loop { c += 1; puts "two_symbols_sitting_in_a_tree_#{c}".to_sym } was a total crasher on 1.8.5 but works on 1.8.6 p110. Don''t have time to build 1.8.5. again and check, unfortunately. But as people say that symbol table is not even GCed I would avoid converting people''s input into symbols anyway. -- Julian ''Julik'' Tarkhanov please send all personal mail to me at julik.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/camping-list/attachments/20070926/84999230/attachment.html
On Sep 26, 2007, at 12:35 AM, Julian ''Julik'' Tarkhanov wrote:> class H < (HashWithIndifferentAccess rescue Hash)To be clear, I''m really for the hash also because I use the "obj = @items.delete" paradigm to signify "take this item out because we''ll work with it"). But you can optionally shortcut nil assignment to delete (which would be nasty). -- Julian ''Julik'' Tarkhanov please send all personal mail to me at julik.nl -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/camping-list/attachments/20070926/cc49bb57/attachment-0001.html
Minimal HWIA removal patch attached. So far, the examples, file upload, sessions, all work under mongrel with the patch applied. _why, is it something like that that you want ? I''m not even sure if HWIA extension is useful. The method_missing shortcut is even shorter than the one with :symbols. -- Cheers, zimbatm -------------- next part -------------- A non-text attachment was scrubbed... Name: camping-no-HWIA.diff Type: text/x-diff Size: 2944 bytes Desc: not available Url : http://rubyforge.org/pipermail/camping-list/attachments/20070926/a05a4f0f/attachment.bin
On Wed, Sep 26, 2007 at 11:33:42AM +0200, Jonas Pfenniger wrote:> I suggest that H is a child of Hash. Extensions can extend it to > provide method_missing goodness or anything else. The only concern I > have is about case-sensitiveness. I am not sure if the http headers > are normalized on input or not.Well, case-sensitiveness would be a prob with 1.5 as well. Since @env.HTTP_HOST will work and @env.http_host will not. _why
2007/9/27, why the lucky stiff <why at whytheluckystiff.net>:> Well, case-sensitiveness would be a prob with 1.5 as well. Since > @env.HTTP_HOST will work and @env.http_host will not.True. So what do you think of the attached patch ? It removes roughly 50 octets to camping.rb and seems to work pretty well, except for apps that used :symbols to access H members. -- Cheers, zimbatm -------------- next part -------------- A non-text attachment was scrubbed... Name: camping-no-HWIA.diff Type: text/x-diff Size: 4911 bytes Desc: not available Url : http://rubyforge.org/pipermail/camping-list/attachments/20070929/baa051db/attachment.bin