Changeset 34a4e5d for server/lib/gutenbach/server/requests.py
- Timestamp:
- Jan 11, 2012, 4:51:13 PM (12 years ago)
- Branches:
- no-cups
- Children:
- 4126d3d
- Parents:
- d21198f
- git-author:
- Jessica B. Hamrick <jhamrick@…> (01/11/12 16:51:13)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (01/11/12 16:51:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/server/requests.py
reee389a r34a4e5d 1 from . import InvalidJobException, InvalidPrinterStateException, InvalidJobStateException 1 2 import gutenbach.ipp as ipp 2 3 import logging … … 446 447 @handler_for(ipp.OperationCodes.CANCEL_JOB) 447 448 def cancel_job(self, request, response): 448 raise ipp.errors.ServerErrorOperationNotSupported 449 """3.3.3 Cancel-Job Operation 450 451 This REQUIRED operation allows a client to cancel a Print Job from 452 the time the job is created up to the time it is completed, canceled, 453 or aborted. Since a Job might already be printing by the time a 454 Cancel-Job is received, some media sheet pages might be printed 455 before the job is actually terminated. 456 457 The IPP object MUST accept or reject the request based on the job's 458 current state and transition the job to the indicated new state as 459 follows: 460 461 Current State New State Response 462 ----------------------------------------------------------------- 463 pending canceled successful-ok 464 pending-held canceled successful-ok 465 processing canceled successful-ok 466 processing processing successful-ok See Rule 1 467 processing processing client-error-not-possible See Rule 2 468 processing-stopped canceled successful-ok 469 processing-stopped processing-stopped successful-ok See Rule 1 470 processing-stopped processing-stopped client-error-not-possible See Rule 2 471 completed completed client-error-not-possible 472 canceled canceled client-error-not-possible 473 aborted aborted client-error-not-possible 474 475 Rule 1: If the implementation requires some measurable time to 476 cancel the job in the 'processing' or 'processing-stopped' job 477 states, the IPP object MUST add the 'processing-to-stop-point' 478 value to the job's 'job-state-reasons' attribute and then 479 transition the job to the 'canceled' state when the processing 480 ceases (see section 4.3.8). 481 482 Rule 2: If the Job object already has the 483 'processing-to-stop-point' value in its 'job-state-reasons' 484 attribute, then the Printer object MUST reject a Cancel-Job 485 operation. 486 487 Access Rights: The authenticated user (see section 8.3) 488 performing this operation must either be the job owner or an 489 operator or administrator of the Printer object (see Sections 490 1 and 8.5). Otherwise, the IPP object MUST reject the 491 operation and return: 'client-error-forbidden', 492 'client-error-not-authenticated', or 493 'client-error-not-authorized' as appropriate. 494 495 Request 496 ------- 497 498 Group 1: Operation Attributes 499 REQUIRED 'attributes-charset' 500 REQUIRED 'attributes-natural-language' 501 REQUIRED 'job-id' (integer(1:MAX)) and 'printer-uri' (uri) 502 -or- 'job-uri' (uri) 503 OPTIONAL 'requesting-user-name' (name(MAX)) 504 OPTIONAL 'message' (text(127)) 505 506 Response 507 -------- 508 509 Group 1: Operation Attributes 510 OPTIONAL 'status-message' (text(255)) 511 OPTIONAL 'detailed-status-message' (text(MAX)) 512 REQUIRED 'attributes-charset' 513 REQUIRED 'attributes-natural-language' 514 Group 2: Unsupported Attributes 515 516 """ 517 518 operation = request.attribute_groups[0] 519 520 job_id = None 521 printer_uri = None 522 requesting_user_name = None 523 message = None 524 525 # required attributes 526 if 'job-id' in operation and 'printer-uri' in operation: 527 job_id = verify_attribute(operation['job-id'], ipp.JobId)[0] 528 printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0] 529 if printer_uri not in self.printer.uris: 530 raise ipp.errors.ClientErrorAttributes( 531 str(operation['printer-uri']), operation['printer-uri']) 532 533 elif 'job-uri' in operation: 534 job_uri = verify_attribute(operation['job-uri'], ipp.JobUri)[0] 535 job_id = int(job_uri.split("/")[-1]) 536 537 if 'requesting-user-name' in operation: 538 user_name = verify_attribute( 539 operation['requesting-user-name'], ipp.RequestingUserName)[0] 540 541 try: 542 job = self.printer.get_job(job_id) 543 job.cancel() 544 except InvalidJobException: 545 raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id) 449 546 450 547 @handler_for(ipp.OperationCodes.SEND_DOCUMENT) … … 504 601 REQUIRED 'attributes-charset' 505 602 REQUIRED 'attributes-natural-language' 506 REQUIRED 'job-id' ( uri)507 OPTIONAL 'printer-uri' (uri)603 REQUIRED 'job-id' (integer(1:MAX)) and 'printer-uri' (uri) 604 -or- 'job-uri' (uri) 508 605 OPTIONAL 'requesting-user-name' (name(MAX)) 509 606 OPTIONAL 'document-name' (name(MAX)) … … 583 680 ipp.DocumentNaturalLanguage)[0] 584 681 585 job = self.printer.get_job(job_id) 586 job.send_document( 587 request.data, 588 requesting_user_name=user_name, 589 document_name=document_name, 590 compression=compression, 591 document_format=document_format, 592 document_natural_language=document_natural_language, 593 last_document=last_document) 682 try: 683 job = self.printer.get_job(job_id) 684 job.send_document( 685 request.data, 686 requesting_user_name=user_name, 687 document_name=document_name, 688 compression=compression, 689 document_format=document_format, 690 document_natural_language=document_natural_language, 691 last_document=last_document) 692 attrs = job.get_job_attributes() 693 except InvalidJobException: 694 raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id) 594 695 595 696 response.attribute_groups.append(ipp.AttributeGroup( 596 ipp.AttributeTags.JOB, job.get_job_attributes()))697 ipp.AttributeTags.JOB, attrs)) 597 698 598 699 @handler_for(ipp.OperationCodes.SEND_URI) … … 647 748 REQUIRED 'attributes-charset' 648 749 REQUIRED 'attributes-natural-language' 649 REQUIRED 'job-id' ( uri)650 OPTIONAL 'printer-uri' (uri)750 REQUIRED 'job-id' (integer(1:MAX)) and 'printer-uri' (uri) 751 -or- 'job-uri' (uri) 651 752 OPTIONAL 'requesting-user-name' (name(MAX)) 652 753 OPTIONAL 'requested-attributes' (1setOf keyword) … … 694 795 695 796 # get the job attributes and add them to the response 696 job = self.printer.get_job(job_id) 697 attrs = job.get_job_attributes(requested_attributes=requested_attributes) 797 try: 798 job = self.printer.get_job(job_id) 799 attrs = job.get_job_attributes(requested_attributes=requested_attributes) 800 except InvalidJobException: 801 raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id) 802 698 803 response.attribute_groups.append(ipp.AttributeGroup( 699 804 ipp.AttributeTags.JOB, attrs))
Note: See TracChangeset
for help on using the changeset viewer.