Menu

#9 Configurable Plugins not behaving the same way

v1.x
closed
nobody
1
2015-05-08
2015-04-27
Anonymous
No

I have been developing my project using Yapsy 1.10 on a Portable Python 2.7.5 distribution, and I am trying to upgrade to Python 2.7.6.1, and ended up with the 1.11 version of Yapsy.

My plugins define a panel class, and the created panel keeps a copy of the plugin (wxPython, though this isn't pertinent).

So in one method of my panel I have:

self.plugin.setConfigOption('lastdate', self.date_field.Value)

This sets the option exactly as I want it to in Python 2.7.5/Yapsy 1.10

In Python 2.6.1/Yapsy 1.11, I get:

Traceback (most recent call last):
  File "C:\Users\josh\Desktop\reporter\plugins\dateparsetest.py", line 58, in on_go_stud
    self.plugin.setConfigOption('lastdate', self.date_field.Value)
  File "C:\Users\josh\Desktop\Portable Python 2.7.6.1\App\lib\site-packages\yapsy\ConfigurablePluginManager.py", line 193, in <lambda>
    x,y)
  File "C:\Users\josh\Desktop\Portable Python 2.7.6.1\App\lib\site-packages\yapsy\ConfigurablePluginManager.py", line 164, in registerOptionFromPlugin
    self.config_has_changed()
TypeError: <lambda>() takes exactly 1 argument (0 given)

The panel init method includes the following code, which behaves the same way in both versions:

if self.plugin.hasConfigOption('lastdate'):
    self.date_field.SetValue(self.plugin.getConfigOption('lastdate'))

I cannot see any difference in the ConfigurablePluginManager code between 1.10 and 1.11, but perhaps I'm missing something?

Discussion

  • Josh English

    Josh English - 2015-04-27

    This is my ticket. I thought I logged into SF but apparently I didn't.

     
  • Thibauld Nion

    Thibauld Nion - 2015-05-03

    Hello and sorry for the late reply. This seems related to the fallbak set at init time of the configurablepluginmanger. Do you set the config_change_trigger argument explicitely to domething ?

    I'm asking to try to understand why this has not failed earlier as the default value for this argument is badly defined (the lambda should take no argument).

     
  • Josh English

    Josh English - 2015-05-06

    I don't use config_change_trigger in the creation of the ConfigurablePlugIn.

    In my Frame's init I call:

    manager = ConfigurablePluginManager(self._config)
    

    where self._config is an instance of SafeConfigParser.

    Wait... I went back and looked. Apparently in my 2.7.5 distribution, I made a change in the ConfigurablePluginManager code (bad user!) because I was getting this same error before. Instead of assigning lambda: True to config_change_trigger, I went into the source to update the code.

    I see what's wrong. I went ahead and changed the above code to:

    manager = ConfigurablePluginManager(self._config,
            config_change_trigger = lambda: None)
    

    and it works in both 2.7.5 and 2.7.6.

    You're right, the default_change_trigger should be a no-argument lambda by default.

    Thank you for your response, as it made me look again and realize my mistake.

     
  • Thibauld Nion

    Thibauld Nion - 2015-05-08

    Well... not worries... actually the mistake is mine in this case and I've just comited a fix + a test for that (as it happens the unit-test were providing a specific trigger which was hiding the bug).

    However, please note that if you don't provide a specific config_change_trigger and don't implement anything special elsewhere, there is a risk that the config change are not actually saved on file (the "change trigger" used by the unit-test is actually a function that saves the config in a file). => I've also added some more doc about that.

     
  • Thibauld Nion

    Thibauld Nion - 2015-05-08
    • status: open --> pending
     
  • Thibauld Nion

    Thibauld Nion - 2015-05-08
    • status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB