Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: RTResponse should be more pythonic #15

Open
lkarsten opened this issue Jan 28, 2013 · 3 comments
Open

Feature: RTResponse should be more pythonic #15

lkarsten opened this issue Jan 28, 2013 · 3 comments

Comments

@lkarsten
Copy link

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.

@z4r
Copy link
Owner

z4r commented Jan 28, 2013

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.

@daffodil
Copy link
Contributor

daffodil commented Feb 1, 2013

Had a quick look at tracker.py ?

How am I supposed to use it ?

eg
tracker = Tracker('http://rt.foo.com/REST/1.0/', 'webmaster', 'secret', CookieAuthenticator)

But it look like the kinda thing i want..

Pete

@z4r z4r mentioned this issue Feb 3, 2013
@darkpixel
Copy link

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': '[email protected]',
    }
}

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants