Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
keychain.master_password dialog and ui.View subclass issue
-
If I have a call to
keychain.get_password
in a delegate and have amaster_password
set it will lock up the ui even if using a@ui.in_background
function decorator. What am I doing wrong here?(Don't mind the messed up indentation - posting on mobile...)
import keychain, ui, console class Test (ui.View): def __init__(self): tv = ui.TableView() tv.frame = self.bounds tv.flex = 'WH' ds = ui.ListDataSource(['foo','bar','baz']) ds.action = self.item_selected tv.data_source = ds tv.delegate = ds self.tableview = tv self.add_subview(self.tableview) @ui.in_background def item_selected(self,sender): #this will lock up bec of the keychain.master_password alert #(make sure that u have an entry in the keychain 'name'/'user'/'foobar') print keychain.get_password('name','user') #if you comment out the line above, you can see that the @ui.in_background is working #bec the next line does not lock up the ui console.alert('test') test = Test() test.present('sheet')
This only happens when subclassing
ui.View
. When making a "standalone" view there's no lock up:import keychain, ui @ui.in_background def cell_tapped(sender): print keychain.get_password('name','user') tv = ui.TableView() tv.flex = 'WH' ds = ui.ListDataSource({'title':x,'accessory_type':'detail_button'} for x in ['foo','bar','baz']) ds.action = cell_tapped tv.data_source = tv.delegate = ds tv.present('sheet')
-
So it seems like it's either an issue with
ui.View
or thekeychain.master_password
dialog. (It only happens when subclassingui.View
).
@omz is this a bug?# to reproduce: # set a master_password; # set a service in the keychain: # name=foo, username=bar, password=whatever # (so that the master_password dialog will be called) # Issue: The ui locks up import keychain, ui class GetPassword (ui.View): #this doesn't make a difference #@ui.in_background def get_password(self,name,user): return keychain.get_password(name,user) gp = GetPassword() print gp.get_password('foo','bar')
-
Looks like a bug. Thanks, I'll look into it.
-
Thanks so much!
-
@omz I have a similar problem I think. This works fine the first time it's run. However the second time through... the second script hangs the ui when it's run.
import ui, console, editor class Test (ui.View): def __init__(self): tv = ui.TableView() tv.frame = self.bounds tv.flex = 'WH' ds = ui.ListDataSource(['foo','bar','baz']) ds.action = self.item_selected tv.data_source = ds tv.delegate = ds self.tableview = tv self.add_subview(self.tableview) @ui.in_background def item_selected(self,sender): #console.alert('Test') self.close() editor.open_file('Test2') Test().present('popover')
import console console.alert('Test2')