[Yum-devel] [PATCH 1/4] Add caching getloginuid, so we can use it outside of history

Tim Lauridsen tim.lauridsen at gmail.com
Fri Jun 11 07:23:51 UTC 2010


On Thu, Jun 10, 2010 at 10:47 PM, James Antill <james at and.org> wrote:

> ---
>  yum/misc.py |   12 +++++++++++-
>  1 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/yum/misc.py b/yum/misc.py
> index 921b95c..35b8056 100644
> --- a/yum/misc.py
> +++ b/yum/misc.py
> @@ -899,7 +899,7 @@ def unlink_f(filename):
>         if e.errno != errno.ENOENT:
>             raise
>
> -def getloginuid():
> +def _getloginuid():
>     """ Get the audit-uid/login-uid, if available. None is returned if
> there
>         was a problem. Note that no caching is done here. """
>     #  We might normally call audit.audit_getloginuid(), except that
> requires
> @@ -914,6 +914,16 @@ def getloginuid():
>     except ValueError:
>         return None
>
> +_cached_getloginuid = None
> +def getloginuid():
> +    """ Get the audit-uid/login-uid, if available. None is returned if
> there
> +        was a problem. The value is cached, so you don't have to save it.
> """
> +    global _cached_getloginuid
> +    if _cached_getloginuid is None:
> +        _cached_getloginuid = _getloginuid()
> +    return _cached_getloginuid
> +
> +
>  # ---------- i18n ----------
>  import locale
>  import sys
> --
> 1.7.0.1
>
> _______________________________________________
> Yum-devel mailing list
> Yum-devel at lists.baseurl.org
> http://lists.baseurl.org/mailman/listinfo/yum-devel


ACK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20100611/bc9bc670/attachment.html>


More information about the Yum-devel mailing list