Changes in / [b77e57e:7e29e6a]


Ignore:
File:
1 edited

Legend:

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

    rb77e57e r7daf25f  
    171171
    172172        operation = request.attribute_groups[0]
    173         document = request.data       
    174         user_name = None
    175         job_name = None
    176         job_k_octets = None
    177         document_format = None
    178         document_natural_language = None
    179         compression = None
    180         last_document = None
     173
    181174        # requested printer uri
    182175        if 'printer-uri' not in operation:
     
    207200
    208201        # get attributes from the printer and add to response
     202        job_id = self.printer.create_job(
     203            requesting_user_name=user_name,
     204            job_name=job_name,
     205            job_k_octets=job_k_octets)
     206        attrs = self.printer.get_job_attributes(job_id)
     207        response.attribute_groups.append(ipp.AttributeGroup(
     208            ipp.AttributeTags.JOB, attrs))
     209            #raise ipp.errors.ServerErrorOperationNotSupported
     210        # Get nescessary information for calling send_document
     211        # Any field being set to None here just means that we either aren't using or haven't implemented parsing it
     212        document = request.data       
     213        #XXX
     214        document_format = None
     215        document_natural_language = None
     216        compression = None
     217        last_document = None
     218
     219
     220       
     221        # Actually put the document in the job
    209222        try:
    210             job_id = self.printer.print_job(document,
    211                     document_name               = document_name,
    212                     document_format             = document_format,
    213                     document_natural_language   = document_natural_language,
    214                     requesting_user_name        = user_name,
    215                     compression                 = compression,
    216                     job_name                    = job_name,
    217                     job_k_octets                = job_k_octets)
     223            self.printer.send_document(job_id,document,
     224                    document_name = document_name,
     225                    document_format = document_format,
     226                    document_natural_language = document_natural_language,
     227                    requesting_user_name = requesting_user_name,
     228                    compression = compression,
     229                    last_document = last_document)
    218230        except InvalidJobException:
    219231            raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id)
    220232
     233       
     234        # Print the job, now that we've filled it in as appropriate
     235       
     236       #XXX
     237       #Should we be handling a possible exception here?
     238        self.print_job(document,
     239                document_name = document_name,
     240                document_format = document_format,
     241                document_natural_language = document_natural_language,
     242                requesting_user_name = requesting_user_name,
     243                compression=compression,
     244                job_name = job_name,
     245                job_k_octets = job_k_octets)
    221246
    222247        attrs = self.printer.get_job_attributes(job_id)
    223      
    224         #Actually append the attributes we pulled
    225         response.attribute_groups.append(ipp.AttributeGroup(
    226             ipp.AttributeTags.JOB, attrs))
    227 
    228        
     248        response.attribute_groups.append(ipp.AttributeGroup(ipp.AttributeTags.JOB, attrs))
     249
    229250    @handler_for(ipp.OperationCodes.VALIDATE_JOB)
    230251    def validate_job(self, request, response):
    231         """3.2.3 Validate-Job Operation
    232 
    233         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.
    256         """
    257         operation = request.attribute_groups[0]
    258         user_name = None
    259         job_name = None
    260         job_k_octets = None
    261         # requested printer uri
    262         if 'printer-uri' not in operation:
    263             raise ipp.errors.ClientErrorBadRequest("Missing 'printer-uri' attribute")
    264         printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0]
    265         if printer_uri not in self.printer.uris:
    266             raise ipp.errors.ClientErrorAttributes(
    267                 str(operation['printer-uri']), operation['printer-uri'])
    268 
    269         if 'requesting-user-name' in operation:
    270             user_name = verify_attribute(
    271                 operation['requesting-user-name'], ipp.RequestingUserName)[0]
    272 
    273         if 'job-name' in operation:
    274             job_name = verify_attribute(
    275                 operation['job-name'], ipp.JobName)[0]
    276 
    277         if 'job-k-octets' in operation:
    278             job_k_octets = verify_attribute(
    279                 operation['job-k-octets'], ipp.JobKOctets)[0]
    280        
    281         self.printer.verify_job(requesting_user_name=user_name,
    282             job_name=job_name,
    283             job_k_octets = job_k_octets)
    284 
    285         #raise ipp.errors.ServerErrorOperationNotSupported
     252
     253        raise ipp.errors.ServerErrorOperationNotSupported
    286254
    287255    @handler_for(ipp.OperationCodes.GET_JOBS)
     
    411379        It is up to the IPP object to interpret the URI and subsequently
    412380        '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
     381        raise ipp.errors.ServerErrorOperationNotSupported
    473382
    474383    @handler_for(ipp.OperationCodes.CREATE_JOB)
Note: See TracChangeset for help on using the changeset viewer.