Spyce contains a few methods that deal with handling form data. You've already seen one of them briefly, but let's take a look at some more of them: [[\ [[-- Handle processing --]] [[-- The actual form --]] The script above sends form data through either the “GET” or “POST” methods randomly, and then it displays the results of several of Spyce's methods, which are listed in the methods list. Below that, we define getList. Notice, however, that getList deals with Spyce itself. The “[[!spy X]]” structure simply defines a function that can be accessed later. In this case, it's a function that calls a method with either “A”, “B” or “C” as an argument—our field names. Later in the script, we call this function with each item in methods. Observe what each method returns, and observe what happens when “GET” and “POST” data are mixed. Conclusion Spyce has a lot to offer to web developers and developers looking for dynamic content in general. One of its main advantages is that it can work alone, with Apache, with mod_python, with FastCGI or with CGI without any major modifications. If one method is not available to you, there's always more to fall back on. It offers several tags that can be used for unique purposes, and it offers a way for developers to save time by using active tags. Of course, there are also plenty of others features of Spyce that cannot be covered in a single article. Spyce isn't the only way of embedding Python code, but it is arguably the most feature-filled way.
blog comments powered by Disqus |