Challenging Project ... Need a deep guru to provide enlightenment.

Discussion in 'Ruby' started by Jeff Wood, Oct 13, 2005.

  1. Jeff Wood

    Jeff Wood Guest

    ------=_Part_10089_1753604.1129242645949
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    I think I've got a very challenging project on my hands but here's I'm
    trying to create.

    I want a completely clean(transparent) proxy object.

    One where ALL methods simply return the result of the same call on the
    proxied ( not the proxy ) object.

    I mean, if the user wants to add/override methods, that's fine, but by
    default, EVERY call should be passed through.

    I hope that makes sense...

    So:

    a =3D String
    b =3D Proxy.new( a )

    # should be the same
    a.class
    b.class

    # should be the same
    a.methods
    b.methods

    I want it be completely transparent.

    Is that possible?

    j.

    --
    "http://ruby-lang.org -- do you ruby?"

    Jeff Wood

    ------=_Part_10089_1753604.1129242645949--
    Jeff Wood, Oct 13, 2005
    #1
    1. Advertising

  2. Jeff Wood

    Joe Van Dyk Guest

    On 10/13/05, Jeff Wood <> wrote:
    > I think I've got a very challenging project on my hands but here's I'm
    > trying to create.
    >
    > I want a completely clean(transparent) proxy object.
    >
    > One where ALL methods simply return the result of the same call on the
    > proxied ( not the proxy ) object.
    >
    > I mean, if the user wants to add/override methods, that's fine, but by
    > default, EVERY call should be passed through.
    >
    > I hope that makes sense...
    >
    > So:
    >
    > a =3D String
    > b =3D Proxy.new( a )


    Would b =3D

    > # should be the same
    > a.class
    > b.class
    >
    > # should be the same
    > a.methods
    > b.methods
    >
    > I want it be completely transparent.


    Not too hard, I think:

    def create_proxy klass
    klass.dup
    end

    a =3D String
    b =3D create_proxy a

    Unless I'm not understanding something correctly.
    Joe Van Dyk, Oct 14, 2005
    #2
    1. Advertising

  3. ------=_Part_14313_13204321.1129245371034
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Lookup send and method_missing



    --
    Into RFID? www.rfidnewsupdate.com <http://www.rfidnewsupdate.com> Simple,
    fast, news.

    ------=_Part_14313_13204321.1129245371034--
    Lyndon Samson, Oct 14, 2005
    #3
  4. Jeff Wood

    Joe Van Dyk Guest

    On 10/13/05, Lyndon Samson <> wrote:
    > Lookup send and method_missing


    Won't work.

    class Hi
    def method_missing method, *args
    @obj.send method, *args
    end
    def initialize obj
    @obj =3D obj
    end
    end

    h =3D Hi.new(String)

    h.class
    =3D> Hi

    String.class
    =3D> Class

    h.methods.size
    =3D> 41

    String.methods.size
    =3D> 73
    Joe Van Dyk, Oct 14, 2005
    #4
  5. SXMgdGhlcmUgYW4gZXF1aXZhbGVudCBvZiBtZXRob2RfbWlzc2luZyB0aGF0IGludGVyY2VwdHMg
    KmFsbCoKbWV0aG9kcywgbm90IGp1c3QgdGhlIG1pc3Npbmcgb25lcz8KCk9uIDEwLzEzLzA1LCBK
    b2UgVmFuIER5ayA8am9ldmFuZHlrQGdtYWlsLmNvbT4gd3JvdGU6Cj4gT24gMTAvMTMvMDUsIEx5
    bmRvbiBTYW1zb24gPGx5bmRvbi5zYW1zb25AZ21haWwuY29tPiB3cm90ZToKPiA+IExvb2t1cCBz
    ZW5kIGFuZCBtZXRob2RfbWlzc2luZwo+Cj4gV29uJ3Qgd29yay4KPgo+IGNsYXNzIEhpCj4gICBk
    ZWYgbWV0aG9kX21pc3NpbmcgbWV0aG9kLCAqYXJncwo+ICAgICBAb2JqLnNlbmQgbWV0aG9kLCAq
    YXJncwo+ICAgZW5kCj4gICBkZWYgaW5pdGlhbGl6ZSBvYmoKPiAgICAgQG9iaiA9IG9iago+ICAg
    ZW5kCj4gZW5kCj4KPiBoID0gSGkubmV3KFN0cmluZykKPgo+IGguY2xhc3MKPiA9PiBIaQo+Cj4g
    U3RyaW5nLmNsYXNzCj4gPT4gQ2xhc3MKPgo+IGgubWV0aG9kcy5zaXplCj4gPT4gNDEKPgo+IFN0
    cmluZy5tZXRob2RzLnNpemUKPiA9PiA3Mwo+Cj4K
    Jacob Quinn Shenker, Oct 14, 2005
    #5
  6. Hi --

    On Fri, 14 Oct 2005, Jeff Wood wrote:

    > I think I've got a very challenging project on my hands but here's I'm
    > trying to create.
    >
    > I want a completely clean(transparent) proxy object.
    >
    > One where ALL methods simply return the result of the same call on the
    > proxied ( not the proxy ) object.
    >
    > I mean, if the user wants to add/override methods, that's fine, but by
    > default, EVERY call should be passed through.
    >
    > I hope that makes sense...
    >
    > So:
    >
    > a = String
    > b = Proxy.new( a )
    >
    > # should be the same
    > a.class
    > b.class
    >
    > # should be the same
    > a.methods
    > b.methods
    >
    > I want it be completely transparent.
    >
    > Is that possible?


    Are you sure you're describing what you want correctly? The class of
    String is Class -- but don't you want b.class to report String?


    David

    --
    David A. Black
    David A. Black, Oct 14, 2005
    #6
  7. Jeff Wood

    Ara.T.Howard Guest

    On Fri, 14 Oct 2005, Jeff Wood wrote:

    > I think I've got a very challenging project on my hands but here's I'm
    > trying to create.
    >
    > I want a completely clean(transparent) proxy object.
    >
    > One where ALL methods simply return the result of the same call on the
    > proxied ( not the proxy ) object.
    >
    > I mean, if the user wants to add/override methods, that's fine, but by
    > default, EVERY call should be passed through.
    >
    > I hope that makes sense...
    >
    > So:
    >
    > a = String
    > b = Proxy.new( a )
    >
    > # should be the same
    > a.class
    > b.class
    >
    > # should be the same
    > a.methods
    > b.methods
    >
    > I want it be completely transparent.
    >
    > Is that possible?


    this'll be a good start:

    harp:~ > cat a.rb
    class Proxy
    ignore = %w( __send__ __id__ )

    instance_methods.each do |m|
    next if ignore.include? m
    module_eval <<-code
    def #{ m } *a, &b
    __obj.send "#{ m }", *a, &b
    end
    code
    end

    attr_accessor '__obj'

    def initialize obj
    self.__obj = obj
    end
    end

    a = String::new '42'
    b = Proxy::new a

    p a.class
    p b.class

    p(a.methods == b.methods)



    harp:~ > ruby a.rb
    String
    String
    true


    hth.

    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | Your life dwells amoung the causes of death
    | Like a lamp standing in a strong breeze. --Nagarjuna
    ===============================================================================
    Ara.T.Howard, Oct 14, 2005
    #7
  8. Jeff Wood

    Ara.T.Howard Guest

    On Fri, 14 Oct 2005, Ara.T.Howard wrote:

    > this'll be a good start:


    <snip backwards reply>

    scratch that - try this:

    harp:~ > cat a.rb
    module Proxy
    def self::new obj
    klass = Class::new do
    ignore = %w( __send__ __id__ )

    obj.class.instance_methods.each do |m|
    next if ignore.include? m
    module_eval <<-code
    def #{ m } *a, &b
    __obj.send "#{ m }", *a, &b
    end
    code
    end

    attr_accessor '__obj'

    def initialize obj
    self.__obj = obj
    end

    self
    end
    klass::new obj
    end
    end

    a = String::new 'forty-two'
    b = Proxy::new a

    p a.class
    p b.class

    p(a.methods == b.methods)

    p b.upcase


    harp:~ > ruby a.rb
    String
    String
    true
    "FORTY-TWO"


    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | Your life dwells amoung the causes of death
    | Like a lamp standing in a strong breeze. --Nagarjuna
    ===============================================================================
    Ara.T.Howard, Oct 14, 2005
    #8
  9. Hi --

    On Fri, 14 Oct 2005, Ara.T.Howard wrote:

    > a = String::new 'forty-two'
    > b = Proxy::new a


    That's not the original problem, though. It was:

    a = String
    b = Proxy.new(a)

    I guess you have the same hunch I do, that it was actually meant to be
    String.new.


    David

    --
    David A. Black
    David A. Black, Oct 14, 2005
    #9
  10. Jeff Wood

    Jeff Wood Guest

    ------=_Part_10601_15624515.1129247599262
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    These are a good start, but what I'm really trying to do is come up with a
    completely clean way to do DRb ...

    Don't get me wrong, I love DRb for what it is, but I want transparent proxy=
    Jeff Wood, Oct 14, 2005
    #10
  11. Jeff Wood

    Jeff Wood Guest

    ------=_Part_10653_30537851.1129248161243
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Yeah, sorry.

    I mean ...

    a =3D 1
    b =3D Proxy.new( a )

    or

    a =3D "Hello, World"
    b =3D Proxy.new( a )

    or

    a =3D MyComplicatedObject.new
    b =3D Proxy.new( a )

    ...

    sorry for the mis-type ...

    j.


    On 10/13/05, David A. Black <> wrote:
    >
    > Hi --
    >
    > On Fri, 14 Oct 2005, Ara.T.Howard wrote:
    >
    > > a =3D String::new 'forty-two'
    > > b =3D Proxy::new a

    >
    > That's not the original problem, though. It was:
    >
    > a =3D String
    > b =3D Proxy.new(a)
    >
    > I guess you have the same hunch I do, that it was actually meant to be
    > String.new.
    >
    >
    > David
    >
    > --
    > David A. Black
    >
    >
    >



    --
    "http://ruby-lang.org -- do you ruby?"

    Jeff Wood

    ------=_Part_10653_30537851.1129248161243--
    Jeff Wood, Oct 14, 2005
    #11
  12. Jeff Wood

    Jeff Wood Guest

    ------=_Part_10749_18307957.1129248776728
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Does this make any sense in the context of wanting something I can script
    remotely against?

    DRb has a disposition that you have to know what you are calling remotely
    before you can call it ...

    And, if you are wanting to pass a remote object into a function, you can't
    do any duck-type checking because respond_to? is based on DRbObject, not th=
    e
    remote object it is to proxy.

    Anyways, that's the goal of the project, simply to be able to use DRb
    transparently, completely transparently.

    I look forward to any further suggestions you have, thanks for what you've
    provided already.

    j.


    On 10/13/05, Jeff Wood <> wrote:
    >
    > Yeah, sorry.
    >
    > I mean ...
    >
    > a =3D 1
    > b =3D Proxy.new( a )
    >
    > or
    >
    > a =3D "Hello, World"
    > b =3D Proxy.new( a )
    >
    > or
    >
    > a =3D MyComplicatedObject.new
    > b =3D Proxy.new( a )
    >
    > ...
    >
    > sorry for the mis-type ...
    >
    > j.
    >
    >
    > On 10/13/05, David A. Black <> wrote:
    > >
    > > Hi --
    > >
    > > On Fri, 14 Oct 2005, Ara.T.Howard wrote:
    > >
    > > > a =3D String::new 'forty-two'
    > > > b =3D Proxy::new a

    > >
    > > That's not the original problem, though. It was:
    > >
    > > a =3D String
    > > b =3D Proxy.new(a)
    > >
    > > I guess you have the same hunch I do, that it was actually meant to be
    > > String.new.
    > >
    > >
    > > David
    > >
    > > --
    > > David A. Black
    > >
    > >
    > >

    >
    >
    > --
    > "http://ruby-lang.org -- do you ruby?"
    >
    > Jeff Wood
    >
    >



    --
    "http://ruby-lang.org -- do you ruby?"

    Jeff Wood

    ------=_Part_10749_18307957.1129248776728--
    Jeff Wood, Oct 14, 2005
    #12
  13. Jeff Wood

    Trans Guest

    Hi Jeff.

    See Facets.

    facets.rubyforge.org

    In there is a modified version of Jim Weirich's BlankSlate. You can use
    that as a base class, it removes all but a handful of methods (and may
    remove even more in the future).

    That is about the best you are going to achieve without a dispatch
    mechinism, which Ruby does not have. And from what I understand won't
    ever have b/c it would slow things down too much.

    But, Ruby may get a bonafide Kernelless "ObjectShell" in the future.

    T.
    Trans, Oct 14, 2005
    #13
  14. Jeff Wood

    John Carter Guest

    Re: Challenging Project ... Need a deep guru to provideenlightenment.

    On Fri, 14 Oct 2005, Jeff Wood wrote:

    > a = String
    > b = Proxy.new( a )
    >
    > # should be the same
    > a.class
    > b.class
    >
    > # should be the same
    > a.methods
    > b.methods
    >
    > I want it be completely transparent.



    b = a

    Totally totally transparent. :))

    So which bit do you want opaque then? :))


    John Carter Phone : (64)(3) 358 6639
    Tait Electronics Fax : (64)(3) 359 4632
    PO Box 1645 Christchurch Email :
    New Zealand

    Carter's Clarification of Murphy's Law.

    "Things only ever go right so that they may go more spectacularly wrong later."

    From this principle, all of life and physics may be deduced.
    John Carter, Oct 14, 2005
    #14
  15. Jeff Wood

    Dave Burt Guest

    Jeff Wood...
    > I want a completely clean(transparent) proxy object.


    The controversial Ref class I made a while back on this list has this
    property, I think, with the exception that it also has a deref property
    which allows you to assign it a different delegate-object. You could remove
    that interface, but I imagine it could be handy.
    It just uses Delegate, and redefines is_a?, kind_of?, respond_to, and
    Module#===.

    Download it from http://www.dave.burt.id.au/ruby/ref.rb

    Cheers,
    Dave
    Dave Burt, Oct 14, 2005
    #15
  16. Jeff Wood

    Trans Guest

    Actually, I just went ahead and added a Proxy class to Facets (btw aka
    Nano Methods and Mega Modules). Very easy:

    require 'facet/blankslate'

    class Proxy < BlankSlate

    def initialize( obj )
    @self = obj
    end

    def method_missing( sym, *args, &blk )
    @self.__send__( sym, *args, &blk )
    end

    end

    What's esspeically nice about this is you can still get to the Proxy
    itself.

    irb(main):001:0> require 'facet/proxy'
    => true
    irb(main):002:0> a = "Hello Dog"
    => "Hello Dog"
    irb(main):003:0> ap = Proxy.new( a )
    => #<Proxy:0xb7c21064 @self="Hello Dog">
    irb(main):004:0> a.object_id
    => -606004354
    irb(main):005:0> ap.object_id
    => -606004354
    irb(main):006:0> ap.__meta__.object_id
    => -606009294


    Have fun,
    T.
    Trans, Oct 14, 2005
    #16
  17. Jeff Wood

    Ara.T.Howard Guest

    On Fri, 14 Oct 2005, Jeff Wood wrote:

    > These are a good start, but what I'm really trying to do is come up with a
    > completely clean way to do DRb ...
    >
    > Don't get me wrong, I love DRb for what it is, but I want transparent proxy.
    >
    > So, I want to be able to do DRb::proxy.new( "druby://add.ress:1234" )
    >
    > and get back an object I can call methods on ... that will report it self as
    > whatever the Proxy is proxying not DRbObject ...
    >
    > Does that make sense? I am wanting to be able to use irb with DRb and get
    > live auto-completion across the wire ...


    sortof. what would the proxy be? i mean, you have

    proxy(client) -->> server

    you can never acheive

    proxy(server)

    well. you can, but's that's what drb is. what i'm driving at is that it
    seems the proxy object you seek may only be wrapped around the local drb
    object and, therfore, you'll be right back where you started from. which
    object to you intend to wrap such that it would make it seem that the object
    were local?

    i think you'd need to hackery in the drb object itself - it has a notion of
    which methods to forward and which not to. you could muck with this. i'm
    unclear how a proxy would clarify the situation though...

    regards.

    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | Your life dwells amoung the causes of death
    | Like a lamp standing in a strong breeze. --Nagarjuna
    ===============================================================================
    Ara.T.Howard, Oct 14, 2005
    #17
  18. Jeff Wood

    ES Guest

    Jeff Wood wrote:
    > These are a good start, but what I'm really trying to do is come up with a
    > completely clean way to do DRb ...


    It really helps when you say what you actually want to do :)

    It seems as if the DRb object already works just like you want
    except that it says it is a DRbObject when you do #inspect or
    something? Or is there some other functionality that you need?

    > Don't get me wrong, I love DRb for what it is, but I want transparent proxy.
    >
    > So, I want to be able to do DRb::proxy.new( "druby://add.ress:1234" )
    >
    > and get back an object I can call methods on ... that will report it self as
    > whatever the Proxy is proxying not DRbObject ...
    >
    > Does that make sense? I am wanting to be able to use irb with DRb and get
    > live auto-completion across the wire ...
    >
    > I figure a transparent proxy is the ONLY way ...
    >
    > let me know if I'm going down the wrong path.
    >
    > j.
    >
    > On 10/13/05, Ara.T.Howard <> wrote:
    >
    >>On Fri, 14 Oct 2005, Ara.T.Howard wrote:
    >>
    >>
    >>>this'll be a good start:

    >>
    >><snip backwards reply>
    >>
    >>scratch that - try this:
    >>
    >>harp:~ > cat a.rb
    >>module Proxy
    >>def self::new obj
    >>klass = Class::new do
    >>ignore = %w( __send__ __id__ )
    >>
    >>obj.class.instance_methods.each do |m|
    >>next if ignore.include? m
    >>module_eval <<-code
    >>def #{ m } *a, &b
    >>__obj.send "#{ m }", *a, &b
    >>end
    >>code
    >>end
    >>
    >>attr_accessor '__obj'
    >>
    >>def initialize obj
    >>self.__obj = obj
    >>end
    >>
    >>self
    >>end
    >>klass::new obj
    >>end
    >>end
    >>
    >>a = String::new 'forty-two'
    >>b = Proxy::new a
    >>
    >>p a.class
    >>p b.class
    >>
    >>p(a.methods == b.methods)
    >>
    >>p b.upcase
    >>
    >>
    >>harp:~ > ruby a.rb
    >>String
    >>String
    >>true
    >>"FORTY-TWO"
    >>
    >>
    >>-a
    >>--
    >>
    >>===============================================================================
    >>| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    >>| phone :: 303.497.6469
    >>| Your life dwells amoung the causes of death
    >>| Like a lamp standing in a strong breeze. --Nagarjuna
    >>
    >>===============================================================================
    >>
    >>
    >>

    >
    >
    >
    > --
    > "http://ruby-lang.org -- do you ruby?"
    >
    > Jeff Wood
    >
    ES, Oct 14, 2005
    #18
  19. Jeff Wood

    Jeff Wood Guest

    ------=_Part_15899_14407167.1129288070608
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Actually I wrote a new chunk of code based on Ara's snippet that for direct
    calls does EXACTLY what I want it to ... I'll be posting it later today ...
    I just have to deal with stuff like blah.call.call2.call3 ... which I don't
    believe will currently work ... I'll have to dig through and see how DRb
    makes it work ...
    DRbObjects don't work ... call methods or call respond_to? ... they are NO=
    T
    calls on the remote object ... I don't believe ANY call on a proxied object
    should be local, they should ALL be passed over the wire ( and yes, I know
    that at least id and send can't, but everything other than those ).
    I really think you guys will like the stuff I have ... So far, I'm calling
    it Roxy ...
    Thanks.
    j.

    On 10/13/05, ES <> wrote:
    >
    > Jeff Wood wrote:
    > > These are a good start, but what I'm really trying to do is come up wit=

    h
    > a
    > > completely clean way to do DRb ...

    >
    > It really helps when you say what you actually want to do :)
    >
    > It seems as if the DRb object already works just like you want
    > except that it says it is a DRbObject when you do #inspect or
    > something? Or is there some other functionality that you need?
    >
    > > Don't get me wrong, I love DRb for what it is, but I want transparent

    > proxy.
    > >
    > > So, I want to be able to do DRb::proxy.new( "druby://add.ress:1234" )
    > >
    > > and get back an object I can call methods on ... that will report it

    > self as
    > > whatever the Proxy is proxying not DRbObject ...
    > >
    > > Does that make sense? I am wanting to be able to use irb with DRb and

    > get
    > > live auto-completion across the wire ...
    > >
    > > I figure a transparent proxy is the ONLY way ...
    > >
    > > let me know if I'm going down the wrong path.
    > >
    > > j.
    > >
    > > On 10/13/05, Ara.T.Howard <> wrote:
    > >
    > >>On Fri, 14 Oct 2005, Ara.T.Howard wrote:
    > >>
    > >>
    > >>>this'll be a good start:
    > >>
    > >><snip backwards reply>
    > >>
    > >>scratch that - try this:
    > >>
    > >>harp:~ > cat a.rb
    > >>module Proxy
    > >>def self::new obj
    > >>klass =3D Class::new do
    > >>ignore =3D %w( __send__ __id__ )
    > >>
    > >>obj.class.instance_methods.each do |m|
    > >>next if ignore.include? m
    > >>module_eval <<-code
    > >>def #{ m } *a, &b
    > >>__obj.send "#{ m }", *a, &b
    > >>end
    > >>code
    > >>end
    > >>
    > >>attr_accessor '__obj'
    > >>
    > >>def initialize obj
    > >>self.__obj =3D obj
    > >>end
    > >>
    > >>self
    > >>end
    > >>klass::new obj
    > >>end
    > >>end
    > >>
    > >>a =3D String::new 'forty-two'
    > >>b =3D Proxy::new a
    > >>
    > >>p a.class
    > >>p b.class
    > >>
    > >>p(a.methods =3D=3D b.methods)
    > >>
    > >>p b.upcase
    > >>
    > >>
    > >>harp:~ > ruby a.rb
    > >>String
    > >>String
    > >>true
    > >>"FORTY-TWO"
    > >>
    > >>
    > >>-a
    > >>--
    > >>

    >
    > >>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D=3D=3D=3D
    > >>| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    > >>| phone :: 303.497.6469
    > >>| Your life dwells amoung the causes of death
    > >>| Like a lamp standing in a strong breeze. --Nagarjuna
    > >>

    >
    > >>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D=3D=3D=3D
    > >>
    > >>
    > >>

    > >
    > >
    > >
    > > --
    > > "http://ruby-lang.org -- do you ruby?"
    > >
    > > Jeff Wood
    > >

    >
    >
    >



    --
    "http://ruby-lang.org -- do you ruby?"

    Jeff Wood

    ------=_Part_15899_14407167.1129288070608--
    Jeff Wood, Oct 14, 2005
    #19
  20. Jeff Wood

    Jeff Wood Guest

    ------=_Part_15915_7806665.1129288166865
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Or to be specifically accurate, DRbObjects aren't transparent enough ...
    they don't provide you with the list of available functionality
    appropriately.

    On 10/14/05, Jeff Wood <> wrote:
    >
    > Actually I wrote a new chunk of code based on Ara's snippet that for
    > direct calls does EXACTLY what I want it to ... I'll be posting it later
    > today ... I just have to deal with stuff like blah.call.call2.call3 ...
    > which I don't believe will currently work ... I'll have to dig through an=

    d
    > see how DRb makes it work ...
    > DRbObjects don't work ... call methods or call respond_to? ... they are
    > NOT calls on the remote object ... I don't believe ANY call on a proxied
    > object should be local, they should ALL be passed over the wire ( and yes=

    , I
    > know that at least id and send can't, but everything other than those ).
    > I really think you guys will like the stuff I have ... So far, I'm
    > calling it Roxy ...
    > Thanks.
    > j.
    >
    > On 10/13/05, ES <> wrote:
    > >
    > > Jeff Wood wrote:
    > > > These are a good start, but what I'm really trying to do is come up

    > > with a
    > > > completely clean way to do DRb ...

    > >
    > > It really helps when you say what you actually want to do :)
    > >
    > > It seems as if the DRb object already works just like you want
    > > except that it says it is a DRbObject when you do #inspect or
    > > something? Or is there some other functionality that you need?
    > >
    > > > Don't get me wrong, I love DRb for what it is, but I want transparent

    > > proxy.
    > > >
    > > > So, I want to be able to do DRb::proxy.new( "druby://add.ress:1234" )
    > > >
    > > > and get back an object I can call methods on ... that will report it

    > > self as
    > > > whatever the Proxy is proxying not DRbObject ...
    > > >
    > > > Does that make sense? I am wanting to be able to use irb with DRb and

    > > get
    > > > live auto-completion across the wire ...
    > > >
    > > > I figure a transparent proxy is the ONLY way ...
    > > >
    > > > let me know if I'm going down the wrong path.
    > > >
    > > > j.
    > > >
    > > > On 10/13/05, Ara.T.Howard <> wrote:
    > > >
    > > >>On Fri, 14 Oct 2005, Ara.T.Howard wrote:
    > > >>
    > > >>
    > > >>>this'll be a good start:
    > > >>
    > > >><snip backwards reply>
    > > >>
    > > >>scratch that - try this:
    > > >>
    > > >>harp:~ > cat a.rb
    > > >>module Proxy
    > > >>def self::new obj
    > > >>klass =3D Class::new do
    > > >>ignore =3D %w( __send__ __id__ )
    > > >>
    > > >>obj.class.instance_methods.each do |m|
    > > >>next if ignore.include? m
    > > >>module_eval <<-code
    > > >>def #{ m } *a, &b
    > > >>__obj.send "#{ m }", *a, &b
    > > >>end
    > > >>code
    > > >>end
    > > >>
    > > >>attr_accessor '__obj'
    > > >>
    > > >>def initialize obj
    > > >>self.__obj =3D obj
    > > >>end
    > > >>
    > > >>self
    > > >>end
    > > >>klass::new obj
    > > >>end
    > > >>end
    > > >>
    > > >>a =3D String::new 'forty-two'
    > > >>b =3D Proxy::new a
    > > >>
    > > >>p a.class
    > > >>p b.class
    > > >>
    > > >>p(a.methods =3D=3D b.methods)
    > > >>
    > > >>p b.upcase
    > > >>
    > > >>
    > > >>harp:~ > ruby a.rb
    > > >>String
    > > >>String
    > > >>true
    > > >>"FORTY-TWO"
    > > >>
    > > >>
    > > >>-a
    > > >>--
    > > >>

    > >
    > > >>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D=3D=3D=3D
    > > >>| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    > > >>| phone :: 303.497.6469
    > > >>| Your life dwells amoung the causes of death
    > > >>| Like a lamp standing in a strong breeze. --Nagarjuna
    > > >>
    > > >>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D=3D=3D=3D
    > >
    > > >>
    > > >>
    > > >>
    > > >
    > > >
    > > >
    > > > --
    > > > "http://ruby-lang.org -- do you ruby?"
    > > >
    > > > Jeff Wood
    > > >

    > >
    > >
    > >

    >
    >
    > --
    > "http://ruby-lang.org -- do you ruby?"
    >
    > Jeff Wood
    >




    --
    "http://ruby-lang.org -- do you ruby?"

    Jeff Wood

    ------=_Part_15915_7806665.1129288166865--
    Jeff Wood, Oct 14, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?cmFtYXRh?=

    Classical Complex challenging Asp and SQL problem

    =?Utf-8?B?cmFtYXRh?=, Apr 30, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    454
    Mark Rae
    May 3, 2005
  2. Roedy Green

    Enum enlightenment

    Roedy Green, Jul 8, 2005, in forum: Java
    Replies:
    12
    Views:
    739
    Dale King
    Jul 16, 2005
  3. Mr.Disguise
    Replies:
    19
    Views:
    460
    Mr.Disguise
    Nov 12, 2007
  4. Siemen Baader

    enlightenment libs + ruby

    Siemen Baader, Apr 16, 2009, in forum: Ruby
    Replies:
    0
    Views:
    309
    Siemen Baader
    Apr 16, 2009
  5. Jarrod Hyder

    Need a javascript guru (I need help!)

    Jarrod Hyder, Jan 27, 2005, in forum: Javascript
    Replies:
    1
    Views:
    81
Loading...

Share This Page