Skip to content

Feature: RTResponse should be more pythonic #15

Open

Description

@lkarsten

It should be possible to get a response in dictionary form. List of tuples is a good starting point, but you usually want to access just one field real quick.

Dates returned in an RTResponse should be pre-parsed to datetime objects, instead of returned as strings. (There might be some locale issues here)

This will simplify use of the library.

Implementation wise it should be an easy fix in rtkit/resource.py's RTResponse object, but I'm not sure how it best is made visible interface wise.

I'm happy to provide a patches if these changes sound acceptable.

Activity

  1. z4r commented on Jan 28, 2013

    @z4r
    Owner

    Hi Lasse,
    thanks for your interest.
    You do quite right, but my idea was a set of high-level API that should solve the unpythonic.

    The basic idea can be found in tracker.py and entities.py.

    let me know what do you think about it.

  2. darkpixel commented on Jun 2, 2015

    @darkpixel

    Easy workaround. Use the documented method for creating a ticket along with a quick and dirty regular expression:

    import re
    
    re_ticket_id = re.compile(r'Ticket (?P<ticket_id>\d+) created\.', re.MULTILINE)
    
    resource = RTResource('https://example.com/rt/REST/1.0', 'user', 'pass')
    
    content = {
        'content': {
            'Queue': 'General',
            'Subject': 'My Summary',
            'Text': 'This is my test ticket',
            'Requestors': 'user@example.tld',
        }
    }
    
    response = resource.post(path='ticket/new', payload=content,)
    match = re_ticket_id.search(response.body)
    print 'Ticket ID: %s' % (match.group('ticket_id'))
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions