View previous topic :: View next topic |
Author |
Message |
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sat Mar 12, 2005 3:50 pm Post subject: Walnut scripts for HTML page generation |
|
|
(Edit: I split this topic since it was polluting your ActiveX one)
I'm gonna (finally) start looking at how to hook more of Mango up to this thing. In particular, I'll attempt to implement an HTTP container for Walnut scripts. Any ideas on how to expose both the input and output classes as script "arguments" ? Carlos?
Last edited by kris on Sun Mar 13, 2005 9:43 pm; edited 1 time in total |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Sat Mar 12, 2005 4:59 pm Post subject: |
|
|
kris wrote: | Additionally,
If there were a tool like Swig4D, for D libraries instead of C libraries, then it'd be much easier to hook things up.
I'm gonna (finally) start looking at how to hook more of Mango up to this thing. In particular, I'll attempt to implement an HTTP container for Walnut scripts. Any ideas on how to expose both the input and output classes as script "arguments" ? Carlos? |
Sorry, but I don't understand what you mean. |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sat Mar 12, 2005 5:59 pm Post subject: |
|
|
Yeah; that was a bit vague!
I'm going to setup Walnut within an HTTP server, such that the scripts act like servlets. Scriptlets, if you like. To tie the scripts to the outside world, they need to be provided with a context. In the servlet world, this is provided in the form of a ServletRequest & ServletResponse pair.
In the scriptlet world, should this pair somehow manifest themselves as predefined 'magic' variables? Or should one somehow pass them as arguments via program.execute()?
Or should there be a 'Context' object that the script has to bind to before retrieving said pair? This kind of thing should be both efficient & trivial in usage, so that's a consideration.
Appreciate your help, Carlos. |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Sat Mar 12, 2005 6:28 pm Post subject: |
|
|
kris wrote: | Yeah; that was a bit vague!
I'm going to setup Walnut within an HTTP server, such that the scripts act like servlets. Scriptlets, if you like. To tie the scripts to the outside world, they need to be provided with a context. In the servlet world, this is provided in the form of a ServletRequest & ServletResponse pair.
In the scriptlet world, should this pair somehow manifest themselves as predefined 'magic' variables? Or should one somehow pass them as arguments via program.execute()?
Or should there be a 'Context' object that the script has to bind to before retrieving said pair? This kind of thing should be both efficient & trivial in usage, so that's a consideration.
Appreciate your help, Carlos. |
Considering that both ServletRequest and ServletResponse constructors take a IProviderBridge (I keep writing Bridget, even if I don't know any ), I'd say they should be created without the user noticing.
I don't know if you've checked what I did so far integrating Mango into Walnut, but basically I ported the cserver example. It seems to work (at least it doesn't throw any exceptions or such), but I'm not sure what it does, so I couldn't tell for sure. What I've done is wrap Mango classes around Walnut types, but maybe that's too low level.
Thing is, I don't know: it seemed like a good idea when I started, I still don't think it's a bad idea, but I can't tell if it's "efficient & trivial in usage". How high or low should we go? That's a question that could only be answered by knowing what users Walnut is gonna have.
(I reckon what I just wrote sounds a bit odd, so take it by the good side). |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sat Mar 12, 2005 7:28 pm Post subject: |
|
|
I'm still not being clear
What you're describing above is building an http server using scripting as the glue to tie the pieces together. The script is wrapped around the libraries.
What I'm getting at is executing the scripts within the http server; the library is wrapped around the scripts instead
I have looked at what you've achieved so far ~ there sure is a lot of work there! But the area I'm interested in is not yet covered.
And, to clarify, I should note the Request and Response pair are actually those IServletRequest & IServletResponse interfaces that get handed to a running servlet. I think what you're talking about is the construction phase of those, whereas I'm getting at the usage of them.
BTW, Carlos: is there some documentation that notes how all the various integration structs operate, and which method signatures one must expose? Or did you figure all that out the hard way? I'm looking for some basic recipes to follow, being a lazy sod and all. |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Sat Mar 12, 2005 8:42 pm Post subject: |
|
|
Let's see if I understood this time.
Your scenario is the server running and some user (admin, I suppose) wanting to change something to the running server? If that's so, then it's a whole different thing. You should take a look at http://dblinux.sis.epn.edu.ec/~csantand/dmdscript.html and see point #4.
About documentation, no way. I had to go through the sources and understand how things are done.
And don't worry, it's natural to be lazy: human beings are lazy. Just think of all the progress we've made: someone didn't want to walk, he invented a car, someone didn't want to write, he invented a typing machine, someone didn't want to take the stairs, he invented an elevator... Laziness is what makes us what we are. |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sun Mar 13, 2005 1:36 pm Post subject: |
|
|
Carlos wrote: | Let's see if I understood this time.
Your scenario is the server running and some user (admin, I suppose) wanting to change something to the running server? If that's so, then it's a whole different thing |
Perhaps
Here's an alternate angle: the scripts will be used in place of JSP. They are server scripts, rather than client scripts. Hooking Walnut up to a database might be of value here.
Do you have any thoughts upon database bindings? |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Sun Mar 13, 2005 7:52 pm Post subject: |
|
|
Yeah, I'm familiar with JSP, but let me see how that'd work.
I remember Apache JServer (that's the name, right?) parsed each JSP, produced a Java file out of it and the compiled it and with some sort of black magic (ie, a process unknown to me) it worked. For example, this:
Code: | <?! String foo() { return "Walnut"; } ?>
<!-- html code-->
<? // java code ?>
<?=/*java variable?>
|
Was converted to:
Code: | class Something {
// JServer things
String foo() { return "Walnut"; }
returntype mainJSPfunction(arguments)
{
//JServer things
response.out(/*html code*/);
// java code
response.out(/*java variable*/.toString());
//more things
}
|
Basically, that was it, right?
The solution I see for this is to do it in Mango and not in Walnut. First, you'd have to write a parser for the server scripts (let's call them MSP, mango server pages, or maybe WSP ). It would output Walnut code. Then, you'd have to integrate Walnut into Mango. Why, because Mango will be the HTTP server, so it'll know about responses, requests, etc. Then, it'd be just like the example I told you about: the Walnut that you'd have into Mango would have to interact with your Mango objects (I hope I'm being clear).
Database access wouldn't be but just a matter of someone writing a 100? generic database access library in D (similar to what John C and I did for ActiveX in the digitalmars.d ng), and then write a wrapper around it for Walnut.[/code] |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sun Mar 13, 2005 8:51 pm Post subject: |
|
|
Yep - now we're talking about the same thing
Hooking the big peices together is pretty straightforward. What remains is the original question: what's the best way to pass arguments into a script?
These arguments are a pair of classes, and represent the IServletRequest and IServletResponse instances ~ the input and output handles. Is there a nice clean way to pass them directly to a script as part of the global object, or does the script have to instantiate a new object (called Context, for example) before it can retrieve these two handles? This is a question about DMDScript implementation, rather than one about Walnut per se.
Does this make sense? |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Mon Mar 14, 2005 7:52 am Post subject: |
|
|
kris wrote: | Yep - now we're talking about the same thing
Hooking the big peices together is pretty straightforward. What remains is the original question: what's the best way to pass arguments into a script?
These arguments are a pair of classes, and represent the IServletRequest and IServletResponse instances ~ the input and output handles. Is there a nice clean way to pass them directly to a script as part of the global object, or does the script have to instantiate a new object (called Context, for example) before it can retrieve these two handles? This is a question about DMDScript implementation, rather than one about Walnut per se.
Does this make sense? |
For doing that, you can check Walnut. The steps are simple: read the script, compile it and execute it. That's all done by DMDScript. What you have to do is, before execution but after compiling, create the new objects. What objects, I don't know. You have to create new types (again, see Walnut) in order to do it. That way, I don't think there'll be any need to pass arguments, because whatever you want the user to have at hand, you'll provide through those objects. I don't know what else I can say ATM without you looking at the source code to see what I'm talking about. |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sat Apr 09, 2005 2:04 am Post subject: |
|
|
After an extended bout of consideration and reflection, it turns out DMDScript is far from ideal for my needs. FWIW, the deciding factors include (in no particular order)
- the license
- a distinct lack of documentation for hooking up through somewhat arcance interfaces
- lack of reasonable support within D for loadable OO libraries, implemented in and callable from D (and hence DMDScript)
Lua is rather more suitable for my needs, is completely open, and has all the appropriate libraries hooked up already. Forgive me, Carlos ~ but I have to reverse direction on my intended involvement here. |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Sat Apr 09, 2005 8:28 am Post subject: |
|
|
No problem. |
|
Back to top |
|
|
dan.lewis
Joined: 21 Feb 2007 Posts: 69 Location: Canada
|
Posted: Tue Mar 13, 2007 3:57 pm Post subject: |
|
|
I'm hoping to solve these in the future for anyone else wanting to work on Walnut.
1) Walnut 1.1+ version(Windows) will include ActiveX and DLL support.
2) Walnut 2.X is being released under a BSD license.
3) Walnut 2.X is aspect oriented - extremely easy to read, enough so that adding things feels more like data entry than programming.
4) I may want to attach Walnut to AutoItX at some point. _________________ nop
nop ; problem solved |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|