Re: python / tinymail.Account.set_pass_func
- From: Mark Doffman <mark doffman codethink co uk>
- To: Philip Van Hoof <spam pvanhoof be>
- Cc: tinymail-devel-list gnome org
- Subject: Re: python / tinymail.Account.set_pass_func
- Date: Mon, 21 Jul 2008 12:18:51 +0100
Hi Shikhar,
Philip Van Hoof wrote:
I'll let Mark Doffman answer this, he's working on the Python bindings
On Sun, 2008-07-13 at 03:09 +0530, Shikhar wrote:
Shikhar wrote:
Shikhar wrote:
I would appreciate some guidance about how to make use of
tinymail.Account.set_pass_func()
What would the (Python) signature of the function be?
The set_pass_func method should take one argument, a python function
that gets a password for the account.
Ah, looking at the tmut source code helped me figure out PasswordGetter
Not actually, it turns out. I have spent a lot of time figuring this out
so it would be great if someone could help me out. I don't have
experience with GObject so that could be tripping me, or maybe it has
something to do with the bindings
>>> from tinymail.camel import *
>>> from tinymail.uigtk import GtkPasswordDialog
>>>
>>> def get_pass(aid, prompt):
... pwdgetter = GtkPasswordDialog()
... return pwdgetter.get_password(aid, prompt)
...
>>> acc = CamelTransportAccount()
>>> acc.set_id('tny_test')
>>> acc.set_pass_func(get_pass)
__main__:1: Warning: invalid cast from `TnyCamelTransportAccount' to
`TnyList'
Segmentation fault
The code for this function is implemented in
bindings/python/tinymail.override line 351. Unfortunately the
implementation is both wrong and useless. The 'C' interface for the
account store is:
void (*set_pass_func) (TnyAccount *self, TnyGetPassFunc get_pass_func);
This is very difficult to bind because there is no user data associated
with the callback. The function the python bindings needs to pass in the
get_pass_func argument is a marshaller function. The purpose of this
function is to marshal data arguments in and out of the implementing
python function, and to actually invoke it.
This means that the actual python function must be stored as a data
argument, which is missing in this interface.
Ideally all callback functions in the tinymail interface would use
GClosures, as this would be trivial to bind to. Failing that providing
user data associated with each callback would make binding by hand
possible.
Currently it will be difficult, but possible, to provide a python
wrapper for this function. The solution would involve using
g_object_set_data to store a pointer to the user data on the account
object. Messy, but possible.
Much of the interface involving callbacks has not been wrapped by the
python bindings. This is the first thing that needs to be done to have
fully functioning python bindings. Many of the callback interfaces have
user data associated, not sure how many of these difficult cases there are.
(Same error even if the account has a Camel
session/username/password/hostname/port/name etc. attributes set)
_______________________________________________
tinymail-devel-list mailing list
tinymail-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/tinymail-devel-list
I don't have the time right now to make a concerted push on wrapping the
callback functions. I can however provide help if you wish to do so.
The g_object_set_data idea for wrapping this particular function comes
from Rob Taylor. So maybe I can test it out and get back to you.
Thanks
Mark
--
Mark Doffman, Codethink Ltd. - http://codethink.co.uk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]