Patch for TypeError in

Ricardo Jorge rvelhote at
Sun Feb 7 10:35:17 MST 2010

Hi everyone.

When trying to obtain the length of a SharesContainer object, which
has __len__ defined, the script would exit with the error "Fix for
TypeError: argument of type 'LoadParm' is not iterable"
It can be fixed by calling the services() method (which is partof
LoadParm) which returns a List item.

#!/usr/bin/env python
import param, shares

samba_lp = param.LoadParm()

container = shares.SharesContainer(samba_lp)
print len(container)

Result: Fix for TypeError: argument of type 'LoadParm' is not iterable


You can use.

1. len(samba_lp)
 Number 1, will also return the global section so you shoud use
len(samba_lp) - 1

2. len(container.keys())

diff --git a/source4/scripting/python/samba/
index 89a312e..b6ddeb3 100644
--- a/source4/scripting/python/samba/
+++ b/source4/scripting/python/samba/
@@ -37,7 +37,7 @@ class SharesContainer(object):
         return Share(self._lp[name])

     def __len__(self):
-        if "global" in self._lp:
+        if "global" in
             return len(self._lp)-1
         return len(self._lp)

Best Regards.

More information about the samba-technical mailing list