Re: 2 questions: unique properties + history
"John P. Rouillard" <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Nagy and Ralf: In message <[email protected]>, Ralf Schlatterbeck writes: >On Wed, Feb 24, 2021 at 02:47:59PM +0100, Nagy Gabor wrote: >> multiple IDs either, I was asked to implement it. >> >> Now I am still struggling with the Hyperdb class wrapper of the web >> interface. My (lame?) question is how can I access items of classes via >> their key property, or at least fetch the ID, like >> db.status.lookup("resolved"). > >You can alway access the underlying API by using db._db where the db is >the web hyperdb wrapper and _db is the hyperdb object. > >I don't think the hyperdb wraps the lookup class, you can still use >filter, something along the lines of >db.status.filter (None, dict (name = 'resolved')) >or use the hyperdb layer directly. In my query edit template I have: tal:define="queries python:db.query.filter(filterspec={'creator': uid})" so I suspect: python:db.query.filter(filterspec={'name': 'resolved} would work if Ralf's sugestion doesn't. >> As I see, all operation requires the numeric ID of >> the item (@link@ etc.). Let's say I want to add a button "Change >> status to resolved" to the web page. To this end, I need the ID of >> "resolved" item of status class (right?). I do not want to hardcode >> to the HTML template that this is, let's say, 6. What is the easiest >> way to retrieve the ID of the status with (key property) name >> "resolved"? I can do it (loop through db/status/list, etc.), but none >> of my solutions is nice... If not necessary, I don't want to use low >> level methods, but if it is necessary, I will. :) Also you can write an extension. Add find_resolved_id.py to the tracker's extensions directory: def get_resolved_id(db): id = db._db.filter(...) return id def init(instance): instance.registerUtil('getresolvedid', get_resolved_id) call it in a template with: python:utils.getresolvedid(db) this hides the uglyness and names/documents it a little bit. -- -- rouilj John Rouillard =========================================================================== My employers don't acknowledge my existence much less my opinions.