Changeset 0ede474


Ignore:
Timestamp:
Dec 18, 2011, 11:47:36 PM (12 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
no-cups
Children:
7bd1035
Parents:
9eeab06
git-author:
Jessica B. Hamrick <jhamrick@…> (12/18/11 23:47:36)
git-committer:
Jessica B. Hamrick <jhamrick@…> (12/18/11 23:47:36)
Message:

Add documentation to the currently supported CUPS handlers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/lib/gutenbach/server/requests.py

    r9eeab06 r0ede474  
    8888        return printer_name
    8989
     90    def _get_job_id(self, request):
     91        pass
     92       
    9093    ##### Printer Commands
    9194
     
    161164    @handler_for(const.Operations.CUPS_GET_DEFAULT)
    162165    def cups_get_default(self, request, response):
     166        """The CUPS-Get-Default operation (0x4001) returns the default
     167        printer URI and attributes.
     168
     169        CUPS-Get-Default Request
     170        ------------------------
     171
     172        The following groups of attributes are supplied as part of the
     173        CUPS-Get-Default request:
     174
     175        Group 1: Operation Attributes
     176            Natural Language and Character Set:
     177                The 'attributes-charset' and
     178                'attributes-natural-language' attributes as described
     179                in section 3.1.4.1 of the IPP Model and Semantics
     180                document.
     181            'requested-attributes' (1setOf keyword):
     182                The client OPTIONALLY supplies a set of attribute
     183                names and/or attribute group names in whose values the
     184                requester is interested. If the client omits this
     185                attribute, the server responds as if this attribute
     186                had been supplied with a value of 'all'.
     187       
     188        CUPS-Get-Default Response
     189        -------------------------
     190
     191        The following groups of attributes are send as part of the
     192        CUPS-Get-Default Response:
     193
     194        Group 1: Operation Attributes
     195            Status Message:
     196                The standard response status message.
     197            Natural Language and Character Set:
     198                The 'attributes-charset' and
     199                'attributes-natural-language' attributes as described
     200                in section 3.1.4.2 of the IPP Model and Semantics
     201                document.
     202
     203        Group 2: Printer Object Attributes
     204            The set of requested attributes and their current values.
     205
     206        (Source: http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_DEFAULT )
     207
     208        """
     209           
    163210        self._get_printer_attributes(self.printers[self.default], request, response)
    164211        response.operation_id = const.StatusCodes.OK
     
    166213    @handler_for(const.Operations.CUPS_GET_PRINTERS)
    167214    def cups_get_printers(self, request, response):
     215        """
     216        The CUPS-Get-Printers operation (0x4002) returns the printer
     217        attributes for every printer known to the system. This may
     218        include printers that are not served directly by the server.
     219
     220        CUPS-Get-Printers Request
     221        -------------------------
     222       
     223        The following groups of attributes are supplied as part of the
     224        CUPS-Get-Printers request:
     225
     226        Group 1: Operation Attributes
     227            Natural Language and Character Set:
     228                The 'attributes-charset' and
     229                'attributes-natural-language' attributes as described
     230                in section 3.1.4.1 of the IPP Model and Semantics
     231                document.
     232            'first-printer-name' (name(127)):CUPS 1.2/Mac OS X 10.5
     233                The client OPTIONALLY supplies this attribute to
     234                select the first printer that is returned.
     235            'limit' (integer (1:MAX)):
     236                The client OPTIONALLY supplies this attribute limiting
     237                the number of printers that are returned.
     238            'printer-location' (text(127)): CUPS 1.1.7
     239                The client OPTIONALLY supplies this attribute to
     240                select which printers are returned.
     241            'printer-type' (type2 enum): CUPS 1.1.7
     242                The client OPTIONALLY supplies a printer type
     243                enumeration to select which printers are returned.
     244            'printer-type-mask' (type2 enum): CUPS 1.1.7
     245                The client OPTIONALLY supplies a printer type mask
     246                enumeration to select which bits are used in the
     247                'printer-type' attribute.
     248            'requested-attributes' (1setOf keyword) :
     249                The client OPTIONALLY supplies a set of attribute
     250                names and/or attribute group names in whose values the
     251                requester is interested. If the client omits this
     252                attribute, the server responds as if this attribute
     253                had been supplied with a value of 'all'.
     254            'requested-user-name' (name(127)) : CUPS 1.2/Mac OS X 10.5
     255                The client OPTIONALLY supplies a user name that is
     256                used to filter the returned printers.
     257
     258        CUPS-Get-Printers Response
     259        --------------------------
     260
     261        The following groups of attributes are send as part of the
     262        CUPS-Get-Printers Response:
     263
     264        Group 1: Operation Attributes
     265            Status Message:
     266                The standard response status message.
     267            Natural Language and Character Set:
     268                The 'attributes-charset' and
     269                'attributes-natural-language' attributes as described
     270                in section 3.1.4.2 of the IPP Model and Semantics
     271                document.
     272               
     273        Group 2: Printer Object Attributes
     274            The set of requested attributes and their current values
     275            for each printer.
     276
     277        (Source: http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_PRINTERS )
     278           
     279        """
     280
    168281        # Each printer will append a new printer attribute group.
    169282        for printer in self.printers:
     
    173286    @handler_for(const.Operations.CUPS_GET_CLASSES)
    174287    def cups_get_classes(self, request, response):
     288        """The CUPS-Get-Classes operation (0x4005) returns the printer
     289        attributes for every printer class known to the system. This
     290        may include printer classes that are not served directly by
     291        the server.
     292
     293        CUPS-Get-Classes Request
     294        ------------------------
     295
     296        The following groups of attributes are supplied as part of the
     297        CUPS-Get-Classes request:
     298
     299        Group 1: Operation Attributes
     300            Natural Language and Character Set:
     301                The 'attributes-charset' and
     302                'attributes-natural-language' attributes as described
     303                in section 3.1.4.1 of the IPP Model and Semantics
     304                document.
     305            'first-printer-name' (name(127)):CUPS 1.2/Mac OS X 10.5
     306                The client OPTIONALLY supplies this attribute to
     307                select the first printer that is returned.
     308            'limit' (integer (1:MAX)):
     309                The client OPTIONALLY supplies this attribute limiting
     310                the number of printer classes that are returned.
     311            'printer-location' (text(127)): CUPS 1.1.7
     312                The client OPTIONALLY supplies this attribute to
     313                select which printer classes are returned.
     314            'printer-type' (type2 enum): CUPS 1.1.7
     315                The client OPTIONALLY supplies a printer type
     316                enumeration to select which printer classes are
     317                returned.
     318            'printer-type-mask' (type2 enum): CUPS 1.1.7
     319                The client OPTIONALLY supplies a printer type mask
     320                enumeration to select which bits are used in the
     321                'printer-type' attribute.
     322            'requested-attributes' (1setOf keyword) :
     323                The client OPTIONALLY supplies a set of attribute
     324                names and/or attribute group names in whose values the
     325                requester is interested. If the client omits this
     326                attribute, the server responds as if this attribute
     327                had been supplied with a value of 'all'.
     328            'requested-user-name' (name(127)) : CUPS 1.2/Mac OS X 10.5
     329                The client OPTIONALLY supplies a user name that is
     330                used to filter the returned printers.
     331               
     332        CUPS-Get-Classes Response
     333        -------------------------
     334
     335        The following groups of attributes are send as part of the
     336        CUPS-Get-Classes Response:
     337
     338        Group 1: Operation Attributes
     339            Status Message:
     340                The standard response status message.
     341            Natural Language and Character Set:
     342                The 'attributes-charset' and
     343                'attributes-natural-language' attributes as described
     344                in section 3.1.4.2 of the IPP Model and Semantics
     345                document.
     346
     347        Group 2: Printer Class Object Attributes
     348            The set of requested attributes and their current values
     349            for each printer class.
     350
     351        (Source: http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_CLASSES )
     352
     353        """
     354       
     355        # We have no printer classes, so we don't need to do anything
    175356        response.operation_id = const.StatusCodes.OK
    176         # We have no printer classes, so nothing to return.
    177357
    178358class GutenbachIPPServer(BaseHTTPServer.BaseHTTPRequestHandler):
     
    196376        logger.debug("Received request: %s" % repr(request))
    197377
    198         # Attributes
     378        # Operation attributes -- typically the same for any request
    199379        attributes = [
    200380            ipp.Attribute(
     
    205385                [ipp.Value(ipp.Tags.NATURAL_LANGUAGE, 'en-us')])
    206386            ]
    207         # Attribute group
     387        # Put the operation attributes in a group
    208388        attribute_group = ipp.AttributeGroup(
    209389            const.AttributeTags.OPERATION,
    210390            attributes)
    211391
    212         # Set up the response
     392        # Set up the default response -- handlers will override these
     393        # values if they need to
    213394        response_kwargs = {}
    214395        response_kwargs['version']          = request.version
     
    223404
    224405        # Send the response across HTTP
    225         self.send_response(200, "o hai")
     406        self.send_response(200, "Gutenbach IPP Response")
    226407        self.send_header("Content-Type", "application/ipp")
    227408        self.send_header("Connection", "close")
Note: See TracChangeset for help on using the changeset viewer.