Ticket #1160 (closed enhancement: fixed)

Opened 2 years ago

Last modified 11 months ago

[TiddlyWeb] keeping TiddlyWeb keywords in tiddlyweb.query

Reported by: jdlrobson Owned by: jdlrobson
Priority: undefined Milestone:
Component: tiddlyweb Version:
Severity: undefined Keywords: TiddlyWeb
Cc:

Description

I'm using jinja2 templates a lot and I am finding it increasingly annoying that when I render a page, that in the environ variable any query string parameters that are tiddlyweb keywords eg. select, sort, limit are not available in the convenient tiddlyweb.query dictionary.

eg. for  http://myurl.com/instance/page?s=5&select=tag:foo&select=title:!bar

in the environ variable there is environtiddlyweb.query? = {'s':5?} but I would like it to be environtiddlyweb.query? = {'s':5?,'select':['tag:foo','title:!bar']}

At the moment I have to parse QUERY_STRING which is really irritating.

Can this be changed?

Change History

  Changed 2 years ago by cdent

Potentially yes, but it sounds like there might be other ways to achieve what you are trying to achieve. If I knew what you were trying to achieve I might be able to either suggest an alternative or know if the "just use (a fixed up) tiddlyweb.query" solution is the right one.

Generally speaking you want to do as little coding and conditional handling in your templates as possible and assemble the data before entering the template rendering stage.

  Changed 2 years ago by cdent

  • owner changed from cdent to jdlrobson

follow-up: ↓ 4   Changed 2 years ago by cdent

  • component changed from core to tiddlyweb

in reply to: ↑ 3   Changed 2 years ago by jdlrobson

Replying to cdent: My thoughts on this are that even if it's the wrong thing to do it's inconsistent. I have had several problems. For instance I did a jinja template which allowed sorting of ideas. I used the query string parameter sort=-modifier and in python I expected to have convenient easy access to anything with query string name sort. However after inspection I noticed this was not there and that was why my code was failing.

If you use the env plugin it enlightens a new tiddlyweb developer. I noticed querystrings were held in environ and made a note of that in my brain. Then later on when I try to use it it doesn't work as I might expect it to.

I think it's also useful if you were writing a serialiser/template where you want to be able to parse the filters acting on a bag as well.

Say I wanted a list of tiddlers and above it something like this: Here is a list of all tiddlers tagged with foo,bar or baz with modifier field rakugo sorted by created date <<list>>

and the query sting on that seraliser was ?g=9mselect=tag:foo,tag:bar,tag:baz&select=modifier:rakugo&sort=-created&z=239&zx=3

trying to get the above sentence from this query string would be a nightmare if I had to use environQUERY_STRING? and regexs (which cause me great headaches) which at the moment appears to be my only option. What I'd like to be able to do is easily construct that string using the much simpler tiddlyweb.query format and doing simple splits on ":" in the arguments.

  Changed 2 years ago by cdent

  • status changed from new to closed
  • resolution set to fixed

fixed

  Changed 11 months ago by cdent

  • milestone TiddlyWeb 1.0 final deleted

Milestone TiddlyWeb 1.0 final deleted

Note: See TracTickets for help on using tickets.