[Moin-user] SQL Queries in Moin

Juergen Hermann jh at web.de
Thu Oct 30 14:34:08 EST 2003


On Sun, 26 Oct 2003 18:53:15 +0000, Paul Moore wrote:

>[[SQL("select * from emp")]]

2 hours work at max.

>I'm assuming I'd probably have to write this myself,

Maybe a little more if you have to get aquainted. :)

We'll give you some hints.

> as I suspect that
>writing macros available? I've searched the MoinMoin site, but can't
>see anything (other than stuff in the MacroMarket that I can try to
>learn from).

Start at the MoinDev page. Add any things you learn, then we'll have 
more complete developer docs some day.

>This is getting a bit away from "collaborative website" and more into
>"web application" areas, so maybe MoinMoin isn't a good tool for this.

While I warn people to press moin into niches where other tools a WAY 
better (say, bug tracking), it is a good idea to create BRIDGES to other 
systems (e.g. bug report macros, probably you'll see Bugzilla support in 
the future). So adding ER modelling to moin is probably stupid, SQL 
selects are not.

>1. I need to get the username/password/database somewhere. Can I store
>   them externally to the page, or am I better just adding 3 more
>   parameters to the macro?

Just add them to moin_config.py. Use a special prefix though, like 
macro_sql_*.

>2. As I'm getting data from the database, it might be nice to password
>   protect the page. Is there any sort of Moin or Apache trick to
>   require authentication on particular Wiki pages?

Current CVS or upcoming release (#acl).

>3. Should I do this some other way altogether?

Not really. Do me a favour and make the thing DBAPI 2.0 compatible, and 
use __import__ to load the dbapi module, so that it's also configurable 
in moin_config. If you do that, expect to find SQL.py added to the 
distribution.

Use MoinMoin/macro/ShowSmileys.py as a template for SQL.py. As for docs 
on writing macros, just look at the existing ones. It really _IS_ easy, 
and often enough you don't need to know much about the rest of the moin 
source.

I had Python newbies write macros after 2 days with moin & python.


Ciao, Jürgen






More information about the Moin-user mailing list