How to I iterate over object in a URL from Plone using a python script

Isn't this essentially the same questions as Portal Catalog object not updating ?

Please finish that question before posting again.

What is the output? What are you using to list objects? Your code is very weird. I'd be surprised it actually ever ran successfully.

what is the line "modified(obj)" for? What are you doing with manage_setLocalRoles, checkPermission and rolesOfPermission?

Lots of weird stuff going. Please don't double post. Simplify your problem.