source: server/lib/gutenbach/ipp/operations.py @ 59a1d4a

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

A litte bit of documentation

  • Property mode set to 100644
File size: 30.6 KB
Line 
1from .value import Value
2from .attribute import Attribute
3from .attributegroup import AttributeGroup
4from .request import Request
5import constants as consts
6import exceptions as err
7import logging
8
9logger = logging.getLogger(__name__)
10
11def verify_operations(request):
12    """Pretty much all requests have the first attribute group for
13    operation attributes, and these all have 'attributes-charset' and
14    'attributes-natural-language' as the first two attributes.  This
15    method just generically verifies that these attributes are there.
16
17    """
18
19    # XXX: check version
20    if False:
21        raise err.VersionNotSupported(str(request.version))
22
23    # XXX: check operation id
24    if False:
25        raise err.OperationNotSupported(str(request.operation_id))
26
27    # check operation attributes tag
28    op_attrs = request.attribute_groups[0]
29    if op_attrs.tag != consts.AttributeTags.OPERATION:
30        raise err.BadRequest(
31            "Attribute group does not have OPERATION tag: 0x%x" % op_attrs.tag)
32
33    # XXX: if these aren't valid, then you HAVE to return something
34    # special.  See RFC 2911 3.1.6.1
35    # # check compression
36    # if False:
37    #     raise err.CompressionNotSupported
38
39    # # check document format
40    # if False:
41    #     raise err.DocumentFormatNotSupported
42
43    # # check document uri
44    # if False:
45    #     raise err.UriSchemeNotSupported
46
47    # check charset
48    charset_attr = op_attrs.attributes[0]
49    if charset_attr.name != 'attributes-charset':
50        raise err.BadRequest(
51            "Attribute is not attributes-charset: %s" % charset_attr.name)
52    if len(charset_attr.values) != 1:
53        raise err.BadRequest(
54            "Too many values for attributes-charset: %d" % len(charset_attr.values))
55    # check charset value
56    charset_value = charset_attr.values[0]
57    if charset_value.tag != consts.operations_attribute_value_tags['attributes-charset']:
58        raise err.BadRequest(
59            "Wrong tag for charset value: 0x%x" % charset_value.tag)
60    if charset_value.value != 'utf-8':
61        raise err.CharsetNotSupported(str(charset_value.value))
62
63    # check for attributes-natural-language
64    natlang_attr = op_attrs.attributes[1]
65    if natlang_attr.name != 'attributes-natural-language':
66        raise err.BadRequest(
67            "Attribute is not attributes-natural-language: %s" % natlang_attr.name)
68    if len(charset_attr.values) != 1:
69        raise err.BadRequest(
70            "Too many values for attributes-natural-language: %s" % len(natlang_attr.values))
71    # check natural language value
72    natlang_value = natlang_attr.values[0]
73    if natlang_value.tag != consts.operations_attribute_value_tags['attributes-natural-language']:
74        raise err.BadRequest(
75            "Natural language value does not have NATURAL_LANGUAGE tag: 0x%x" % natlang_value.tag)
76    if natlang_value.value != 'en-us':
77        raise err.Attributes(
78            "Invalid natural language value: %s" % natlang_value.value, [natlang_attr])
79
80    return dict([(attr.name, attr.values) for attr in op_attrs.attributes])
81
82def verify_printer_uri(values):
83    if len(values) != 1:
84        raise err.BadRequest(
85            "Requesting printer uri attribute has too many values: %d" % len(values))
86    uri_value = values[0]
87    if uri_value.tag != consts.operations_attribute_value_tags['printer-uri']:
88        raise err.BadRequest(
89            "Bad value tag (expected URI): 0x%x" % uri_value_tag)
90   
91    # actually get the printer name
92    # XXX: hack -- CUPS will strip the port from the request, so
93    # we can't do an exact comparison (also the hostname might be
94    # different, depending on the CNAME or whether it's localhost)
95    uri = uri_value.value.split("/")[-1]
96    return uri
97
98def verify_requesting_username(values):
99    if len(values) != 1:
100        raise err.BadRequest(
101            "Requesting user name attribute has too many values: %d" % len(values))
102    requser_value = values[0]
103    if requser_value.tag != consts.operations_attribute_value_tags['requesting-user-name']:
104        raise err.BadRequest(
105            "Bad value tag (expected NAME_WITHOUT_LANGUAGE): 0x%x" % requser_value.tag)
106   
107    return requser_value.value
108
109def make_empty_response(request):
110    # Operation attributes -- typically the same for any request
111    attributes = [
112        Attribute(
113            'attributes-charset',
114            [Value(consts.operations_attribute_value_tags['attributes-charset'], 'utf-8')]),
115        Attribute(
116            'attributes-natural-language',
117            [Value(consts.operations_attribute_value_tags['attributes-natural-language'],
118                   'en-us')])
119        ]
120    # Put the operation attributes in a group
121    attribute_group = AttributeGroup(
122        consts.AttributeTags.OPERATION,
123        attributes)
124
125    # Set up the default response -- handlers will override these
126    # values if they need to
127    response_kwargs = {}
128    response_kwargs['version']          = request.version
129    response_kwargs['operation_id']     = consts.StatusCodes.OK
130    response_kwargs['request_id']       = request.request_id
131    response_kwargs['attribute_groups'] = [attribute_group]
132    response = Request(**response_kwargs)
133
134    return response
135
136def make_job_attributes(attrs, request, response):
137    ipp_attrs = []
138    for attr, vals in attrs:
139        ipp_vals = [Value(
140            tag=consts.job_attribute_value_tags[attr],
141            value=val) for val in vals]
142        ipp_attrs.append(Attribute(name=attr, values=ipp_vals))
143    response.attribute_groups.append(AttributeGroup(
144        consts.AttributeTags.JOB, ipp_attrs))
145
146def make_printer_attributes(attrs, request, response):
147    ipp_attrs = []
148    for attr, vals in attrs:
149        ipp_vals = [Value(
150            tag=consts.printer_attribute_value_tags[attr],
151            value=val) for val in vals]
152        ipp_attrs.append(Attribute(name=attr, values=ipp_vals))
153    response.attribute_groups.append(AttributeGroup(
154        consts.AttributeTags.PRINTER, ipp_attrs))
155
156#### GET-JOBS
157
158def verify_get_jobs_request(request):
159    """RFC 2911 3.2.6.1 Get-Jobs Request
160
161    The client submits the Get-Jobs request to a Printer object.
162   
163    The following groups of attributes are part of the Get-Jobs
164    Request:
165
166    Group 1: Operation Attributes
167        Natural Language and Character Set:
168            The 'attributes-charset' and
169            'attributes-natural-language' attributes as described
170            in section 3.1.4.1.
171        Target:
172            The 'printer-uri' (uri) operation attribute which is
173            the target for this operation as described in section
174            3.1.5.
175        Requesting User Name:
176            The 'requesting-user-name' (name(MAX)) attribute
177            SHOULD be supplied by the client as described in
178            section 8.3.
179        'limit' (integer(1:MAX)):
180            The client OPTIONALLY supplies this attribute. The
181            Printer object MUST support this attribute. It is an
182            integer value that determines the maximum number of
183            jobs that a client will receive from the Printer even
184            if 'which-jobs' or 'my-jobs' constrain which jobs are
185            returned. The limit is a 'stateless limit' in that if
186            the value supplied by the client is 'N', then only the
187            first 'N' jobs are returned in the Get-Jobs Response.
188            There is no mechanism to allow for the next 'M' jobs
189            after the first 'N' jobs. If the client does not
190            supply this attribute, the Printer object responds
191            with all applicable jobs.
192        'requested-attributes' (1setOf type2 keyword):
193            The client OPTIONALLY supplies this attribute. The
194            Printer object MUST support this attribute. It is a
195            set of Job attribute names and/or attribute groups
196            names in whose values the requester is
197            interested. This set of attributes is returned for
198            each Job object that is returned. The allowed
199            attribute group names are the same as those defined in
200            the Get-Job-Attributes operation in section 3.3.4. If
201            the client does not supply this attribute, the Printer
202            MUST respond as if the client had supplied this
203            attribute with two values: 'job-uri' and 'job-id'.
204        'which-jobs' (type2 keyword):
205            The client OPTIONALLY supplies this attribute. The
206            Printer object MUST support this attribute. It
207            indicates which Job objects MUST be returned by the
208            Printer object. The values for this attribute are:
209             - 'completed': This includes any Job object whose
210               state is 'completed', 'canceled', or 'aborted'.
211             - 'not-completed': This includes any Job object whose
212               state is 'pending', 'processing',
213               'processing-stopped', or 'pending-held'.
214            A Printer object MUST support both values. However, if
215            the implementation does not keep jobs in the
216            'completed', 'canceled', and 'aborted' states, then it
217            returns no jobs when the 'completed' value is
218            supplied.  If a client supplies some other value, the
219            Printer object MUST copy the attribute and the
220            unsupported value to the Unsupported Attributes
221            response group, reject the request, and return the
222            'client-error-attributes-or-values-not-supported'
223            status code.  If the client does not supply this
224            attribute, the Printer object MUST respond as if the
225            client had supplied the attribute with a value of
226            'not-completed'.
227        'my-jobs' (boolean):
228            The client OPTIONALLY supplies this attribute. The
229            Printer object MUST support this attribute. It
230            indicates whether jobs from all users or just the jobs
231            submitted by the requesting user of this request MUST
232            be considered as candidate jobs to be returned by the
233            Printer object. If the client does not supply this
234            attribute, the Printer object MUST respond as if the
235            client had supplied the attribute with a value of
236            'false', i.e., jobs from all users. The means for
237            authenticating the requesting user and matching the
238            jobs is described in section 8.
239
240    """
241
242    out = {}
243
244    # generic operations verification
245    attrs = verify_operations(request)
246
247    # requested printer uri
248    if 'printer-uri' not in attrs:
249        raise err.BadRequest("Missing 'printer-uri' attribute")
250    out['printer-uri'] = verify_printer_uri(attrs['printer-uri'])
251   
252    # requesting username
253    if 'requesting-user-name' not in attrs:
254        logger.warning("Missing 'requesting-user-name' attribute")
255    else:
256        out['requesting-user-name'] = verify_requesting_username(attrs['requesting-user-name'])
257
258    if 'limit' in attrs:
259        out['limit'] = None # XXX
260
261    if 'requested-attributes' in attrs:
262        out['requested-attributes'] = None # XXX
263
264    if 'which-jobs' in attrs:
265        out['which-jobs'] = None # XXX
266
267    if 'my-jobs' in attrs:
268        out['my-jobs'] = None # XXX
269
270    return out
271
272def make_get_jobs_response(jobs, request):
273    """RFC 2911: 3.2.6.2 Get-Jobs Response
274       
275    The Printer object returns all of the Job objects up to the number
276    specified by the 'limit' attribute that match the criteria as
277    defined by the attribute values supplied by the client in the
278    request. It is possible that no Job objects are returned since
279    there may literally be no Job objects at the Printer, or there may
280    be no Job objects that match the criteria supplied by the
281    client. If the client requests any Job attributes at all, there is
282    a set of Job Object Attributes returned for each Job object.
283
284    It is not an error for the Printer to return 0 jobs. If the
285    response returns 0 jobs because there are no jobs matching the
286    criteria, and the request would have returned 1 or more jobs
287    with a status code of 'successful-ok' if there had been jobs
288    matching the criteria, then the status code for 0 jobs MUST be
289    'successful-ok'.
290
291    Group 1: Operation Attributes
292        Status Message:
293            In addition to the REQUIRED status code returned in
294            every response, the response OPTIONALLY includes a
295            'status-message' (text(255)) and/or a
296            'detailed-status-message' (text(MAX)) operation
297            attribute as described in sections 13 and 3.1.6.
298        Natural Language and Character Set:
299            The 'attributes-charset' and
300            'attributes-natural-language' attributes as described
301            in section 3.1.4.2.
302
303    Group 2: Unsupported Attributes
304        See section 3.1.7 for details on returning Unsupported
305        Attributes.  The response NEED NOT contain the
306        'requested-attributes' operation attribute with any
307        supplied values (attribute keywords) that were requested
308        by the client but are not supported by the IPP object.  If
309        the Printer object does return unsupported attributes
310        referenced in the 'requested-attributes' operation
311        attribute and that attribute included group names, such as
312        'all', the unsupported attributes MUST NOT include
313        attributes described in the standard but not supported by
314        the implementation.
315
316    Groups 3 to N: Job Object Attributes
317        The Printer object responds with one set of Job Object
318        Attributes for each returned Job object. The Printer
319        object ignores (does not respond with) any requested
320        attribute or value which is not supported or which is
321        restricted by the security policy in force, including
322        whether the requesting user is the user that submitted the
323        job (job originating user) or not (see section
324        8). However, the Printer object MUST respond with the
325        'unknown' value for any supported attribute (including all
326        REQUIRED attributes) for which the Printer object does not
327        know the value, unless it would violate the security
328        policy. See the description of the 'out-of- band' values
329        in the beginning of Section 4.1.
330
331        Jobs are returned in the following order:
332        - If the client requests all 'completed' Jobs (Jobs in the
333          'completed', 'aborted', or 'canceled' states), then the
334          Jobs are returned newest to oldest (with respect to
335          actual completion time)
336        - If the client requests all 'not-completed' Jobs (Jobs in
337          the 'pending', 'processing', 'pending-held', and
338          'processing- stopped' states), then Jobs are returned in
339          relative chronological order of expected time to
340          complete (based on whatever scheduling algorithm is
341          configured for the Printer object).
342
343    """
344
345    response = make_empty_response(request)
346    # XXX: we need to honor the things that the request actually asks for
347    for job in jobs:
348        make_job_attributes(job, request, response)
349    return response
350
351## GET-PRINTER-ATTRIBUTES
352
353def verify_get_printer_attributes_request(request):
354    """RFC 2911: 3.2.5.1 Get-Printer-Attributes Request
355
356    The following sets of attributes are part of the Get-Printer-
357    Attributes Request:
358
359    Group 1: Operation Attributes
360        Natural Language and Character Set:
361            The 'attributes-charset' and 'attributes-natural-language'
362            attributes as described in section 3.1.4.1.
363        Target:
364            The 'printer-uri' (uri) operation attribute which is the
365            target for this operation as described in section 3.1.5.
366        Requesting User Name:
367            The 'requesting-user-name' (name(MAX)) attribute SHOULD be
368            supplied by the client as described in section 8.3.
369        'requested-attributes' (1setOf keyword):
370            The client OPTIONALLY supplies a set of attribute names
371            and/or attribute group names in whose values the requester
372            is interested. The Printer object MUST support this
373            attribute.  If the client omits this attribute, the
374            Printer MUST respond as if this attribute had been
375            supplied with a value of 'all'.
376        'document-format' (mimeMediaType):
377            The client OPTIONALLY supplies this attribute. The Printer
378            object MUST support this attribute. This attribute is
379            useful for a Printer object to determine the set of
380            supported attribute values that relate to the requested
381            document format.  The Printer object MUST return the
382            attributes and values that it uses to validate a job on a
383            create or Validate-Job operation in which this document
384            format is supplied. The Printer object SHOULD return only
385            (1) those attributes that are supported for the specified
386            format and (2) the attribute values that are supported for
387            the specified document format. By specifying the document
388            format, the client can get the Printer object to eliminate
389            the attributes and values that are not supported for a
390            specific document format. For example, a Printer object
391            might have multiple interpreters to support both
392            'application/postscript' (for PostScript) and 'text/plain'
393            (for text) documents. However, for only one of those
394            interpreters might the Printer object be able to support
395            'number-up' with values of '1', '2', and '4'. For the
396            other interpreter it might be able to only support
397            'number-up' with a value of '1'.  Thus a client can use
398            the Get-Printer-Attributes operation to obtain the
399            attributes and values that will be used to accept/reject a
400            create job operation.
401
402            If the Printer object does not distinguish between
403            different sets of supported values for each different
404            document format when validating jobs in the create and
405            Validate-Job operations, it MUST NOT distinguish between
406            different document formats in the Get-Printer-Attributes
407            operation. If the Printer object does distinguish between
408            different sets of supported values for each different
409            document format specified by the client, this
410            specialization applies only to the following Printer
411            object attributes:
412
413            - Printer attributes that are Job Template attributes
414              ('xxx- default' 'xxx-supported', and 'xxx-ready' in the
415              Table in Section 4.2),
416
417            - 'pdl-override-supported',
418            - 'compression-supported',
419            - 'job-k-octets-supported',
420            - 'job-impressions-supported',
421            - 'job-media-sheets-supported',
422            - 'printer-driver-installer',
423            - 'color-supported', and
424            - 'reference-uri-schemes-supported'
425
426            The values of all other Printer object attributes
427            (including 'document-format-supported') remain invariant
428            with respect to the client supplied document format
429            (except for new Printer description attribute as
430            registered according to section 6.2).
431
432            If the client omits this 'document-format' operation
433            attribute, the Printer object MUST respond as if the
434            attribute had been supplied with the value of the Printer
435            object's 'document-format- default' attribute. It is
436            RECOMMENDED that the client always supply a value for
437            'document-format', since the Printer object's
438            'document-format-default' may be
439            'application/octet-stream', in which case the returned
440            attributes and values are for the union of the document
441            formats that the Printer can automatically sense.  For
442            more details, see the description of the 'mimeMediaType'
443            attribute syntax in section 4.1.9.
444
445            If the client supplies a value for the 'document-format'
446            Operation attribute that is not supported by the Printer,
447            i.e., is not among the values of the Printer object's
448            'document-format-supported' attribute, the Printer object
449            MUST reject the operation and return the
450            'client-error-document-format-not-supported' status code.
451
452    """
453
454    out = {}
455
456    # generic operations verification
457    attrs = verify_operations(request)
458
459    # requested printer uri
460    if 'printer-uri' not in attrs:
461        raise err.BadRequest("Missing 'printer-uri' attribute")
462    out['printer-uri']  = verify_printer_uri(attrs['printer-uri'])
463
464    # requesting username
465    if 'requesting-user-name' not in attrs:
466        logger.warning("Missing 'requesting-user-name' attribute")
467    else:
468        out['requesting-user-name'] = verify_requesting_username(attrs['requesting-user-name'])
469
470    if 'requested-attributes' in attrs:
471        out['requested-attributes'] = None # XXX
472
473    if 'document-format' in attrs:
474        out['document-format'] = None # XXX
475
476    return out
477
478def make_get_printer_attributes_response(attrs, request):
479    """3.2.5.2 Get-Printer-Attributes Response
480
481    The Printer object returns the following sets of attributes as
482    part of the Get-Printer-Attributes Response:
483
484    Group 1: Operation Attributes
485        Status Message:
486            In addition to the REQUIRED status code returned in every
487            response, the response OPTIONALLY includes a
488            'status-message' (text(255)) and/or a
489            'detailed-status-message' (text(MAX)) operation attribute
490            as described in sections 13 and 3.1.6.
491        Natural Language and Character Set:
492            The 'attributes-charset' and 'attributes-natural-language'
493            attributes as described in section 3.1.4.2.
494
495    Group 2: Unsupported Attributes
496        See section 3.1.7 for details on returning Unsupported
497        Attributes.  The response NEED NOT contain the
498        'requested-attributes' operation attribute with any supplied
499        values (attribute keywords) that were requested by the client
500        but are not supported by the IPP object.  If the Printer
501        object does return unsupported attributes referenced in the
502        'requested-attributes' operation attribute and that attribute
503        included group names, such as 'all', the unsupported
504        attributes MUST NOT include attributes described in the
505        standard but not supported by the implementation.
506
507    Group 3: Printer Object Attributes
508        This is the set of requested attributes and their current
509        values.  The Printer object ignores (does not respond with)
510        any requested attribute which is not supported. The Printer
511        object MAY respond with a subset of the supported attributes
512        and values, depending on the security policy in
513        force. However, the Printer object MUST respond with the
514        'unknown' value for any supported attribute (including all
515        REQUIRED attributes) for which the Printer object does not
516        know the value. Also the Printer object MUST respond with the
517        'no-value' for any supported attribute (including all REQUIRED
518        attributes) for which the system administrator has not
519        configured a value. See the description of the 'out-of-band'
520        values in the beginning of Section 4.1.
521
522    """
523
524    response = make_empty_response(request)
525    make_printer_attributes(attrs, request, response)
526    return response
527
528### CUPS-GET-DEFAULT
529
530def verify_cups_get_default_request(request):
531    """CUPS-Get-Default Request
532   
533    The following groups of attributes are supplied as part of the
534    CUPS-Get-Default request:
535
536    Group 1: Operation Attributes
537        Natural Language and Character Set:
538            The 'attributes-charset' and
539            'attributes-natural-language' attributes as described
540            in section 3.1.4.1 of the IPP Model and Semantics
541            document.
542        'requested-attributes' (1setOf keyword):
543            The client OPTIONALLY supplies a set of attribute
544            names and/or attribute group names in whose values the
545            requester is interested. If the client omits this
546            attribute, the server responds as if this attribute
547            had been supplied with a value of 'all'.
548
549    (Source: http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_DEFAULT )
550
551    """
552
553    return {}
554
555def make_cups_get_default_response(attrs, request):
556    """CUPS-Get-Default Response
557
558    The following groups of attributes are send as part of the
559    CUPS-Get-Default Response:
560
561    Group 1: Operation Attributes
562        Status Message:
563            The standard response status message.
564        Natural Language and Character Set:
565            The 'attributes-charset' and
566            'attributes-natural-language' attributes as described
567            in section 3.1.4.2 of the IPP Model and Semantics
568            document.
569
570    Group 2: Printer Object Attributes
571        The set of requested attributes and their current values.
572
573    (Source: http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_DEFAULT )
574
575    """
576
577    response = make_empty_response(request)
578    make_printer_attributes(attrs, request, response)
579    return response
580
581### CUPS-GET-PRINTERS
582
583def verify_cups_get_printers_request(request):
584    """CUPS-Get-Printers Request
585   
586    The following groups of attributes are supplied as part of the
587    CUPS-Get-Printers request:
588
589    Group 1: Operation Attributes
590        Natural Language and Character Set:
591            The 'attributes-charset' and
592            'attributes-natural-language' attributes as described
593            in section 3.1.4.1 of the IPP Model and Semantics
594            document.
595        'first-printer-name' (name(127)):CUPS 1.2/Mac OS X 10.5
596            The client OPTIONALLY supplies this attribute to
597            select the first printer that is returned.
598        'limit' (integer (1:MAX)):
599            The client OPTIONALLY supplies this attribute limiting
600            the number of printers that are returned.
601        'printer-location' (text(127)): CUPS 1.1.7
602            The client OPTIONALLY supplies this attribute to
603            select which printers are returned.
604        'printer-type' (type2 enum): CUPS 1.1.7
605            The client OPTIONALLY supplies a printer type
606            enumeration to select which printers are returned.
607        'printer-type-mask' (type2 enum): CUPS 1.1.7
608            The client OPTIONALLY supplies a printer type mask
609            enumeration to select which bits are used in the
610            'printer-type' attribute.
611        'requested-attributes' (1setOf keyword) :
612            The client OPTIONALLY supplies a set of attribute
613            names and/or attribute group names in whose values the
614            requester is interested. If the client omits this
615            attribute, the server responds as if this attribute
616            had been supplied with a value of 'all'.
617        'requested-user-name' (name(127)) : CUPS 1.2/Mac OS X 10.5
618            The client OPTIONALLY supplies a user name that is
619            used to filter the returned printers.
620
621    (Source: http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_PRINTERS )
622
623    """
624
625    # XXX: actually do something here
626    return {}
627
628def make_cups_get_printers_response(printers, request):
629    """CUPS-Get-Printers Response
630
631    The following groups of attributes are send as part of the
632    CUPS-Get-Printers Response:
633
634    Group 1: Operation Attributes
635        Status Message:
636            The standard response status message.
637        Natural Language and Character Set:
638            The 'attributes-charset' and
639            'attributes-natural-language' attributes as described
640            in section 3.1.4.2 of the IPP Model and Semantics
641            document.
642           
643    Group 2: Printer Object Attributes
644        The set of requested attributes and their current values
645        for each printer.
646
647    (Source: http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_PRINTERS )
648
649    """
650
651    response = make_empty_response(request)
652    for printer in printers:
653        make_printer_attributes(printer, request, response)
654    return response
655
656### CUPS-GET-CLASSES
657
658def verify_cups_get_classes_request(request):
659    """CUPS-Get-Classes Request
660
661    The following groups of attributes are supplied as part of the
662    CUPS-Get-Classes request:
663
664    Group 1: Operation Attributes
665        Natural Language and Character Set:
666            The 'attributes-charset' and
667            'attributes-natural-language' attributes as described
668            in section 3.1.4.1 of the IPP Model and Semantics
669            document.
670        'first-printer-name' (name(127)):CUPS 1.2/Mac OS X 10.5
671            The client OPTIONALLY supplies this attribute to
672            select the first printer that is returned.
673        'limit' (integer (1:MAX)):
674            The client OPTIONALLY supplies this attribute limiting
675            the number of printer classes that are returned.
676        'printer-location' (text(127)): CUPS 1.1.7
677            The client OPTIONALLY supplies this attribute to
678            select which printer classes are returned.
679        'printer-type' (type2 enum): CUPS 1.1.7
680            The client OPTIONALLY supplies a printer type
681            enumeration to select which printer classes are
682            returned.
683        'printer-type-mask' (type2 enum): CUPS 1.1.7
684            The client OPTIONALLY supplies a printer type mask
685            enumeration to select which bits are used in the
686            'printer-type' attribute.
687        'requested-attributes' (1setOf keyword) :
688            The client OPTIONALLY supplies a set of attribute
689            names and/or attribute group names in whose values the
690            requester is interested. If the client omits this
691            attribute, the server responds as if this attribute
692            had been supplied with a value of 'all'.
693        'requested-user-name' (name(127)) : CUPS 1.2/Mac OS X 10.5
694            The client OPTIONALLY supplies a user name that is
695            used to filter the returned printers.
696
697    (Source: http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_CLASSES )
698
699    """
700
701    # XXX: actually do something here
702    return {}
703
704def make_cups_get_classes_response(request):
705    """CUPS-Get-Classes Response
706
707    The following groups of attributes are send as part of the
708    CUPS-Get-Classes Response:
709
710    Group 1: Operation Attributes
711        Status Message:
712            The standard response status message.
713        Natural Language and Character Set:
714            The 'attributes-charset' and
715            'attributes-natural-language' attributes as described
716            in section 3.1.4.2 of the IPP Model and Semantics
717            document.
718
719    Group 2: Printer Class Object Attributes
720        The set of requested attributes and their current values
721        for each printer class.
722
723    (Source: http://www.cups.org/documentation.php/spec-ipp.html#CUPS_GET_CLASSES )
724
725    """
726
727    response = make_empty_response(request)
728    return response
Note: See TracBrowser for help on using the repository browser.