Hi Joachim, my first steps in teapot used the named parameters (and manually sending the URL), but as soon as I used the HTML form, I had to switch to regex (I thought). Maybe this was wrong, but your hint concerning the 'req' will certainly yield new insights. I will try to find the req object and check what is going on with it... :-) thanks and kind regards Marcus jtuchel@objektfabrik.de <jtuchel@objektfabrik.de> schrieb am Di., 4. Aug. 2015 um 13:12 Uhr:
Marcus,
Hi Joachim,
thanks for your feedback. Concerning the order of the values I rely solely on the teapot error message.
The way I understand your code snippet, you access the url parameters by using "at: 1". I have never used Teapot, but would be surprised if it encourages this. In HTTP world, a parameter consists of its name and value, both being Strings.
Besides I have no idea how I could make this GET request independant from the order the HTML form generated.
You shouldn't be required to do anything. In the Smalltalk web frameworks I know (Sst and Seaside mostly) an HTTPRequest object has a Dictionary like API for accessing parameters. Maybe something like "parameterAt: 'r'" should do the trick.
Maybe with Javascript?
Javascript is the source of a lot of evil, but here, it is innocent like Cinderella. Normal HTTP processing still works without javascript and I hope this won't change any time soon. This is simple HTTP back and forth, no javascript required nor desired.
But I assume this simple scenario should work in teapot and I just understand it correctly...
Hmm. As I said, don't access url parameters by index, only by name. I am sure Teapot offers methods for that, in the most basic case it gives you a Dictionary or parameters, but most likely some wrapper that provides a Dictionary-esque access methods.
Maybe this bit is a starting point (found here https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfu...):
3.1. Parameters in URLs
The URL pattern may contain named parameters (e.g., <user> above), whose values are accessible via the request object. The request is an extension of ZnRequest with some extra methods.
Query parameters and Form parameters can be accessed the same way as path parameters (req at: #paramName). Teapot can perform conversions of parameters to a number, for example as follows:
Teapot on GET: '/user/<id:IsInteger>' -> [ :req | users findById: (req at: #id)]; output: #ston; start.
But hey, now I see why you wanted to use Regex: Chapter 3.2 introduces them.... So what can you do if you want to use the reqex stuff? I'd start by adding a Breakpoint into the handler block and inspect the req object that gets passed in. Maybe somethins is wrong about your regex (I am far from being an expert on Regular Expressions) and Teapot is not doing any harm. Joachim
-- ----------------------------------------------------------------------- Objektfabrik Joachim Tuchel mailto:jtuchel@objektfabrik.de <jtuchel@objektfabrik.de> Fliederweg 1 http://www.objektfabrik.de D-71640 Ludwigsburg http://joachimtuchel.wordpress.com Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1