Popular recipes tagged "meta:loc=197"http://code.activestate.com/recipes/tags/meta:loc=197/2013-09-18T23:05:51-07:00ActiveState Code RecipesA wxPython GUI To Create Sqlite3 Databases (Python)
2013-09-18T23:05:51-07:00toufic zaarourhttp://code.activestate.com/recipes/users/4187866/http://code.activestate.com/recipes/578665-a-wxpython-gui-to-create-sqlite3-databases/
<p style="color: grey">
Python
recipe 578665
by <a href="/recipes/users/4187866/">toufic zaarour</a>
(<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/sqlite/">sqlite</a>, <a href="/recipes/tags/wxpython/">wxpython</a>).
Revision 2.
</p>
<p>A GUI built around wxPython in a way that will allow you to add to this application other forms and functionalities. The main DialogBox is to create,in a fast way, Sqlite3 databases that are used for web or applications development. In order to work properly, save the script in a separate directory.There is also more; each time you create a database a text file named "CreationLog.txt" will be created (for the first time you use the application or if it is not there) and updated, describing when and where was your database created and with what SQL query. I am pleased to receive all the suggestions and improvements on this site or to my e-mail directly if this is convenient to you.</p>
MySQL-based forum functions (Python)
2007-06-08T08:43:19-07:00Calder Coalsonhttp://code.activestate.com/recipes/users/4044812/http://code.activestate.com/recipes/521898-mysql-based-forum-functions/
<p style="color: grey">
Python
recipe 521898
by <a href="/recipes/users/4044812/">Calder Coalson</a>
.
</p>
<p>This program provides the basic functions required to write a forum in MySQL and Python. The way the class is structured allows it to be imported and used in any application, whether it's web based, command line, Tcl/Tk or wxPython. It simply provides the helper functions to perform actions required to get, use and set different data in the database.</p>
<p>However, I have not included the code to create the database yet. Here's the structure:
TABLE: users
INTEGER: id
STRING: name
STRING: signature
STRING: password
TABLE: messages
INTEGER: id
LONGSTRING: content
DATE: created
TIME: createdtime
DATE: edited
TIME: editedtime
INTEGER: authorid
TABLE: threads
INTEGER: id
STRING: title
STRING: messages
DATETIME: edited</p>
<p>Create that database, set up a user account, and change the arguments in ForumBase.__init__ to the user you want the program to log on as.</p>
Serve PageTemplates with Medusa (Python)
2002-10-18T17:16:53-07:00Troy Melhasehttp://code.activestate.com/recipes/users/119109/http://code.activestate.com/recipes/157501-serve-pagetemplates-with-medusa/
<p style="color: grey">
Python
recipe 157501
by <a href="/recipes/users/119109/">Troy Melhase</a>
(<a href="/recipes/tags/web/">web</a>).
</p>
<p>This recipe combines the delicious PageTemplates package with the flavorful Medusa package to serve up rendered PageTemplates from the file system.</p>
<p>Why not just use Zope you say? As far as I know, the current Zope release isn't an option with Python 2.2 code. The project for which this recipe was devised requires Python 2.2.</p>
<p>Ingredients you'll need:</p>
<ol>
<li><p>Python 2.2. If you're using 2.1, try Zope instead, as it does everything this recipe can do plus a whole lot more.</p></li>
<li><p>ExtensionClass and friends. There is more than one way to get ExtensionClass installed, but the method I've used successfully is to install StandaloneZODB. That package is available here: <a href="http://www.zope.org/Products/StandaloneZODB%3C/p%3E" rel="nofollow">http://www.zope.org/Products/StandaloneZODB</p></a></li>
<li><p>PageTemplates, TAL, and ZTUtils packages. These are available in the Zope source releases but must be installed manually. Again, there's more than one way to make these packages available in your system. The method I've used is to copy the package directories from the Zope source archive into the Python lib/site-packages/ directory. The Zope source is available from this link: <a href="http://www.zope.org/Products%3C/p%3E" rel="nofollow">http://www.zope.org/Products</p></a></li>
<li><p>Medusa. I used Medusa 0.5.2 to develop this recipe, but you may have an equally pleasant experience with other versions. You can get Medusa here: <a href="http://oedipus.sourceforge.net/medusa/%3C/p%3E" rel="nofollow">http://oedipus.sourceforge.net/medusa/</p></a></li>
<li><p>A Medusa startup script. As with all Medusa handlers, you must explicitly construct a PageTemplates handler and associate it with an HTTP server. You can modify a copy of the sample startup script included with Medusa or create your own.</p></li>
<li><p>Some PageTemplates. The code below reads PageTemplates markup from files stored in your file system. Give your markup files a ".pt" or ".ptx" extension, and the handler will try to render them as PageTemplates before returning their markup.</p></li>
</ol>
<p>Once you have all these items in place, modify your Medusa start up script:</p>
<ol>
<li><p>Save the code below as "pagetemplate_handler.py", and bring it into your script: import pagetemplate_handler</p></li>
<li><p>Construct a pagetemplate_handler.pagetemplate_handler, pagetemplate_handler.pagetemplate_xml_handler, or both. These types need a filesystem object, just like the default_handler.</p></li>
<li><p>Associate your pagetemplate_handler with your HTTP server.</p></li>
</ol>