Midgard workshop at FSCONS
Posted on 2008-10-21 21:33:53 EEST.
There will be a great Midgard related workshop at FSCONS. The focus of the workshop is to present the next generation of Midgard and great features that it offers.
What are those great features that are presented? Easiest and the most usable feature is the PHP & Python support and DBUS. Let's make a short snippet of code for python and for PHP that do the same thing
|
<?php $cnc = new midgard_connection(); $cnc->open('midgard'); $cnc->set_sitegroup('mysitegroup'); ?> |
import _midgard as midgard import gobject import dbus.mainloop.glib cnc = midgard.connection() cnc.open('midgard') cnc.set_sitegroup('mysitegroup) |
Both snippets do the exactly same thing. Open up connection to Midgard and after that the whole power of Midgard and it's features is at your disposal.
Let's make another short snippet that continue those I wrote earlier.
|
<?php $page = new midgard_page(); $page->name = "Testing 123"; $page->create(); $page->name = "Final 123"; $page->update(); ?>
|
page = midgard.mgdschema.midgard_page() page.name = "Testing 456" page->create() page.name = "Final 456" page.update() |
Again. Both do the very same thing. This same kind of data abstraction is available for C and soon for Mono (C#). But let's take this a bit further. What if I want have to put all latest articles to some index or search engine of my own?
Let's make one python snippet.
|
import _midgard as midgard import gobject import dbus.mainloop.glib import my_indexer def index(object, args): # LOTS OF MAGIC cnc = midgard.connection() cnc.open('midgard') cnc.set_sitegroup('mysitegroup) mbus = midgard.dbus("/midgard_article/create") mbus.connect("notified", index, "foo") mainloop = gobject.MainLoop() mainloop.run() |
As you can see it's that easy to make a python application that listens for creations off midgard_article objects. And this means all articles even if they are created at PHP - level. Piotras deserves big applause for this archievement!
When you play with PHP I suggest that you use MidCOM 3 component framework. It provides nice services that take full leverage of Midgard's services. But think what you can nowadays do behind the scenes with nice C, Mono or Python daemons. Sky is the limit!
