Changeset 21b140d
- Timestamp:
- Jan 21, 2012, 3:01:47 PM (12 years ago)
- Branches:
- no-cups
- Children:
- 7c8a2f8
- Parents:
- c1cebbc
- git-author:
- Kyle Brogle <broglek@…> (01/21/12 15:01:47)
- git-committer:
- Kyle Brogle <broglek@…> (01/21/12 15:01:47)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/gutenbach/server/requests.py
rd994f15 r21b140d 699 699 @handler_for(ipp.OperationCodes.SEND_URI) 700 700 def send_uri(self, request, response): 701 raise ipp.errors.ServerErrorOperationNotSupported 701 """This OPTIONAL operation is identical to the Send-Document operation 702 (see section 3.3.1) except that a client MUST supply a URI reference 703 ("document-uri" operation attribute) rather than the document data 704 itself. If a Printer object supports this operation, clients can use 705 both Send-URI or Send-Document operations to add new documents to an 706 existing multi-document Job object. However, if a client needs to 707 indicate that the previous Send-URI or Send-Document was the last 708 document, the client MUST use the Send-Document operation with no 709 document data and the "last-document" flag set to 'true' (rather than 710 using a Send-URI operation with no "document-uri" operation 711 attribute). 712 713 If a Printer object supports this operation, it MUST also support the 714 Print-URI operation (see section 3.2.2). 715 716 The Printer object MUST validate the syntax and URI scheme of the 717 supplied URI before returning a response, just as in the Print-URI 718 operation. The IPP Printer MAY validate the accessibility of the 719 document as part of the operation or subsequently (see section 720 3.2.2). 721 722 Request 723 ------- 724 725 Group 1: Operation Attributes 726 REQUIRED 'attributes-charset' 727 REQUIRED 'attributes-natural-language' 728 REQUIRED 'job-id' (integer(1:MAX)) and 'printer-uri' (uri) 729 REQUIRED 'document-uri' (uri) 730 -or- 'job-uri' (uri) 731 OPTIONAL 'requesting-user-name' (name(MAX)) 732 OPTIONAL 'document-name' (name(MAX)) 733 OPTIONAL 'compression' (type3 keyword) 734 OPTIONAL 'document-format' (mimeMediaType) 735 OPTIONAL 'document-natural-language' (naturalLanguage) 736 Group 2: Document Content 737 738 Response 739 -------- 740 741 Group 1: Operation Attributes 742 OPTIONAL 'status-message' (text(255)) 743 OPTIONAL 'detailed-status-message' (text(MAX)) 744 REQUIRED 'attributes-charset' 745 REQUIRED 'attributes-natural-language' 746 Group 2: Unsupported Attributes 747 Group 3: Job Object Attributes 748 REQUIRED 'job-uri' (uri) 749 REQUIRED 'job-id' (integer(1:MAX)) 750 REQUIRED 'job-state' (type1 enum) 751 REQUIRED 'job-state-reasons' (1setOf type2 keyword) 752 OPTIONAL 'job-state-message' (text(MAX)) 753 OPTIONAL 'number-of-intervening-jobs' (integer(0:MAX))""" 754 755 operation = request.attribute_groups[0] 756 757 job_id = None 758 printer_uri = None 759 requesting_user_name = None 760 document_name = None 761 compression = None 762 document_format = None 763 document_natural_language = None 764 last_document = None 765 766 # required attributes 767 if 'job-id' not in operation: 768 raise ipp.errors.ClientErrorBadRequest("Missing 'job-id' attribute") 769 job_id = verify_attribute(operation['job-id'], ipp.JobId)[0] 770 771 if 'last-document' not in operation: 772 raise ipp.errors.ClientErrorBadRequest("Missing 'last-document' attribute") 773 last_document = verify_attribute(operation['last-document'], ipp.LastDocument)[0] 774 775 if 'document-uri' not in operation: 776 raise ipp.errors.ClientErrorBadRequest("Missing 'document-uri' attribute") 777 document_uri = verify_attribute(operation['document-uri'], ipp.DocumentUri)[0] 778 if not last_document: 779 raise ipp.errors.ServerErrorMultipleJobsNotSupported 780 781 # optional attributes 782 if 'printer-uri' in operation: 783 printer_uri = verify_attribute(operation['printer-uri'], ipp.PrinterUri)[0] 784 if printer_uri not in self.printer.uris: 785 raise ipp.errors.ClientErrorAttributes( 786 str(operation['printer-uri']), operation['printer-uri']) 787 788 if 'requesting-user-name' in operation: 789 user_name = verify_attribute( 790 operation['requesting-user-name'], ipp.RequestingUserName)[0] 791 792 if 'document-name' in operation: 793 document_name = verify_attribute( 794 operation['document-name'], ipp.DocumentName)[0] 795 796 if 'compression' in operation: 797 compression = verify_attribute( 798 operation['compression'], ipp.Compression)[0] 799 800 if 'document-format' in operation: 801 document_format = verify_attribute( 802 operation['document-format'], ipp.DocumentFormat)[0] 803 804 if 'document-natural-language' in operation: 805 document_natural_language = verify_attribute( 806 operation['document_natural_language'], 807 ipp.DocumentNaturalLanguage)[0] 808 809 try: 810 self.printer.send_uri( 811 job_id, 812 document_uri=document_uri, 813 document_name=document_name, 814 document_format=document_format, 815 document_natural_language=document_natural_language, 816 requesting_user_name=user_name, 817 compression=compression, 818 last_document=last_document) 819 attrs = self.printer.get_job_attributes(job_id) 820 except InvalidJobException: 821 raise ipp.errors.ClientErrorNotFound("bad job: %d" % job_id) 822 823 response.attribute_groups.append(ipp.AttributeGroup( 824 ipp.AttributeTags.JOB, attrs)) 702 825 703 826 @handler_for(ipp.OperationCodes.GET_JOB_ATTRIBUTES)
Note: See TracChangeset
for help on using the changeset viewer.