Re: charset; logical OR on filtering; list of dates
"John P. Rouillard" <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Nagy: In message <20210512000436.0a2b1a63@Dell>, Nagy Gabor writes: >Now there are 3 questions in my mind about roundup (the last one is a >bit more general): > >1. The first one is probably a lame question. >How can I serve the content of a text/plain file (from a FileClass) with >a specified encoding? To be more precise, I want my browser to open >http://localhost:8080/tracker/msg4/textfile.txt >with "Content-Type: text/plain; charset=UTF-8" header. >I do not know how to achieve this using a standalone roundup server (or >running roundup-server behind an Apache proxy). Does changing the type property of the file to: text/plain; charset=UTF-8 result in sending an octet-stream? I think the type even though it's a string is sanitized to a list of known types for security. I don't remember seeing any other value used other than a plain mime type. If my guess above is correct then I don't have an answer other than code changes. You could replace Client::serve_file to allow charset. I think can be done in interfaces.py. Alternatively add a "charset" string property to the FileClass and replace Client::_serve_file to emit: self.additional_headers['Content-Type'] = "%s; charset=%s"%(mime_type,charset) with suitable value assigned to charset. I don't think you can wrap _serve_file to modify the Content-Type header while calling the original _serve_file to do all the real work. There is a self.write(content) call in _serve_file that I think triggers output to the browser before _serve_file returns. >2. Can I do logical OR operation on database filtering, concerning >different properties? >For example, I want to list issues with "assignedto=15 OR actor=15". >Do we have a built-in query for this, or shall I utilize filter_sql, or >any other custom solution? I don't know of any generic way to do this. I played with performing set operations between queries at a previous employer. The POC used two defined searches. This allowed you to: search1 UNION search2 - this is your OR operation search2 INTERSECT search3 search1 DIFFERENCE search4 I only implemented the UNION. To do this I defined a new action: setsearch with arguments: set1, set2, op, columns, sort, group @op = UNION (never got around to coding INTERSECTION or DIFFERENCE) @set1 was the designator of a query: query1 query22 etc. @set2 values as set1 columns, sort and group were the same as for the regular query interface. For UNION and INTERSECTION set1 and set2 are interchangable. For DIFFERENCE changing the order of set1 and set2 provides different results. This was done before the current query mechanism was defined. As a result all of the searches you defined were listed in the left sidebar. With the current query management interface, these additional queries can be hidden. If I was to do it again I might use an RPN style method similar to the query mechanism for links/multilinks. So: @q=query1,query2,UNION,query3,DIFFERENCE would combine the items from query1 and query2 then from that set remove the items in query3. This allows multiple operations among queries. I also didn't have a method for saving these queries. They were done using a template to select the queries and execute the new action. This method could allow storing these queries in the query class along with the other queries. So they can be displayed in the left hand sidebar with the rest. >3. This one is a little more general. I know that relational databases >are not designed to store lists/arrays. But I have to implement somehow >a property (let's call it "important_dates") which stores a LIST of >dates. What is the best practice to implement this? * What do you want to do with the list? * Is it a text blob? * Do you want to search for a value in it? * Will multiple issues link to the same element of the list (e.g. date)? * How should it be sorted? Basically a list is a mutilink so: issue = IssueClass( ..., important_dates=Multilink(dates), ...) dates=Class(db, date=Date(), order=Integer()) Have a great day. -- -- rouilj John Rouillard =========================================================================== My employers don't acknowledge my existence much less my opinions.