Piotras' blog: Archive

2006-08-01 - 2006-08-31

MOB - objects' tree

Posted on 2006-08-02 11:42:42 UTC.

Just few days ago I wrote that I am going to write midgard-gtk object browser , even if I am to write it in a year. Today I have registered class list and objects' tree browser. Limited to root objects only, but I it will change within day or two.

A lesson from this part of MOB is that midgard misses some core functionality ( mostly object's method ) which is able to return only root objects if object's class is registered as "content tree" one.

So to build object's tree we should have such three methods ( two of them are already implemented ):

  • list_roots
  • list
  • list_childs


An interesting ( built in ) feature for tree widget is search functionality. If the tree has too many entries and you would like to find particular one by name , it's enough if you start typing. Exactly the same as you used to do using Firefox or Nautilus.


At this point I found one issue. Double clicking on midgard_snippet just hangs application. Or at least it looks like as I had no time to wait till it makes anything. Of course I selected all snippets. In such case it may be more than 5 thousands records.


Another interesting lesson from MOB writing is the fact that core misses config file functionality which should return only the names of configuration files or even better all the names of all configurations. Such approach would encapsulate real file names and could provide more readable configurations and their "destinations" , like :

  • midgard ( my.remote.host )
  • midgard ( localhost )
  • midgard ( my.another.host )

To be continued soon...

Aegir and PHP5

Posted on 2006-08-03 11:26:39 UTC.

If you try to run Aegir with PHP5 and you get this warning:

Parse error: syntax error, unexpected T_ABSTRACT, expecting ')'  
in /var/cache/midgard/bergietest/1-5-5-0.php(991) : eval()'d code
(5) : eval()'d code on line 538

Edit /NemeinRCS/xml_rcs_functions snippet:

Line 538 is:

abstract =>  "CDATA",

Replace it with:

"abstract" =>  "CDATA",



MOB needs name

Posted on 2006-08-07 12:42:44 UTC.


This weekend I spent in bed. "Nice" two days with MOB's code and heat. This is some kind of irony when temperature outside is going down after very long and and very hot July and my head's temperature is going up :)

MOB , Midgard Object Browser became a quite usefull application. I was afraid that snippet's listing hangs mob so I added progressbar and now I know it's just takes too much time. I didn't wanted to keep reading log files for successfull or failed operations , so decided to keep track of any Midgard error in window's statusbar. Now , mob's features are:

  • browse registered classes
  • browse object's tree
  • create new objects
  • edit existing objects
  • delete exisiting objects

I think it's high time to create Midgard subproject for mob, but mob is not good name. Just let me know, if you think you get good name for mob.

Magni

Posted on 2006-08-11 15:53:28 UTC.


MOB has a new name. Magni. And what is more important magni has new home.
I created Midgard's subproject on tigris with hope that this kind of application one may find usefull.

It's not designed to be powerfull all in one application. I just wanted to proof that midgard core became powerfull and it's relatively easy to write midgard library dependant application.

First. Midgard core is not a CMS core, it's just database abstracion layer with authentication mechanism and some built in additional features. Thus , core is not your ideas aware. That's good , because its generic purpose doesn't limit your ideas. So together with other components ,( like midgard-apache module or midgard-php ) it turns into powerfull CMS framework which can be written in any language , like MidCOM is written in PHP.

Second. Just imagine that your favourive PHP ( only PHP ) based CMS which has been developed for last three years begins to be interesting for java community. Imagine that CMS contains 50 000 lines of code. 20 000 is database releated code, another 20 000 creates logic and only 10 000 defines user interface. What java community should do in such case? Write 50 000 lines of java code and be in sync with PHP based development branch. Sounds good? No.
Now imagine that you want to build Your new project with python and Midgard as basement. It's enough then to write python language bindings ( which is done only once ) and focus on Your application. Amount of code which must be written depends on project only. You do not have to worry about anything else.

As a good example, midgard-php bindings part for midgard_collector type:

Execute method:

midgard-core C

MidgardCollector *object;

midgard_collector_execute(object);

/* SQL query is executed and you do not have to worry about it,

even if it's C */

PHP binding Zend ( 1 and 2 )

PHP_FUNCTION(_execute)

{

/* parse parameters and other Zend relaed stuff */

/* ... */
/* Get underlying GObject */

MidgardCollector *object =

(MidgardCollector *) php_midgard_fetch_object(getThis());
/* Invoke method */

midgard_collector_execute(object);

}

And finally midgard-php:

$mc = new midgard_collector(mixed params);

$mc->execute();

The same you can do with java, pyhon, ruby or perl.
I skipped error handling in examples because it's not a point here.

Third. How many database related webDAV services do you know? 5? 10? Maybe 1? With new midgard core it's possible to write native Gnome VFS module and share Midgard content as it could be mounted cd-rom or floppy. How many Gnome or Nautilus plugins have you seen written in PHP?

Another one thing is: if Your favourite CMS is written in PHP and you need for example python small application for it, which could be running on Nokia 770, you must read the second point of this blog. With new midgard core you depend on language bindings only , it doesn't matter if you need KDE or Gnome desktop app. You doesn't have to know if you are going to use MySQL , MS SQL or PosgreSQL. You do not have to know what SQL is. All you have to know is the language you want to write Your app in.

And at the end , imagine this ( it's only theory , but I bet you get the point ):
Your new website is online shop. And what you need is to know when new item has been ordered via website. You do not have POP mail account , so checking every single minute if order is already there is just crazy and without any sense. So what you exactly need is a tray small application which every minute looks for new orders made via website ( exactly like POP mail tray apps ).
Can you do this if Your powerfull CMS is written in PHP? No.
Can you do this with centralized written in C library ( database abstraction layer ) and decentralized applications? Yes , you can.

And ah! Last but not least! How many code do you need to write to create new classes and database "connectivity" for them using PHP or Python? Plenty. How many code must be written with Midgard? None.

Forgive me if that blog entry is too shameless. It's just true.

Exporting MgdSchema objects

Posted on 2006-08-28 11:36:09 UTC.


Midgard CVS HEAD supports nice and quite usefull export method for MgdSchema objects. It is quite simple to export objects on PHP level.

A code example for exporting whole sitegroup ( SG0 in this case ):

foreach ($_MIDGARD['schema']['types'] as $type => $val){
$replication_data_dir = "/some/path"; $qb = new midgard_query_builder($type); $qb->add_constraint("guid", "<>", " "); $ret = $qb->execute();
foreach ($ret as $object){
$filepath = $replication_data_dir."/".$type."_".$object->guid.".xml"; $dump_file = fopen($filepath, 'w'); $xml = $object->export();
if($xml) { fwrite($dump_file, $xml); fclose($dump_file); } else { echo mgd_errstr(); } } unset($object); }

If you try to execute this code twice , you should get MGD_ERR_OBJECT_EXPORTED errno returned for every export method call.

Coming back from vacation

Posted on 2006-08-29 12:07:33 UTC.


Isn't that quite abnormal? I came back from vacation last sunday and first thing I done yesterday was writting about Midgard objects exporting ;)

So , we spent nice week travelling a bit through Świętokrzyskie Mountains.
"A bit" means that on the back seat of your car is 4 years old girl and never stops talking and always wants to go just there where you do not plan to go :)

Few places of interest: Krzyżtopór castle( who's from Sweden and destroyed it? ;), "Jurrasic park"( this is interesting, Ola was very bored there "Are we going to castle now?" ;), Paradise Cave ( unfortunatelly , no one is able to make pictures there ), Piekoszewice ( castle among houses ).

And other interesting things: my daughter is interested in new Apache Foundation logo, completely new spider-admin , and even dead boar is happy.

In other news: Today, I will implement import functionality for Midgard objects, so basic core based replication should be ready tomorrow.

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS