[Pki-devel] [PATCH] 59 Fixing errors reported in Pylint Code analysis Ticket #316 - Part 1

Endi Sukma Dewata edewata at redhat.com
Thu Jun 6 02:38:47 UTC 2013


On 5/31/2013 3:38 PM, Abhishek Koneru wrote:
> Please review the patch which fixes a few errors reported by pylint in
> dogtag's python code.
>
> Also find attached the remaining errors to be fixed. Will submit a
> detailed report in my next mail.
>
> How i used pylint:
>
>    -- Installed pki packages.
>    -- Executed the following command -
>       cd /usr/lib/python2.7/sitepackages; pylint -E --include-ids=y pki/
> pki/deployment/ pki/server/ `which pkispawn` `which pkidestroy` `which
> pki-upgrade` `which pki-server-upgrade`
>
> --Abhishek

Looking at the pkihelper.py again, I'm not sure if this is the right 
approach. In the original code the classes are instantiated into global 
objects and we're calling the methods of these objects like this:

   uid = identity.get_uid()

In the new code the methods are converted into static methods:

   uid = Identity.get_uid()

The problem is many of these methods actually depend on other global 
objects such as 'master', so we haven't really removed the dependency on 
global variables.

I'm thinking we probably should encapsulate the global objects into an 
object that we can pass around, then we access them as local variables. 
For example, in pkispawn we generate the master object and put it in a 
Deployer object. Then we pass the deployer object to the scriptlets.

     deployer = pki.server.Deployer(master)

     instance = scriptlet.PkiScriptlet()
     instance.spawn(deployer)

The Deployer class will have methods that generate the old global 
objects and we pass the master into those objects:

     def get_identity(self):
        return Identity(master)

In the scriptlets we can call the methods this way:

     identity = deployer.get_identity()
     uid = identity.get_uid()

What do you think?

If we do this, I'd suggest we do the conversion one global object at a 
time so it's easier to review.

-- 
Endi S. Dewata




More information about the Pki-devel mailing list