Tim is correct and web2py is push but,
1) an action can call another action in the same controller
2) it is possible to write a controller like
def index():
return(functions=globals())
and a corresponding view that calls
{{=functions['myotherfunction']()}}
where myotherfuction is another action in the same controller.
I am not suggesting this is good practice. Just pointing out it is
possible.
On Mar 20, 12:18 pm, Timothy Farrell <[email protected]> wrote:
> I think you may be confusing push and pull MVC models. web2py is a push
> model. Consequently, views cannot call controllers, rather is the
> controller that is run and what it returns is applied to a predefined view.
>
> Instead of printing the output, assign it to a variable and wrap it in a
> dictionary. Return said dictionary...like so:
>
> output = "Ping output goes here"
> return dict(pingout=output)
>
> If you don't have a view for your page, the default view will display
> the contents of the returned dictionary. Otherwise, you can make a view
> that displays pingout like so:
>
> {{=pingout}}
>
> -tim
>
>
>
> dave_mcgee wrote:
> > Ok, I've worked on this some more and I've taken your recommendation
> > to use a pure Python implementation available here (http://
> > svn.pylucid.net/pylucid/CodeSnippets/ping.py)
>
> > I have this set as a default.py controller in my web2py environment
> > for my app project. Say, I wish to call this controller and run it
> > from my app view (When a user visits default/index.html the results
> > from ping.py are displayed in it) - Is this hard to do?
>
> > Thanks for your help guys - this is a major learning curve for me
>
> > On Mar 20, 2:15 pm, dave_mcgee <[email protected]> wrote:
>
> >> Hi Tim! Thanks for the warm welcome and the assistance!
>
> >> Will work further on this today :)
>
> >> Regards,
> >> Dave
>
> >> On Mar 20, 12:56 pm, Timothy Farrell <[email protected]> wrote:
>
> >>> Welcome to web2py! We're glad you're here.
>
> >>> 1) To install win32 python extensions, the easiest way is to download
> >>> and run the exe from:
>
> >>>http://sourceforge.net/project/platformdownload.php?group_id=78018
>
> >>> ...that corresponds to the version of Python you use. Generally, when
> >>> you see a setup.py script, you use that to install the package by
> >>> upzipping the whole thing to a directory and then running: setup.py
> >>> install. Some packages will complain if you don't have a compiler
> >>> installed because they want to compile some speedups. In most cases you
> >>> can run: setup.py install --without-speedups ...to get around that.
>
> >>> 2) Nope. I tested your script and it works just fine as it is. But it
> >>> only accepts IP addresses (no domain names).
>
> >>> 3) I recommend that you use a more cross-platform solution. See this
> >>> page:http://stackoverflow.com/questions/316866/ping-a-site-in-python
>
> >>> -tim
>
> >>> dave_mcgee wrote:
>
> >>>> Hi everyone. I'm new enough to web2py so please be gentle! :)
>
> >>>> I'm just involved in a small college project at the moment where we've
> >>>> had an existing python script monitoring a number of nodes and
> >>>> returning the results in the python GUI. I'm just moving onto trying
> >>>> to integrate the project into a web2py web framework environment (I've
> >>>> started today)
>
> >>>> I'm currently reading through the manual but having difficulty getting
> >>>> different pieces to work.
>
> >>>> I wish to use the Win32 com module to integrate the functionality of
> >>>> the ping command within my python script below. I'd apreciate it if
> >>>> someone could guide me as how to integrate this script within a web
> >>>> environment..
>
> >>>> 1) Is it as simple as importing setup.py into my project in Web2py
> >>>> from the win32 folder I extracted off source forge?
>
> >>>> 2) Do I have to change any parameters, at all?
>
> >>>> Any other help would be much apreciated! Script is below.. Thanks!
>
> >>>> import win32com.client
>
> >>>> wmi = win32com.client.GetObject(r"winmgmts:\\.\root\cimv2")
>
> >>>> def Ping(host):
> >>>> col_items = wmi.ExecQuery("Select * from Win32_PingStatus Where
> >>>> Address = '%s'" % host)
> >>>> for item in col_items:
> >>>> if item.StatusCode == 0:
> >>>> # success
> >>>> print "Host ", item.Address
> >>>> print "Recorded Hops: ", item.RecordRoute
> >>>> print "Buffer Size: ", item.ReplySize
> >>>> print "Response Time: ", item.ResponseTime
> >>>> print "ResponseTimeToLive: ", item.ResponseTimeToLive
> >>>> print "Timeout: ", item.Timeout
> >>>> print "TimetoLive: ", item.TimetoLive
>
> >>>> # ping node
> >>>> Ping('192.168.1.3')
>
> >>> --
> >>> Timothy Farrell <[email protected]>
> >>> Computer Guy
> >>> Statewide General Insurance Agency (www.swgen.com)
>
> --
> Timothy Farrell <[email protected]>
> Computer Guy
> Statewide General Insurance Agency (www.swgen.com)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---