[Nitro] OG accessing manager attributes 'beneath' manager.store.ogmanager

Mark Van De Vyver mvyver at gmail.com
Sun Sep 9 00:35:41 EDT 2007


On 9/9/07, Mark Van De Vyver <mvyver at gmail.com> wrote:
> Hi,
> To make it clearer, the following script should help....
> Can anyone confirm that:
> a) whether any of the three commented out lines fail/succeed?

The three fail as expected.

> b) Is this expected?

Yes,
 ./og/lib/og/store.rb:
     attr_accessor :ogmanager

 ./og/lib/og/store/sql.rb
    attr_accessor :conn
    attr_accessor :typemap

The other instance variables are encapsulated and aren't 'exposed', via
 attr_reader or attr_accessor.

There is an issue here about the scope of the `options` variable.

If I understand correctly:
A manager looks after one-and-only-one store.
    - The manager and store options should never be out of sync - correct?
       (This wasn't necessarily the case).

Can anyone confirm this should be the behavior?

Mark

> c) If yes, can that data be accessed any other way?
>
> Thanks
> Mark
>
> ************ start script ************
>
> #!/usr/bin/ruby
> require "spec"
> require "yaml"
> require "pp"
>
> begin
>   require "rubygems"
> rescue LoadError => ex
>   # drink it!
> end
>
> require "og"
>
> @manager = Og.start
>
> Aspects.setup
>
> pp @manager
> pp @manager.store.class.name
> pp @manager.store.conn
> pp @manager.store.ogmanager
> #pp @manager.store.options #undefined method `options' ...
> #pp @manager.store.transaction_nesting #undefined method
> `transaction_nesting'...
> pp @manager.store.typemap
> #pp @manager.store.store_class # undefined method `store_class'
>
> ************ End script ************
>
> On 9/8/07, Mark Van De Vyver <mvyver at gmail.com> wrote:
> > Hi,
> > In the context of writing a spec, I'm having trouble accessing any
> > attribute "below" the @manager.store.ogmanager attribute.
> >
> > By below I mean in reference to the print out below.
> >
> > Hopefully I'm doing something really dumb, I can print everything from
> > `@manager.models` down to `@manager.store.ogmanager`, but nothing
> > beneath that.
> >
> > Specifically, for example, `pp @manager.store.options` gives an error,
> > see the end of the the following output (Questions follow below):
> >
> > >    @config = OgSpecHelper.setup({:config_only=>true})
> > >    @manager = Og.start
> > >    Aspects.setup
> > >    pp @manager
> > >.    pp @manager.store.options
> >
> > #<Og::Manager:0xb7791d48
> >  @models=[],
> >  @name=:memory,
> >  @options=
> >   {:name=>:memory,
> >    :user=>"",
> >    :dbi_driver=>:sqlite,
> >    :evolve_schema=>:warn,
> >    :password=>"",
> >    :called_by_og_setup=>true,
> >    :adapter=>:dbi},
> >  @store=
> >   #<Og::DbiAdapter:0xb7791a78
> >    @conn=
> >     #<DBI::DatabaseHandle:0xb77916e0
> >      @handle=#<DBI::DBD::SQLite::Database:0xb7791730>,
> >      @trace_mode=2,
> >      @trace_output=#<IO:0xb7f03018>>,
> >    @ogmanager=#<Og::Manager:0xb7791d48 ...>,
> >    @options=
> >     {:name=>:memory,
> >      :user=>"",
> >      :dbi_driver=>:sqlite,
> >      :evolve_schema=>:warn,
> >      :password=>"",
> >      :called_by_og_setup=>true,
> >      :adapter=>:dbi},
> >    @transaction_nesting=0,
> >    @typemap=
> >     {Fixnum=>"integer",
> >      Time=>"timestamp",
> >      Float=>"float",
> >      Integer=>"integer",
> >      Date=>"date",
> >      TrueClass=>"boolean",
> >      Hash=>"text",
> >      Og::Blob=>"bytea",
> >      Object=>"text",
> >      String=>"text",
> >      Array=>"text"}>,
> >  @store_class=Og::DbiAdapter>
> > NoMethodError in 'A default connection to a new Og store manager before(:all)'
> > undefined method `options' for #<Og::DbiAdapter:0xb7833864>
> >
> > Is this expected behavior?
> > If not, any suggestions about what might be causing this?
> >
> > Mark
> >
>


More information about the Nitro-general mailing list