#13 Creating/Executing components from strings, via Interpreter

v1.0_(example)
closed
nobody
interpreter (4)
5
2005-03-25
2005-03-19
No

I am attempting to compile a myghty template from a string. I'm
using the interpreter to generate the component from the string data
(via make_component), and then attemping to execute that
component via the interpreter (execute). If there is another way of
doing this, let me know (I noticed this is how Mason describes how
to do it ;) )

This is under 0.96f

The interpreter seems to lose my passed in parameter, possibly
during the the clone of the interp's request (the first thing execute
does)??

I've included a brief snippet of code that will reproduce this. It
prints out:

id: 137136108MissingArgument: required argument username not
found

file: test.py line 12

message = interp.execute(comp, username = 'pjenvey')

test.py:12

---------------------------------------------
Original Stack Trace:
MissingArgument: required argument username not found

file: /usr/local/lib/python2.3/site-packages/myghty/component.py line
110

raise exception.MissingArgument("required argument %s not found"
% arg)

/usr/local/lib/python2.3/site-packages/myghty/component.py:110
/usr/local/lib/python2.3/site-packages/myghty/request.py:389
/usr/local/lib/python2.3/site-packages/myghty/request.py:253
/usr/local/lib/python2.3/site-packages/myghty/exception.py:70
/usr/local/lib/python2.3/site-packages/myghty/request.py:285
/usr/local/lib/python2.3/site-packages/myghty/interp.py:129
test.py:12

Discussion

  • Mike Bayer

    Mike Bayer - 2005-03-19

    Logged In: YES
    user_id=1100624

    hey there -

    the interpreter execute() method actually handles the full
    blown set of per-request parameters, request arguments being
    just one of them. the format is as follows:

    message = interp.execute(comp, request_args =
    {'username':'pjenvey'})

    theres a brief example in the docs, probably needs some more
    documentation though, at:
    http://www.myghty.org/docs/configuration.myt#configuration_programmatic_interpreter

    might not be a bad idea to add another method, like
    "exec_comp" or something like that which does the (more
    mason-like) syntax youre looking for.

     
  • Mike Bayer

    Mike Bayer - 2005-03-25
    • status: open --> closed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks