← Back to team overview

screenlets-dev team mailing list archive

[Merge] lp:~doctormo/screenlets/bugfix-lp-769795 into lp:screenlets

 

Martin Owens has proposed merging lp:~doctormo/screenlets/bugfix-lp-769795 into lp:screenlets.

Requested reviews:
  Screenlets Dev Team (screenlets-dev)

For more details, see:
https://code.launchpad.net/~doctormo/screenlets/bugfix-lp-769795/+merge/58901

Add in some checks to alert coders when they don't pass in a name for our option.
-- 
https://code.launchpad.net/~doctormo/screenlets/bugfix-lp-769795/+merge/58901
Your team Screenlets Dev Team is requested to review the proposed merge of lp:~doctormo/screenlets/bugfix-lp-769795 into lp:screenlets.
=== modified file 'src/lib/options/base.py'
--- src/lib/options/base.py	2011-03-28 15:24:57 +0000
+++ src/lib/options/base.py	2011-04-24 13:41:31 +0000
@@ -49,6 +49,8 @@
     def __init__ (self, group, name, *attr, **args):
         """Creates a new Option with the given information."""
         super(Option, self).__init__()
+        if name == None:
+            raise ValueError("Option widget %s must have name." % str(type(self)) )
         self.name = name
         self.group = group
         # To maintain compatability, we parse out the 3 attributes and
@@ -404,8 +406,10 @@
             # and create inputs
             for option in group_data['options']:
                 if option.hidden == False:
-                    val = getattr(obj, option.name)
-                    w = self.generate_widget( option, val )
+                    name = getattr(obj, option.name)
+                    if name == None:
+                        raise ValueError("Option %s has no name" % str(type(obj)))
+                    w = self.generate_widget( option, name )
                     if w:
                         box.pack_start(w, 0, 0)
                         w.show()


Follow ups