Changeset cf32fee for server


Ignore:
Timestamp:
Dec 20, 2011, 11:56:46 AM (12 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
no-cups
Children:
71bfce0
Parents:
dc40fe9
git-author:
Jessica B. Hamrick <jhamrick@…> (12/20/11 11:56:46)
git-committer:
Jessica B. Hamrick <jhamrick@…> (12/20/11 11:56:46)
Message:

Add/update helper functions in ipp/operations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/lib/gutenbach/ipp/operations.py

    r6ed9d7a rcf32fee  
    2222            "Attribute group does not have OPERATION tag: 0x%x" % op_attrs.tag)
    2323
    24     # check charset attribute
     24    # XXX: check version
     25    if False:
     26        raise err.VersionNotSupported(str(request.version))
     27
     28    # check operation id
     29    if False:
     30        raise err.OperationNotSupported(str(request.operation_id))
     31
     32    # # check compression
     33    # if False:
     34    #     raise err.CompressionNotSupported
     35
     36    # # check document format
     37    # if False:
     38    #     raise err.DocumentFormatNotSupported
     39
     40    # # check document uri
     41    # if False:
     42    #     raise err.UriSchemeNotSupported
     43
     44    # check charset
     45    charset attribute
    2546    charset_attr = op_attrs.attributes[0]
    2647    if charset_attr.name != 'attributes-charset':
     
    3758            "Charset value does not have CHARSET tag: 0x%x" % charset_value.tag)
    3859    if charset_value.value != 'utf-8':
    39         raise err.Charset(
    40             "Invalid charset value: %s" % charset_value.value)
     60        raise err.CharsetNotSupported(str(charset_value.value))
    4161
    4262    # check for attributes-natural-language
     
    7292            requser_value.tag)
    7393    return requser_value.value
     94
     95def make_empty_response(request):
     96    # Operation attributes -- typically the same for any request
     97    attributes = [
     98        ipp.Attribute(
     99            'attributes-charset',
     100            [ipp.Value(ipp.Tags.CHARSET, 'utf-8')]),
     101        ipp.Attribute(
     102            'attributes-natural-language',
     103            [ipp.Value(ipp.Tags.NATURAL_LANGUAGE, 'en-us')])
     104        ]
     105    # Put the operation attributes in a group
     106    attribute_group = ipp.AttributeGroup(
     107        const.AttributeTags.OPERATION,
     108        attributes)
     109
     110    # Set up the default response -- handlers will override these
     111    # values if they need to
     112    response_kwargs = {}
     113    response_kwargs['version']          = request.version
     114    response_kwargs['operation_id']     = const.StatusCodes.OK
     115    response_kwargs['request_id']       = request.request_id
     116    response_kwargs['attribute_groups'] = [attribute_group]
     117    response = ipp.Request(**response_kwargs)
     118
     119    return response
     120
     121#### GET-JOBS
    74122
    75123def verify_get_jobs_request(request):
Note: See TracChangeset for help on using the changeset viewer.