I don't need it in routes but in templates to build a link.

I wonder just how can I have the url I posted without doing it by
myself (not a hassle tho)

It would be pretty smart for pylons.url to accept a dictionary as an
argument for extra request params, jQuery works this way and I never
had any trouble, rather than using "surplus" kwargs that obviously put
limits on the keys I can use.

================

To better understand what I need, my real script works this way:

it's an administrative tool:

a page shows a bunch of selected tables with their records and an
"edit" link for each row like this:

http://127.0.0.1:5000/controlpanel/edit?tName=products&id=1&id_seller=3

then the "edit" action reads table name and values for primary keys in
querystring then loads that record and creates a form to let user edit
its contents.

Working this way no matter what kind of tables I add to my db I can
edit its records.

I never used, until today a plain "id" for a column name (rather than
"prod_id") and I could keep on living without it but I wonder why such
limitation, I mean, haven't you ere seen a page with a ?id=nnn in its
url?...

Thanks for your support
neurino


On Dec 17, 7:04 pm, Mike Orr <[email protected]> wrote:
> On Fri, Dec 17, 2010 at 9:19 AM, neurino <[email protected]> wrote:
> > I have a dynamic form generator that uses request params to generate
> > fields.
>
> > Let's say I have, for example
>
> > myReqParam = {
> >    id:1
> >    action:"edit"
> > }
>
> > and would like pylons.url to generate this url:
>
> >http://127.0.0.1:5000/controlpanel/formgen?id=1&action=edit
>
> > it's a very common situation
>
> > If not reserved words like "id" and "action" are used I can issue
>
> > h.url(controller="controlpanel", action="formgen", **myReqParams)
>
> > but not with a dictionary like the above...
>
> You can't use a variable as a query param if the same variable is a
> path variable or constant in the relevant route. All Pylons routes
> define 'action', and a few define 'id'. It shouldn't matter if you use
> keyword args or **myReqParams because the same variable can't overlap
> between the two.
>
> The solution is to use ``webhelpers.util.update_params`` to add the
> query parameters:
>
> h.update_params(url(controller="controlpanel", action="formgen"),
> id=1, action="edit")
>
> Also, 'url' is a standard template variable in Pylons 1, so you don't
> need h.url in templates.
>
> > I tried to add a trailing slash like in formalchemy but it's not
> > stripped.
>
> I don't understand the question. If the route is defined with a
> trailing slash, it will be generated with one.
>
> >>> mapper.connect("abc", "/abc/")
> >>> url("abc")
> '/abc/'
> >>> url("/lala/", id=1)
>
> '/lala/?id=1'
>
> --
> Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to