On Wed, Feb 5, 2014 at 3:50 PM, Clavier <[email protected]> wrote:
> Hi.
>
> I am trying to see whether I can implement __getattr__() which is called
> when a method does not exist. I have to use a very long unreadable call in
> the current version of Pyjs:
>
> server=WebRpc('http://server.com/')
> server.request(arg1, arg2) #
> Python call
> server.__getattr__('request').__call__(arg1, arg2) # Pyjs call
> because __getattr__() is not automatically called
>
> I made a class (WebRpc) that a client can access server-side objects, and
> this makes client-server programming very simple. In this case, supporting
> __getattr__() is important because it makes a server-client call exactly
> like a local call. The current Pyjs doesn't support it, so I have to call
> it explicitly making the code unreadable.
>
> I found a previous discussion about it (
> https://groups.google.com/forum/#!topic/pyjamas-dev/_aJ2nmFjjas), but I
> don't understand why it has a performance issue. I think that a programmer
> can avoid it by directly calling the method (i.e.
> "obj.__getattr__('request').call()" instead of "obj.request()") if
> performance is an issue.
>
> Please give me your advice about it (how to implement, caveats, or
> performance issues, etc).
>
are you building with --enable-accessor-proto? that discussion is from 2009.
this code:
=========================
class Hi(object):
def __getattr__(self, key):
print(key)
hi = Hi()
print(hi.there)
=========================
...will print 'there' and 'null' to the console.
--
C Anthony
--
---
You received this message because you are subscribed to the Google Groups
"Pyjs.org Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.