def headerParserHandler(self, req):

        log_setreq(req)
        # We need to init CFG and Logging
        options = req.get_options()
        # if we are initializing out of a <Location> handler don't
        # freak out
        if "RHNComponentType" not in options:
            # clearly nothing to do
            return apache.OK
        initCFG(options["RHNComponentType"])
        initLOG(CFG.LOG_FILE, CFG.DEBUG)
        """ parse the request, init database and figure out what can we call """
        log_debug(2, req.the_request)
        # call method from inherited class
        ret = apacheSession.headerParserHandler(self, req)
        if ret != apache.OK:
            return ret
        # make sure we have DB connection
        if not CFG.SEND_MESSAGE_TO_ALL:
            try:
                rhnSQL.initDB()
            except rhnSQL.SQLConnectError:
                rhnTB.Traceback(mail=1, req=req, severity="schema")
                return apache.HTTP_INTERNAL_SERVER_ERROR
        else:
            # If in outage mode, close the DB connections
            rhnSQL.closeDB()

        # Store client capabilities
        client_cap_header = 'X-RHN-Client-Capability'
        if client_cap_header in req.headers_in:
            client_caps = req.headers_in[client_cap_header]
            client_caps = [
                _f for _f in list(
                    map(string.strip, string.split(client_caps, ","))) if _f
            ]
            rhnCapability.set_client_capabilities(client_caps)

        # Enabling the input header flags associated with the redirects/newer clients
        redirect_support_flags = [
            'X-RHN-Redirect', 'X-RHN-Transport-Capability'
        ]
        for flag in redirect_support_flags:
            if flag in req.headers_in:
                rhnFlags.set(flag, str(req.headers_in[flag]))

        return apache.OK
예제 #2
0
    def headerParserHandler(self, req):

        log_setreq(req)
        # We need to init CFG and Logging
        options = req.get_options()
        # if we are initializing out of a <Location> handler don't
        # freak out
        if not options.has_key("RHNComponentType"):
            # clearly nothing to do
            return apache.OK
        initCFG(options["RHNComponentType"])
        initLOG(CFG.LOG_FILE, CFG.DEBUG)

        """ parse the request, init database and figure out what can we call """
        log_debug(2, req.the_request)
        # call method from inherited class
        ret = apacheSession.headerParserHandler(self, req)
        if ret != apache.OK:
            return ret
        # make sure we have DB connection
        if not CFG.SEND_MESSAGE_TO_ALL:
            try:
                rhnSQL.initDB()
            except rhnSQL.SQLConnectError:
                rhnTB.Traceback(mail=1, req=req, severity="schema")
                return apache.HTTP_INTERNAL_SERVER_ERROR
        else:
            # If in outage mode, close the DB connections
            rhnSQL.closeDB()

        # Store client capabilities
        client_cap_header = 'X-RHN-Client-Capability'
        if req.headers_in.has_key(client_cap_header):
            client_caps = req.headers_in[client_cap_header]
            client_caps = filter(None,
                                 map(string.strip, string.split(client_caps, ","))
                                 )
            rhnCapability.set_client_capabilities(client_caps)

        # Enabling the input header flags associated with the redirects/newer clients
        redirect_support_flags = ['X-RHN-Redirect', 'X-RHN-Transport-Capability']
        for flag in redirect_support_flags:
            if req.headers_in.has_key(flag):
                rhnFlags.set(flag, str(req.headers_in[flag]))

        return apache.OK
예제 #3
0
#
# Copyright (c) 2008 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
import rhnSQL
from rhnCapability import set_client_capabilities, update_client_capabilities

if __name__ == '__main__':
    rhnSQL.initDB('rhnuser/rhnuser@webdev')

    set_client_capabilities([
        "caneatCheese(1)=1", "caneatMeat(22)=3", "a(3)=4", "b(3)=5",
    ])
    update_client_capabilities(1000102174)