Changeset 75928fe for server


Ignore:
Timestamp:
Jan 21, 2012, 11:31:27 PM (12 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
no-cups
Children:
5ffffe0
Parents:
d42236e
git-author:
Jessica B. Hamrick <jhamrick@…> (01/21/12 23:31:27)
git-committer:
Jessica B. Hamrick <jhamrick@…> (01/21/12 23:31:27)
Message:

Fix whitespace issues in requests.py

File:
1 edited

Legend:

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

    r3cb6c7b r75928fe  
    126126    def print_job(self, request, response):
    127127        """RFC 2911: 3.2.1 Print-Job Operation
    128 
     128       
    129129        This REQUIRED operation allows a client to submit a print job
    130130        with only one document and supply the document data (rather
     
    232232
    233233        This REQUIRED operation is similar to the Print-Job operation
    234         (section 3.2.1) except that a client supplies no document data and
    235         the Printer allocates no resources (i.e., it does not create a new
    236         Job object).  This operation is used only to verify capabilities of a
    237         printer object against whatever attributes are supplied by the client
    238         in the Validate-Job request.  By using the Validate-Job operation a
    239         client can validate that an identical Print-Job operation (with the
    240         document data) would be accepted. The Validate-Job operation also
    241         performs the same security negotiation as the Print-Job operation
    242         (see section 8), so that a client can check that the client and
    243         Printer object security requirements can be met before performing a
    244         Print-Job operation.
    245 
    246         The Validate-Job operation does not accept a 'document-uri' attribute
    247         in order to allow a client to check that the same Print-URI operation
    248         will be accepted, since the client doesn't send the data with the
    249         Print-URI operation.  The client SHOULD just issue the Print-URI
    250         request.
    251 
    252         The Printer object returns the same status codes, Operation
    253         Attributes (Group 1) and Unsupported Attributes (Group 2) as the
    254         Print-Job operation.  However, no Job Object Attributes (Group 3) are
    255         returned, since no Job object is created.
     234        (section 3.2.1) except that a client supplies no document data
     235        and the Printer allocates no resources (i.e., it does not
     236        create a new Job object).  This operation is used only to
     237        verify capabilities of a printer object against whatever
     238        attributes are supplied by the client in the Validate-Job
     239        request.  By using the Validate-Job operation a client can
     240        validate that an identical Print-Job operation (with the
     241        document data) would be accepted. The Validate-Job operation
     242        also performs the same security negotiation as the Print-Job
     243        operation (see section 8), so that a client can check that the
     244        client and Printer object security requirements can be met
     245        before performing a Print-Job operation.
     246
     247        The Validate-Job operation does not accept a 'document-uri'
     248        attribute in order to allow a client to check that the same
     249        Print-URI operation will be accepted, since the client doesn't
     250        send the data with the Print-URI operation.  The client SHOULD
     251        just issue the Print-URI request.
     252
     253        Request
     254        -------
     255        Group 1: Operation Attributes
     256            REQUIRED 'attributes-charset'
     257            REQUIRED 'attributes-natural-language'
     258            REQUIRED 'printer-uri' (uri)
     259            OPTIONAL 'requesting-user-name' (name(MAX))
     260            OPTIONAL 'job-name' (name(MAX))
     261            OPTIONAL 'ipp-attribute-fidelity' (boolean)
     262            OPTIONAL 'document-name' (name(MAX))
     263            OPTIONAL 'compression' (type3 keyword)
     264            OPTIONAL 'document-format' (mimeMediaType)
     265            OPTIONAL 'document-natural-language' (naturalLanguage)
     266            OPTIONAL 'job-k-octets' (integer(0:MAX))
     267            OPTIONAL 'job-impressions' (integer(0:MAX))
     268            OPTIONAL 'job-media-sheets' (integer(0:MAX))
     269        Group 2: Job Template Attributes
     270        Group 3: Document Content
     271
     272        Response
     273        --------
     274        Group 1: Operation Attributes
     275            OPTIONAL 'status-message' (text(255))
     276            OPTIONAL 'detailed-status-message' (text(MAX))
     277            REQUIRED 'attributes-charset'
     278            REQUIRED 'attributes-natural-language'
     279        Group 2: Unsupported Attributes
     280       
    256281        """
     282
    257283        operation = request.attribute_groups[0]
    258284        user_name = None
    259285        job_name = None
    260286        job_k_octets = None
     287
    261288        # requested printer uri
    262289        if 'printer-uri' not in operation:
     
    282309            job_name=job_name,
    283310            job_k_octets = job_k_octets)
    284 
    285         #raise ipp.errors.ServerErrorOperationNotSupported
    286311
    287312    @handler_for(ipp.OperationCodes.GET_JOBS)
     
    378403        """3.2.2 Print-URI Operation
    379404
    380         This OPTIONAL operation is identical to the Print-Job operation
    381         (section 3.2.1) except that a client supplies a URI reference to the
    382         document data using the 'document-uri' (uri) operation attribute (in
    383         Group 1) rather than including the document data itself.  Before
    384         returning the response, the Printer MUST validate that the Printer
    385         supports the retrieval method (e.g., http, ftp, etc.) implied by the
    386         URI, and MUST check for valid URI syntax.  If the client-supplied URI
    387         scheme is not supported, i.e. the value is not in the Printer
    388         object's 'referenced-uri-scheme-supported' attribute, the Printer
    389         object MUST reject the request and return the 'client-error-uri-
    390         scheme-not-supported' status code.
    391 
    392         The IPP Printer MAY validate the accessibility of the document as
    393         part of the operation or subsequently.  If the Printer determines an
    394         accessibility problem before returning an operation response, it
    395         rejects the request and returns the 'client-error-document-access-
    396         error' status code.  The Printer MAY also return a specific document
    397         access error code using the 'document-access-error' operation
    398         attribute (see section 3.1.6.4).
    399 
    400         If the Printer determines this document accessibility problem after
    401         accepting the request and returning an operation response with one
    402         of the successful status codes, the Printer adds the
    403         'document-access- error' value to the job's 'job-state-reasons'
    404         attribute and MAY populate the job's 'job-document-access-errors'
    405         Job Description attribute (see section 4.3.11).  See The
    406         Implementer's Guide [IPP- IIG] for suggested additional checks.
     405        This OPTIONAL operation is identical to the Print-Job
     406        operation (section 3.2.1) except that a client supplies a URI
     407        reference to the document data using the 'document-uri' (uri)
     408        operation attribute (in Group 1) rather than including the
     409        document data itself.  Before returning the response, the
     410        Printer MUST validate that the Printer supports the retrieval
     411        method (e.g., http, ftp, etc.) implied by the URI, and MUST
     412        check for valid URI syntax.  If the client-supplied URI scheme
     413        is not supported, i.e. the value is not in the Printer
     414        object's 'referenced-uri-scheme-supported' attribute, the
     415        Printer object MUST reject the request and return the
     416        'client-error-uri- scheme-not-supported' status code.
     417
     418        The IPP Printer MAY validate the accessibility of the document
     419        as part of the operation or subsequently.  If the Printer
     420        determines an accessibility problem before returning an
     421        operation response, it rejects the request and returns the
     422        'client-error-document-access- error' status code.  The
     423        Printer MAY also return a specific document access error code
     424        using the 'document-access-error' operation attribute (see
     425        section 3.1.6.4).
     426
     427        If the Printer determines this document accessibility problem
     428        after accepting the request and returning an operation
     429        response with one of the successful status codes, the Printer
     430        adds the 'document-access- error' value to the job's
     431        'job-state-reasons' attribute and MAY populate the job's
     432        'job-document-access-errors' Job Description attribute (see
     433        section 4.3.11).  See The Implementer's Guide [IPP- IIG] for
     434        suggested additional checks.
    407435                                                                             
    408         If the Printer object supports this operation, it MUST support the
    409         'reference-uri-schemes-supported' Printer attribute (see section 4.4.27).
    410 
    411         It is up to the IPP object to interpret the URI and subsequently
    412         'pull' the document from the source referenced by the URI string."""
    413         operation = request.attribute_groups[0]
    414         document = request.data       
    415         user_name = None
    416         job_name = None
    417         job_k_octets = None
    418         document_format = None
    419         document_natural_language = None
    420         compression = None
    421         last_document = None
    422 
    423 
    424         # requested printer uri
    425         if 'printer-uri' not in operation:
    426             raise ipp.errors.ClientErrorBadRequest("Missing 'printer-uri' attribute")
    427         printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0]
    428         if printer_uri not in self.printer.uris:
    429             raise ipp.errors.ClientErrorAttributes(
    430                 str(operation['printer-uri']), operation['printer-uri'])
    431 
    432         if 'requesting-user-name' in operation:
    433             user_name = verify_attribute(
    434                 operation['requesting-user-name'], ipp.RequestingUserName)[0]
    435 
    436         if 'job-name' in operation:
    437             job_name = verify_attribute(
    438                 operation['job-name'], ipp.JobName)[0]
    439 
    440         if 'job-k-octets' in operation:
    441             job_k_octets = verify_attribute(
    442                 operation['job-k-octets'], ipp.JobKOctets)[0]
    443 
    444         if 'ipp-attribute-fidelity' in operation:
    445             pass # don't care
    446         if 'job-impressions' in operation:
    447             pass # don't care
    448         if 'job-media-sheets' in operation:
    449             pass # don't care
    450 
    451         # get attributes from the printer and add to response
    452         try:
    453             job_id = self.printer.print_uri(document,
    454                     document_name               = document_name,
    455                     document_format             = document_format,
    456                     document_natural_language   = document_natural_language,
    457                     requesting_user_name        = user_name,
    458                     compression                 = compression,
    459                     job_name                    = job_name,
    460                     job_k_octets                = job_k_octets)
    461         except InvalidJobException:
    462             raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id)
    463 
    464 
    465         attrs = self.printer.get_job_attributes(job_id)
    466      
    467         #Actually append the attributes we pulled
    468         response.attribute_groups.append(ipp.AttributeGroup(
    469             ipp.AttributeTags.JOB, attrs))
    470 
    471  
    472        #raise ipp.errors.ServerErrorOperationNotSupported
    473 
    474     @handler_for(ipp.OperationCodes.CREATE_JOB)
    475     def create_job(self, request, response):
    476         """RFC 2911: 3.2.4 Create-Job Operation
    477 
    478         This OPTIONAL operation is similar to the Print-Job operation
    479         (section 3.2.1) except that in the Create-Job request, a
    480         client does not supply document data or any reference to
    481         document data. Also, the client does not supply any of the
    482         'document-name', 'document- format', 'compression', or
    483         'document-natural-language' operation attributes. This
    484         operation is followed by one or more Send-Document or Send-URI
    485         operations. In each of those operation requests, the client
    486         OPTIONALLY supplies the 'document-name', 'document-format',
    487         and 'document-natural-language' attributes for each document
    488         in the multi-document Job object.
     436        If the Printer object supports this operation, it MUST support
     437        the 'reference-uri-schemes-supported' Printer attribute (see
     438        section 4.4.27).
     439
     440        It is up to the IPP object to interpret the URI and
     441        subsequently 'pull' the document from the source referenced by
     442        the URI string.
    489443
    490444        Request
     
    493447            REQUIRED 'attributes-charset'
    494448            REQUIRED 'attributes-natural-language'
    495             REQUIRED 'printer-uri' (uri)
     449            REQUIRED 'printer-uri' (uri)
     450            REQUIRED 'document-uri' (uri)
    496451            OPTIONAL 'requesting-user-name' (name(MAX))
    497452            OPTIONAL 'job-name' (name(MAX))
    498453            OPTIONAL 'ipp-attribute-fidelity' (boolean)
     454            OPTIONAL 'document-name' (name(MAX))
     455            OPTIONAL 'compression' (type3 keyword)
     456            OPTIONAL 'document-format' (mimeMediaType)
     457            OPTIONAL 'document-natural-language' (naturalLanguage)
    499458            OPTIONAL 'job-k-octets' (integer(0:MAX))
    500459            OPTIONAL 'job-impressions' (integer(0:MAX))
     
    517476            OPTIONAL 'job-state-message' (text(MAX))
    518477            OPTIONAL 'number-of-intervening-jobs' (integer(0:MAX))
     478
     479        """
     480
     481        operation = request.attribute_groups[0]
     482        document = request.data       
     483        user_name = None
     484        job_name = None
     485        job_k_octets = None
     486        document_format = None
     487        document_natural_language = None
     488        compression = None
     489        last_document = None
     490
     491        # requested printer uri
     492        if 'printer-uri' not in operation:
     493            raise ipp.errors.ClientErrorBadRequest("Missing 'printer-uri' attribute")
     494        printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0]
     495        if printer_uri not in self.printer.uris:
     496            raise ipp.errors.ClientErrorAttributes(
     497                str(operation['printer-uri']), operation['printer-uri'])
     498
     499        if 'requesting-user-name' in operation:
     500            user_name = verify_attribute(
     501                operation['requesting-user-name'], ipp.RequestingUserName)[0]
     502
     503        if 'job-name' in operation:
     504            job_name = verify_attribute(
     505                operation['job-name'], ipp.JobName)[0]
     506
     507        if 'job-k-octets' in operation:
     508            job_k_octets = verify_attribute(
     509                operation['job-k-octets'], ipp.JobKOctets)[0]
     510
     511        if 'ipp-attribute-fidelity' in operation:
     512            pass # don't care
     513        if 'job-impressions' in operation:
     514            pass # don't care
     515        if 'job-media-sheets' in operation:
     516            pass # don't care
     517
     518        # get attributes from the printer and add to response
     519        try:
     520            job_id = self.printer.print_uri(
     521                document,
     522                document_name=document_name,
     523                document_format=document_format,
     524                document_natural_language=document_natural_language,
     525                requesting_user_name=user_name,
     526                compression=compression,
     527                job_name=job_name,
     528                job_k_octets=job_k_octets)
     529
     530        except InvalidJobException:
     531            raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id)
     532
     533        attrs = self.printer.get_job_attributes(job_id)
     534     
     535        # Actually append the attributes we pulled
     536        response.attribute_groups.append(ipp.AttributeGroup(
     537            ipp.AttributeTags.JOB, attrs))
     538
     539    @handler_for(ipp.OperationCodes.CREATE_JOB)
     540    def create_job(self, request, response):
     541        """RFC 2911: 3.2.4 Create-Job Operation
     542
     543        This OPTIONAL operation is similar to the Print-Job operation
     544        (section 3.2.1) except that in the Create-Job request, a
     545        client does not supply document data or any reference to
     546        document data. Also, the client does not supply any of the
     547        'document-name', 'document- format', 'compression', or
     548        'document-natural-language' operation attributes. This
     549        operation is followed by one or more Send-Document or Send-URI
     550        operations. In each of those operation requests, the client
     551        OPTIONALLY supplies the 'document-name', 'document-format',
     552        and 'document-natural-language' attributes for each document
     553        in the multi-document Job object.
     554
     555        Request
     556        -------
     557        Group 1: Operation Attributes
     558            REQUIRED 'attributes-charset'
     559            REQUIRED 'attributes-natural-language'
     560            REQUIRED 'printer-uri' (uri)
     561            OPTIONAL 'requesting-user-name' (name(MAX))
     562            OPTIONAL 'job-name' (name(MAX))
     563            OPTIONAL 'ipp-attribute-fidelity' (boolean)
     564            OPTIONAL 'job-k-octets' (integer(0:MAX))
     565            OPTIONAL 'job-impressions' (integer(0:MAX))
     566            OPTIONAL 'job-media-sheets' (integer(0:MAX))
     567        Group 2: Job Template Attributes
     568
     569        Response
     570        --------
     571        Group 1: Operation Attributes
     572            OPTIONAL 'status-message' (text(255))
     573            OPTIONAL 'detailed-status-message' (text(MAX))
     574            REQUIRED 'attributes-charset'
     575            REQUIRED 'attributes-natural-language'
     576        Group 2: Unsupported Attributes
     577        Group 3: Job Object Attributes
     578            REQUIRED 'job-uri' (uri)
     579            REQUIRED 'job-id' (integer(1:MAX))
     580            REQUIRED 'job-state' (type1 enum)
     581            REQUIRED 'job-state-reasons' (1setOf type2 keyword)
     582            OPTIONAL 'job-state-message' (text(MAX))
     583            OPTIONAL 'number-of-intervening-jobs' (integer(0:MAX))
    519584       
    520585        """
     
    566631    @handler_for(ipp.OperationCodes.PAUSE_PRINTER)
    567632    def pause_printer(self, request, response):
     633        """3.2.7 Pause-Printer Operation
     634
     635        This OPTIONAL operation allows a client to stop the Printer
     636        object from scheduling jobs on all its devices.  Depending on
     637        implementation, the Pause-Printer operation MAY also stop the
     638        Printer from processing the current job or jobs.  Any job that
     639        is currently being printed is either stopped as soon as the
     640        implementation permits or is completed, depending on
     641        implementation.  The Printer object MUST still accept create
     642        operations to create new jobs, but MUST prevent any jobs from
     643        entering the 'processing' state.
     644
     645        If the Pause-Printer operation is supported, then the
     646        Resume-Printer operation MUST be supported, and vice-versa.
     647
     648        The IPP Printer MUST accept the request in any state and
     649        transition the Printer to the indicated new 'printer-state'
     650        before returning as follows:
     651
     652        Current       New         Reasons             Reponse
     653        --------------------------------------------------------------
     654        'idle'       'stopped'    'paused'            'successful-ok'
     655        'processing' 'processing' 'moving-to-paused'  'successful-ok'
     656        'processing' 'stopped'    'paused'            'successful-ok'
     657        'stopped'    'stopped'    'paused'            'successful-ok'
     658
     659
     660        Request
     661        -------
     662        Group 1: Operation Attributes
     663            REQUIRED 'attributes-charset'
     664            REQUIRED 'attributes-natural-language'
     665            REQUIRED 'printer-uri' (uri)
     666            OPTIONAL 'requesting-user-name' (name(MAX))
     667
     668        Response
     669        --------
     670        Group 1: Operation Attributes
     671            OPTIONAL 'status-message' (text(255))
     672            OPTIONAL 'detailed-status-message' (text(MAX))
     673            REQUIRED 'attributes-charset'
     674            REQUIRED 'attributes-natural-language'
     675        Group 2: Unsupported Attributes
     676   
    568677        """
    569             3.2.7 Pause-Printer Operation
    570 
    571             This OPTIONAL operation allows a client to stop the Printer object
    572             from scheduling jobs on all its devices.  Depending on
    573             implementation, the Pause-Printer operation MAY also stop the Printer
    574             from processing the current job or jobs.  Any job that is currently
    575             being printed is either stopped as soon as the implementation permits
    576             or is completed, depending on implementation.  The Printer object
    577             MUST still accept create operations to create new jobs, but MUST
    578             prevent any jobs from entering the 'processing' state.
    579 
    580             If the Pause-Printer operation is supported, then the Resume-Printer
    581             operation MUST be supported, and vice-versa.
    582 
    583             The IPP Printer stops the current job(s) on its device(s) that were
    584             in the 'processing' or 'processing-stopped' states as soon as the
    585             implementation permits.  If the implementation will take appreciable
    586             time to stop, the IPP Printer adds the 'moving-to-paused' value to
    587             the Printer object's 'printer-state-reasons' attribute (see section
    588             4.4.12).  When the device(s) have all stopped, the IPP Printer
    589             transitions the Printer object to the 'stopped' state, removes the
    590             'moving-to-paused' value, if present, and adds the 'paused' value to
    591             the Printer object's 'printer-state-reasons' attribute.
    592 
    593             When the current job(s) complete that were in the 'processing' state,
    594             the IPP Printer transitions them to the 'completed' state.  When the
    595             current job(s) stop in mid processing that were in the 'processing'
    596             state, the IPP Printer transitions them to the 'processing-stopped'
    597             state and adds the 'printer-stopped' value to the job's 'job-state-
    598             reasons' attribute.
    599 
    600             For any jobs that are 'pending' or 'pending-held', the 'printer-
    601             stopped' value of the jobs' 'job-state-reasons' attribute also
    602             applies.  However, the IPP Printer NEED NOT update those jobs' 'job-
    603             state-reasons' attributes and only need return the 'printer-stopped'
    604             value when those jobs are queried (so-called 'lazy evaluation').
    605 
    606             Whether the Pause-Printer operation affects jobs that were submitted
    607             to the device from other sources than the IPP Printer object in the
    608             same way that the Pause-Printer operation affects jobs that were
    609             submitted to the IPP Printer object using IPP, depends on
    610             implementation, i.e., on whether the IPP protocol is being used as a
    611             universal management protocol or just to manage IPP jobs,
    612             respectively.
    613 
    614             The IPP Printer MUST accept the request in any state and transition
    615             the Printer to the indicated new 'printer-state' before returning as
    616             follows:
    617 
    618             Current        New      'printer   IPP Printer's response status
    619             'printer-    'printer-   -state-          code and action:
    620             state'       state'    reasons'
    621 
    622             'idle'       'stopped'    'paused'  'successful-ok'
    623             'processing' 'processing' 'moving-  OPTION 1: 'successful-ok';
    624                                                       to-       Later, when all output has
    625                                                       paused'   stopped, the 'printer-state'
    626                                                                             becomes 'stopped', and the
    627                                                                             'paused' value replaces the
    628                                                                             'moving-to-paused' value in the
    629                                                                             'printer-state-reasons'
    630                                                                             attribute
    631             'processing' 'stopped'    'paused'  OPTION 2: 'successful-ok';
    632                                                                             all device output stopped
    633                                                                             immediately
    634             'stopped'    'stopped'    'paused'  'successful-ok'
    635 
    636             Access Rights: The authenticated user (see section 8.3) performing
    637             this operation must be an operator or administrator of the Printer
    638             object (see Sections 1 and 8.5).   Otherwise, the IPP Printer MUST
    639             reject the operation and return:  'client-error-forbidden', 'client-
    640             error-not-authenticated', or 'client-error-not-authorized' as
    641             appropriate.
    642 
    643             3.2.7.1 Pause-Printer Request
    644 
    645             The following groups of attributes are part of the Pause-Printer
    646             Request:
    647 
    648             Group 1: Operation Attributes
    649 
    650             Natural Language and Character Set:
    651             The 'attributes-charset' and 'attributes-natural-language'
    652             attributes as described in section 3.1.4.1.
    653 
    654             Target:
    655             The 'printer-uri' (uri) operation attribute which is the target
    656             for this operation as described in section 3.1.5.
    657 
    658             Requesting User Name:
    659             The 'requesting-user-name' (name(MAX)) attribute SHOULD be
    660             supplied by the client as described in section 8.3.
    661 
    662             3.2.7.2 Pause-Printer Response
    663 
    664             The following groups of attributes are part of the Pause-Printer
    665             Response:
    666 
    667             Group 1: Operation Attributes
    668 
    669             Status Message:
    670             In addition to the REQUIRED status code returned in every
    671             response, the response OPTIONALLY includes a 'status-message'
    672             (text(255)) and/or a 'detailed-status-message' (text(MAX))
    673             operation attribute as described in sections 13 and  3.1.6.
    674 
    675             Natural Language and Character Set:
    676             The 'attributes-charset' and 'attributes-natural-language'
    677             attributes as described in section 3.1.4.2.
    678 
    679             Group 2: Unsupported Attributes
    680 
    681             See section 3.1.7 for details on returning Unsupported Attributes.
    682 
    683    
    684     """
    685     operation = request.attribute_groups[0]
    686     printer_uri = None
    687     user_name   = None
    688     if 'printer-uri' not in operation:
     678
     679        operation = request.attribute_groups[0]
     680        printer_uri = None
     681        user_name   = None
     682        if 'printer-uri' not in operation:
    689683            raise ipp.errors.ClientErrorBadRequest("Missing 'printer-uri' attribute")
    690684        printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0]
     
    693687                str(operation['printer-uri']), operation['printer-uri'])
    694688
    695     if 'requesting-user-name' in operation:
    696         user_name = verify_attribute(
    697             operation['requesting-user-name'], ipp.RequestingUserName)[0]
    698    self.printer.pause_printer()
    699 
    700 
    701     #    raise ipp.errors.ServerErrorOperationNotSupported
     689        if 'requesting-user-name' in operation:
     690            user_name = verify_attribute(
     691                operation['requesting-user-name'], ipp.RequestingUserName)[0]
     692        self.printer.pause_printer()
    702693
    703694    @handler_for(ipp.OperationCodes.RESUME_PRINTER)
    704695    def resume_printer(self, request, response):
    705         """
    706         3.2.8 Resume-Printer Operation
     696        """3.2.8 Resume-Printer Operation
    707697
    708698        This operation allows a client to resume the Printer object
    709         scheduling jobs on all its devices.  The Printer object MUST remove
    710         the 'paused' and 'moving-to-paused' values from the Printer object's
    711         'printer-state-reasons' attribute, if present.  If there are no other
    712         reasons to keep a device paused (such as media-jam), the IPP Printer
    713         is free to transition itself to the 'processing' or 'idle' states,
     699        scheduling jobs on all its devices.  The Printer object MUST
     700        remove the 'paused' and 'moving-to-paused' values from the
     701        Printer object's 'printer-state-reasons' attribute, if
     702        present.  If there are no other reasons to keep a device
     703        paused (such as media-jam), the IPP Printer is free to
     704        transition itself to the 'processing' or 'idle' states,
    714705        depending on whether there are jobs to be processed or not,
    715706        respectively, and the device(s) resume processing jobs.
    716707
    717         If the Pause-Printer operation is supported, then the Resume-Printer
    718         operation MUST be supported, and vice-versa.
    719 
    720         The IPP Printer removes the 'printer-stopped' value from any job's
    721         'job-state-reasons' attributes contained in that Printer.
    722 
    723         The IPP Printer MUST accept the request in any state, transition the
    724         Printer object to the indicated new state as follows:
    725 
    726 
    727         Current    New 'printer-  IPP Printer's response status code and
    728         'printer-      state'                     action:
    729         state'
    730 
     708        If the Pause-Printer operation is supported, then the
     709        Resume-Printer operation MUST be supported, and vice-versa.
     710
     711        The IPP Printer removes the 'printer-stopped' value from any
     712        job's 'job-state-reasons' attributes contained in that
     713        Printer.
     714
     715        The IPP Printer MUST accept the request in any state,
     716        transition the Printer object to the indicated new state as
     717        follows:
     718
     719        Current       New           Response
     720        ---------------------------------------------
    731721        'idle'       'idle'         'successful-ok'
    732722        'processing' 'processing'   'successful-ok'
    733 
    734         'stopped'    'processing'   'successful-ok';
    735                                                    when there are jobs to be processed
    736         'stopped'    'idle'         'successful-ok';
    737                                                    when there are no jobs to be processed.
    738 
    739         Access Rights: The authenticated user (see section 8.3) performing
    740         this operation must be an operator or administrator of the Printer
    741         object (see Sections 1 and 8.5).  Otherwise, the IPP Printer MUST
    742         reject the operation and return:  'client-error-forbidden', 'client-
    743         error-not-authenticated', or 'client-error-not-authorized' as
    744         appropriate.
    745 
    746         The Resume-Printer Request and Resume-Printer Response have the same
    747         attribute groups and attributes as the Pause-Printer operation (see
    748         sections 3.2.7.1 and 3.2.7.2).                 
     723        'stopped'    'processing'   'successful-ok'
     724        'stopped'    'idle'         'successful-ok'
     725
     726        Request
     727        -------
     728        Group 1: Operation Attributes
     729            REQUIRED 'attributes-charset'
     730            REQUIRED 'attributes-natural-language'
     731            REQUIRED 'printer-uri' (uri)
     732            OPTIONAL 'requesting-user-name' (name(MAX))
     733
     734        Response
     735        --------
     736        Group 1: Operation Attributes
     737            OPTIONAL 'status-message' (text(255))
     738            OPTIONAL 'detailed-status-message' (text(MAX))
     739            REQUIRED 'attributes-charset'
     740            REQUIRED 'attributes-natural-language'
     741        Group 2: Unsupported Attributes
     742
    749743        """
    750     operation = request.attribute_groups[0]
    751     printer_uri = None
    752     user_name   = None
    753     if 'printer-uri' not in operation:
     744       
     745        operation = request.attribute_groups[0]
     746        printer_uri = None
     747        user_name   = None
     748        if 'printer-uri' not in operation:
    754749            raise ipp.errors.ClientErrorBadRequest("Missing 'printer-uri' attribute")
    755750        printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0]
     
    758753                str(operation['printer-uri']), operation['printer-uri'])
    759754
    760     if 'requesting-user-name' in operation:
    761         user_name = verify_attribute(
    762             operation['requesting-user-name'], ipp.RequestingUserName)[0]
    763    self.printer.resume_printer()
    764 
     755        if 'requesting-user-name' in operation:
     756            user_name = verify_attribute(
     757                operation['requesting-user-name'], ipp.RequestingUserName)[0]
     758
     759        self.printer.resume_printer()
    765760
    766761    @handler_for(ipp.OperationCodes.GET_PRINTER_ATTRIBUTES)
     
    845840        """3.3.3 Cancel-Job Operation
    846841
    847         This REQUIRED operation allows a client to cancel a Print Job from
    848         the time the job is created up to the time it is completed, canceled,
    849         or aborted. Since a Job might already be printing by the time a
    850         Cancel-Job is received, some media sheet pages might be printed
    851         before the job is actually terminated.
    852 
    853         The IPP object MUST accept or reject the request based on the job's
    854         current state and transition the job to the indicated new state as
    855         follows:
     842        This REQUIRED operation allows a client to cancel a Print Job
     843        from the time the job is created up to the time it is
     844        completed, canceled, or aborted. Since a Job might already be
     845        printing by the time a Cancel-Job is received, some media
     846        sheet pages might be printed before the job is actually
     847        terminated.
     848
     849        The IPP object MUST accept or reject the request based on the
     850        job's current state and transition the job to the indicated
     851        new state as follows:
    856852
    857853        Current State       New State           Response
Note: See TracChangeset for help on using the changeset viewer.