myghty sample problem

2 views
Skip to first unread message

Alex Greif

unread,
Mar 22, 2006, 3:28:59 AM3/22/06
to pylons-discuss
Hi,
I dont know whether this is a pylons or myghty problem, but anyway...
I wanted to test some myghty features and took the simple "formcontrol"
sample from the mighty distro:
http://www.myghty.org/source/htdocs/examples/formcontrols/index
I put the three files in the templates folder of my pylons project.

In my controller I simply forwarded to the mighty template like
def mightyTestAction(self):
print m.request_args
m.subexec('/index.myt')

And in the index.myt I set the form action to:
<% h.url_for(action='mightyTestAction') %>

my routing.py has only the default:
map.connect(':controller/:action/:id)

The problem:
The index page shows up, but after filling in the fields and submitting
the form, the form args are not shown in the following page and the
field values are not preserved either. Somehow the request arguments
get lost on the way from the controller to the template renderer,
because inside the controller the print statement prints the args all
fine.

The application should work as on the mighty homepage:
http://www.myghty.org/examples/formcontrols/index.myt

I am still running
Mighty 1.0
pylons 0.8dev_r463

any help is appreciated

thanks,
Alex.

Ben Bangert

unread,
Mar 28, 2006, 6:09:20 PM3/28/06
to pylons-...@googlegroups.com
On Mar 22, 2006, at 12:28 AM, Alex Greif wrote:

> The index page shows up, but after filling in the fields and
> submitting
> the form, the form args are not shown in the following page and the
> field values are not preserved either. Somehow the request arguments
> get lost on the way from the controller to the template renderer,
> because inside the controller the print statement prints the args all
> fine.
>
> The application should work as on the mighty homepage:
> http://www.myghty.org/examples/formcontrols/index.myt
>
> I am still running
> Mighty 1.0
> pylons 0.8dev_r463

Is this problem still occurring now that you've updated? Sorry bout
the late reply, didn't see this email go by earlier.

- Ben

Alex Greif

unread,
Mar 30, 2006, 5:44:58 AM3/30/06
to pylons-discuss
Hi Ben,
after my update to pylons 0.8 and mighty 1.0.1 the problem still exists
:(

can anybody please verify the problem? I am currently stuck with this
problem. And I can find no samples with pylons and mighty form
controls.

The three mighty files can get from
http://www.myghty.org/source/htdocs/examples/formcontrols/index

thanks,
Alex.

Uwe Feldtmann

unread,
Mar 30, 2006, 5:57:42 AM3/30/06
to pylons-...@googlegroups.com
Alex Greif wrote:

Perhaps I missed a message or two but what exactly are you trying to
accomplish?

Uwe.

>thanks,
>Alex.
>
>

Alex Greif

unread,
Mar 30, 2006, 6:07:01 AM3/30/06
to pylons-...@googlegroups.com
I want to use a html form with some input fields. If certain fields
are not filled properly then the same page should be returned with the
fields prefilled.

So I have problems to show form input contents on the following page.

Alex.

Uwe Feldtmann

unread,
Mar 30, 2006, 6:14:29 AM3/30/06
to pylons-...@googlegroups.com
Alex Greif wrote:
I want to use a html form with some input fields. If certain fields
are not filled properly then the same page should be returned with the
fields prefilled.

So I have problems to show form input contents on the following page.
  
Do you want to validate the form elements via XMLHTTPRequest or only on form submission?


Also, I assume you have the following structure defined in your app.

/components
  field.myt
  components.myt
/templates
  index.myt
/controllers
  what_is_the_controller.py and what are your methods?

Uwe.

Alex Greif

unread,
Mar 30, 2006, 6:21:40 AM3/30/06
to pylons-...@googlegroups.com
validation would be the next step. I only want to see that the input
data (key, value pairs) can be show on the following page.

my structure is slightly different, I hav all myt files in templates:


/templates
field.myt
components.myt
index.myt
/controllers
mightytest.py

the controller looks like:
from fotobuchxxl.lib.base import *
class MightytestController(BaseController):


def mightyTestAction(self):
print m.request_args
m.subexec('/index.myt')


ALex.

Uwe Feldtmann

unread,
Mar 30, 2006, 6:50:46 AM3/30/06
to pylons-...@googlegroups.com
Alex Greif wrote:
validation would be the next step. I only want to see that the input
data (key, value pairs) can be show on the following page.

my structure is slightly different, I hav all myt files in templates:

/templates
  field.myt
  components.myt
  index.myt
  mightytest.py

the controller looks like:
from fotobuchxxl.lib.base import *
class MightytestController(BaseController):
    def mightyTestAction(self):
        print m.request_args
        m.subexec('/index.myt')
  
If the form post action="index.myt" I don't think it will come back to your controller. If it is coming back and m.request_args is returning what you want then you might like to try passing the return values from m.request_args as arguments to m.subexec.
hth.

Uwe.

Alex Greif

unread,
Mar 30, 2006, 6:55:46 AM3/30/06
to pylons-...@googlegroups.com
thanks, the following works:
def mightyTestAction(self):
print m.request_args
m.subexec('/index.myt', **m.request_args )

Is this the suggested way to do it in pylons?

Uwe Feldtmann

unread,
Mar 30, 2006, 7:05:48 AM3/30/06
to pylons-...@googlegroups.com
Alex Greif wrote:
thanks, the following works:
    def mightyTestAction(self):
        print m.request_args
        m.subexec('/index.myt', **m.request_args )

Is this the suggested way to do it in pylons?
  
Your guess is as good as mine.  There are several ways to perform this in Pylons, which is best I'm sure will depend more on your application flow than anything else.  I'm sure in time there will be recommendations put forth for best practices. In the meantime it's play and learn.

At least with Pylons it's fun.

Alex Greif

unread,
Mar 30, 2006, 7:08:09 AM3/30/06
to pylons-...@googlegroups.com
could you please post your suggestion?
The more solutions we have the better.

Ben Bangert

unread,
Mar 30, 2006, 10:48:28 AM3/30/06
to pylons-...@googlegroups.com
On Mar 30, 2006, at 3:55 AM, Alex Greif wrote:

> thanks, the following works:
> def mightyTestAction(self):
> print m.request_args
> m.subexec('/index.myt', **m.request_args )
>
> Is this the suggested way to do it in pylons?

Yes, I was helping someone on the irc channel out with the same thing
last night. The reason the examples for Myghty don't work when taking
<%args> blocks is because the Myghty examples do not have controllers
in the middle. The Myghty examples have the request go directly to
the template, when you instead call a template from a controller,
those arguments are not passed in unless you specify them.

Usually, I process the arguments as necessary in the controller,
assign the variables I want to use to 'c', then use them in the
templates as desired. If you just want to pass the request through to
the template with all its arguments intact, that is the suggested way.

HTH,
Ben

Reply all
Reply to author
Forward
0 new messages