source: server/lib/gutenbach/ipp/operations/print_job.py @ 7a7a09e

no-cups
Last change on this file since 7a7a09e was 7a7a09e, checked in by Jessica B. Hamrick <jhamrick@…>, 12 years ago

Add skeleton structures for print-job

  • Property mode set to 100644
File size: 18.9 KB
Line 
1from . import verify_operations
2from . import verify_printer_uri
3from . import verify_requesting_username
4from . import make_empty_response
5from . import make_printer_attributes
6
7import logging
8logger = logging.getLogger(__name__)
9
10def verify_print_job_request(request):
11    """3.2.1.1 Print-Job Request
12
13    The following groups of attributes are supplied as part of the
14    Print-Job Request:
15
16    Group 1: Operation Attributes
17        Natural Language and Character Set:
18            The 'attributes-charset' and 'attributes-natural-language'
19            attributes as described in section 3.1.4.1. The Printer
20            object MUST copy these values to the corresponding Job
21            Description attributes described in sections 4.3.19 and
22            4.3.20.
23        Target:
24            The 'printer-uri' (uri) operation attribute which is the
25            target for this operation as described in section 3.1.5.
26        Requesting User Name:
27            The 'requesting-user-name' (name(MAX)) attribute SHOULD be
28            supplied by the client as described in section 8.3.
29        'job-name' (name(MAX)):
30            The client OPTIONALLY supplies this attribute. The Printer
31            object MUST support this attribute. It contains the client
32            supplied Job name. If this attribute is supplied by the
33            client, its value is used for the 'job-name' attribute of
34            the newly created Job object. The client MAY automatically
35            include any information that will help the end-user
36            distinguish amongst his/her jobs, such as the name of the
37            application program along with information from the
38            document, such as the document name, document subject, or
39            source file name. If this attribute is not supplied by the
40            client, the Printer generates a name to use in the
41            'job-name' attribute of the newly created Job object (see
42            Section 4.3.5).
43        'ipp-attribute-fidelity' (boolean):
44            The client OPTIONALLY supplies this attribute. The Printer
45            object MUST support this attribute. The value 'true'
46            indicates that total fidelity to client supplied Job
47            Template attributes and values is required, else the
48            Printer object MUST reject the Print-Job request. The
49            value 'false' indicates that a reasonable attempt to print
50            the Job object is acceptable and the Printer object MUST
51            accept the Print-Job request. If not supplied, the Printer
52            object assumes the value is 'false'. All Printer objects
53            MUST support both types of job processing. See section 15
54            for a full description of 'ipp-attribute-fidelity' and its
55            relationship to other attributes, especially the Printer
56            object's 'pdl-override-supported' attribute.
57        'document-name' (name(MAX)):
58            The client OPTIONALLY supplies this attribute. The Printer
59            object MUST support this attribute.  It contains the
60            client supplied document name. The document name MAY be
61            different than the Job name. Typically, the client
62            software automatically supplies the document name on
63            behalf of the end user by using a file name or an
64            application generated name. If this attribute is supplied,
65            its value can be used in a manner defined by each
66            implementation. Examples include: printed along with the
67            Job (job start sheet, page adornments, etc.), used by
68            accounting or resource tracking management tools, or even
69            stored along with the document as a document level
70            attribute. IPP/1.1 does not support the concept of
71            document level attributes.
72        'compression' (type3 keyword):
73            The client OPTIONALLY supplies this attribute. The Printer
74            object MUST support this attribute and the 'compression-
75            supported' attribute (see section 4.4.32). The client
76            supplied 'compression' operation attribute identifies the
77            compression algorithm used on the document data. The
78            following cases exist:
79            a) If the client omits this attribute, the Printer object
80               MUST assume that the data is not compressed (i.e. the
81               Printer follows the rules below as if the client
82               supplied the 'compression' attribute with a value of
83               'none').
84            b) If the client supplies this attribute, but the value is
85               not supported by the Printer object, i.e., the value is
86               not one of the values of the Printer object's
87               'compression- supported' attribute, the Printer object
88               MUST reject the request, and return the
89               'client-error-compression-not- supported' status
90               code. See section 3.1.7 for returning unsupported
91               attributes and values.
92            c) If the client supplies the attribute and the Printer
93               object supports the attribute value, the Printer object
94               uses the corresponding decompression algorithm on the
95               document data.
96            d) If the decompression algorithm fails before the Printer
97               returns an operation response, the Printer object MUST
98               reject the request and return the 'client-error-
99               compression-error' status code.
100            e) If the decompression algorithm fails after the Printer
101               returns an operation response, the Printer object MUST
102               abort the job and add the 'compression-error' value to
103               the job's 'job-state-reasons' attribute.
104            f) If the decompression algorithm succeeds, the document
105               data MUST then have the format specified by the job's
106               'document- format' attribute, if supplied (see
107               'document-format' operation attribute definition
108               below).
109        'document-format' (mimeMediaType):
110            The client OPTIONALLY supplies this attribute. The Printer
111            object MUST support this attribute. The value of this
112            attribute identifies the format of the supplied document
113            data.  The following cases exist:
114            a) If the client does not supply this attribute, the
115               Printer object assumes that the document data is in the
116               format defined by the Printer object's
117               'document-format-default' attribute. (i.e. the Printer
118               follows the rules below as if the client supplied the
119               'document-format' attribute with a value equal to the
120               printer's default value).
121            b) If the client supplies this attribute, but the value is
122               not supported by the Printer object, i.e., the value is
123               not one of the values of the Printer object's
124               'document-format- supported' attribute, the Printer
125               object MUST reject the request and return the
126               'client-error-document-format-not- supported' status
127               code.
128            c) If the client supplies this attribute and its value is
129               'application/octet-stream' (i.e. to be auto-sensed, see
130               Section 4.1.9.1), and the format is not one of the
131               document-formats that the Printer can auto-sense, and
132               this check occurs before the Printer returns an
133               operation response, then the Printer MUST reject the
134               request and return the
135               'client-error-document-format-not-supported' status
136               code.
137            d) If the client supplies this attribute, and the value is
138               supported by the Printer object, the Printer is capable
139               of interpreting the document data.
140            e) If interpreting of the document data fails before the
141               Printer returns an operation response, the Printer
142               object MUST reject the request and return the
143               'client-error- document-format-error' status code.
144            f) If interpreting of the document data fails after the
145               Printer returns an operation response, the Printer
146               object MUST abort the job and add the
147               'document-format-error' value to the job's
148               'job-state-reasons' attribute.
149        'document-natural-language' (naturalLanguage):
150            The client OPTIONALLY supplies this attribute. The Printer
151            object OPTIONALLY supports this attribute. This attribute
152            specifies the natural language of the document for those
153            document-formats that require a specification of the
154            natural language in order to image the document
155            unambiguously. There are no particular values required for
156            the Printer object to support.
157        'job-k-octets' (integer(0:MAX)):
158            The client OPTIONALLY supplies this attribute. The Printer
159            object OPTIONALLY supports this attribute and the 'job-k-
160            octets-supported' attribute (see section 4.4.33). The
161            client supplied 'job-k-octets' operation attribute
162            identifies the total size of the document(s) in K octets
163            being submitted (see section 4.3.17.1 for the complete
164            semantics). If the client supplies the attribute and the
165            Printer object supports the attribute, the value of the
166            attribute is used to populate the Job object's
167            'job-k-octets' Job Description attribute.  For this
168            attribute and the following two attributes ('job-
169            impressions', and 'job-media-sheets'), if the client
170            supplies the attribute, but the Printer object does not
171            support the attribute, the Printer object ignores the
172            client-supplied value. If the client supplies the
173            attribute and the Printer supports the attribute, and the
174            value is within the range of the corresponding Printer
175            object's 'xxx-supported' attribute, the Printer object
176            MUST use the value to populate the Job object's 'xxx'
177            attribute. If the client supplies the attribute and the
178            Printer supports the attribute, but the value is outside
179            the range of the corresponding Printer object's 'xxx-
180            supported' attribute, the Printer object MUST copy the
181            attribute and its value to the Unsupported Attributes
182            response group, reject the request, and return the
183            'client-error- attributes-or-values-not-supported' status
184            code. If the client does not supply the attribute, the
185            Printer object MAY choose to populate the corresponding
186            Job object attribute depending on whether the Printer
187            object supports the attribute and is able to calculate or
188            discern the correct value.
189        'job-impressions' (integer(0:MAX)):
190            The client OPTIONALLY supplies this attribute. The Printer
191            object OPTIONALLY supports this attribute and the 'job-
192            impressions-supported' attribute (see section 4.4.34). The
193            client supplied 'job-impressions' operation attribute
194            identifies the total size in number of impressions of the
195            document(s) being submitted (see section 4.3.17.2 for the
196            complete semantics).
197            See last paragraph under 'job-k-octets'.
198        'job-media-sheets' (integer(0:MAX)):
199            The client OPTIONALLY supplies this attribute. The Printer
200            object OPTIONALLY supports this attribute and the
201            'job-media- sheets-supported' attribute (see section
202            4.4.35). The client supplied 'job-media-sheets' operation
203            attribute identifies the total number of media sheets to
204            be produced for this job (see section 4.3.17.3 for the
205            complete semantics).
206            See last paragraph under 'job-k-octets'.
207
208    Group 2: Job Template Attributes
209        The client OPTIONALLY supplies a set of Job Template
210        attributes as defined in section 4.2. If the client is not
211        supplying any Job Template attributes in the request, the
212        client SHOULD omit Group 2 rather than sending an empty
213        group. However, a Printer object MUST be able to accept an
214        empty group.
215
216    Group 3: Document Content
217        The client MUST supply the document data to be processed.  In
218        addition to the MANDATORY parameters required for every
219        operation request, the simplest Print-Job Request consists of
220        just the 'attributes-charset' and
221        'attributes-natural-language' operation attributes; the
222        'printer-uri' target operation attribute; the Document Content
223        and nothing else. In this simple case, the Printer object:
224        - creates a new Job object (the Job object contains a single
225          document),
226        - stores a generated Job name in the 'job-name' attribute in
227          the natural language and charset requested (see Section
228          3.1.4.1) (if those are supported, otherwise using the
229          Printer object's default natural language and charset), and
230        - at job processing time, uses its corresponding default value
231          attributes for the supported Job Template attributes that
232          were not supplied by the client as IPP attribute or embedded
233          instructions in the document data.
234
235    """
236   
237    pass
238
239def make_print_job_response(attrs, request):
240    """3.2.1.2 Print-Job Response
241
242    The Printer object MUST return to the client the following sets of
243    attributes as part of the Print-Job Response:
244
245    Group 1: Operation Attributes
246        Status Message:
247            In addition to the REQUIRED status code returned in every
248            response, the response OPTIONALLY includes a
249            'status-message' (text(255)) and/or a
250            'detailed-status-message' (text(MAX)) operation attribute
251            as described in sections 13 and 3.1.6. If the client
252            supplies unsupported or conflicting Job Template
253            attributes or values, the Printer object MUST reject or
254            accept the Print-Job request depending on the whether the
255            client supplied a 'true' or 'false' value for the
256            'ipp-attribute- fidelity' operation attribute. See the
257            Implementer's Guide [IPP-IIG] for a complete description
258            of the suggested steps for processing a create request.
259        Natural Language and Character Set:
260            The 'attributes-charset' and 'attributes-natural-language'
261            attributes as described in section 3.1.4.2.
262
263    Group 2: Unsupported Attributes
264        See section 3.1.7 for details on returning Unsupported
265        Attributes.  The value of the 'ipp-attribute-fidelity'
266        supplied by the client does not affect what attributes the
267        Printer object returns in this group. The value of
268        'ipp-attribute-fidelity' only affects whether the Print-Job
269        operation is accepted or rejected. If the job is accepted, the
270        client may query the job using the Get-Job- Attributes
271        operation requesting the unsupported attributes that were
272        returned in the create response to see which attributes were
273        ignored (not stored on the Job object) and which attributes
274        were stored with other (substituted) values.
275
276    Group 3: Job Object Attributes
277        'job-uri' (uri):
278            The Printer object MUST return the Job object's URI by
279            returning the contents of the REQUIRED 'job-uri' Job
280            object attribute. The client uses the Job object's URI
281            when directing operations at the Job object. The Printer
282            object always uses its configured security policy when
283            creating the new URI.  However, if the Printer object
284            supports more than one URI, the Printer object also uses
285            information about which URI was used in the Print-Job
286            Request to generated the new URI so that the new URI
287            references the correct access channel. In other words, if
288            the Print-Job Request comes in over a secure channel, the
289            Printer object MUST generate a Job URI that uses the
290            secure channel as well.
291        'job-id' (integer(1:MAX)):
292            The Printer object MUST return the Job object's Job ID by
293            returning the REQUIRED 'job-id' Job object attribute. The
294            client uses this 'job-id' attribute in conjunction with
295            the 'printer-uri' attribute used in the Print-Job Request
296            when directing Job operations at the Printer object.
297        'job-state' (type1 enum):
298            The Printer object MUST return the Job object's REQUIRED
299            'job- state' attribute. The value of this attribute (along
300            with the value of the next attribute: 'job-state-reasons')
301            is taken from a 'snapshot' of the new Job object at some
302            meaningful point in time (implementation defined) between
303            when the Printer object receives the Print-Job Request and
304            when the Printer object returns the response.
305        'job-state-reasons' (1setOf type2 keyword):
306            The Printer object MUST return the Job object's REQUIRED
307            'job- state-reasons' attribute.
308        'job-state-message' (text(MAX)):
309            The Printer object OPTIONALLY returns the Job object's
310            OPTIONAL 'job-state-message' attribute. If the Printer
311            object supports this attribute then it MUST be returned in
312            the response. If this attribute is not returned in the
313            response, the client can assume that the
314            'job-state-message' attribute is not supported and will
315            not be returned in a subsequent Job object query.
316        'number-of-intervening-jobs' (integer(0:MAX)):
317            The Printer object OPTIONALLY returns the Job object's
318            OPTIONAL 'number-of-intervening-jobs' attribute. If the
319            Printer object supports this attribute then it MUST be
320            returned in the response. If this attribute is not
321            returned in the response, the client can assume that the
322            'number-of-intervening-jobs' attribute is not supported
323            and will not be returned in a subsequent Job object query.
324
325    Note: Since any printer state information which affects a job's
326    state is reflected in the 'job-state' and 'job-state-reasons'
327    attributes, it is sufficient to return only these attributes and
328    no specific printer status attributes.
329
330    Note: In addition to the MANDATORY parameters required for every
331    operation response, the simplest response consists of the just the
332    'attributes-charset' and 'attributes-natural-language' operation
333    attributes and the 'job-uri', 'job-id', and 'job-state' Job Object
334    Attributes. In this simplest case, the status code is 'successful-
335    ok' and there is no 'status-message' or 'detailed-status-message'
336    operation attribute.
337
338    """
339
340    pass
Note: See TracBrowser for help on using the repository browser.