Piotras' blog: Archive

2007-09-01 - 2007-09-30

Getting fat

Posted on 2007-09-19 08:18:15 UTC.

I must say it. All of you who still used to smoke cigarettes. Quit it now! I do not smoke for last three weeks and I hope it's the last time I quit with this awfull addiction. Though, first days with morning coffe without cigarette has been not nice....

And I must tell you one thing.

It's not true that you getting fat when you are quiting....

Last but not least , I decided to use patches.

datagard or coffee break

Posted on 2007-09-21 11:18:39 UTC.

So, you wanted to test latest Midgard?

  • Make Your favourite coffee or tea
  • Download it from nightly builds and compile.
  • Run datagard

    /usr/sbin/datagard

  • Give MySQL's admin password when asked for it

    Preparing to create database with default admin account 'root'

By default, you may just press enter. Yes, you drink your coffee so no need to make anything much more difficult.

  • Be patient, datagard is performing many tasks now.
  • Mmmm... What a delicious coffee... Do not forget. Do not smoke while drinking
  • Give hostname if asked for it

    Hostname to use ? (yourhostname):

  • Press enter if datagard did the trick and suggested correct name

  • Stop and start apache
  • Point Your favourite browser to http://yourhostname

Current issue is style not being associated with page and host, and the fact that I can not find any style or page elements imported to database. But hey! It's not even alpha quality :)

Working datagard

Posted on 2007-09-24 11:02:43 UTC.

I wrote about datagard on friday, and today I finally got it working almost as much as I expected. I know you probably know this Midgard template , but this one is unusual because I did hit Enter key only twice during installation.

The first one to invoke:

sudo /usr/sbin/datagard

The second to confirm empty password used for MySQL's admin acount.

Still , I needed to stop and start apache, but this will be fixed soon.

dataragd and replication

Posted on 2007-09-25 09:35:09 UTC.

Did I wrote something new about datagard yesterday? Whatever it is , it is old ;)

So... what happened since last morning?

I added support to reload apache's httpd server when new virtual host is successfully created. It's obviously two command less when datagard stops.

Today, early morning, Bergie suggested yet another cool feature. Why to ask user for MySQL's admin password, if server might be not secured by this? Quite easy as an idea , but I found it difficult to implement. Mainly ( no no, only because of it ) because php's exec function doesn't fill user's array with all data which are returned by executed command.

Docs clearly states:

"If the output argument is present, then the specified array will be filled with every line of output from the command"

But this:

$retval = 0;
$output = array();
exec($somecmd, &$output, &$retval);

Doesn't work as you would like to expect. $output is always an empty array. Anyway, I decided to use wild "convention", and I try to create database without password and when it fails I ask user for password. Not nice , but better than nothing for a start...

Also I added validation checks for midgard_setup_config which initially tries to "detect" if every single constant or class exists or is usefull in our case. Most of these are checked during configure script, but few times I "managed" to run datagard which changed permission with empty user and group name. Though , those passed correctly during package's configure.

And most sexy part of last changes. Midgard database provides predefined list of languages, so I had no other choice and implement replication support :) midgard_replicator requires much more love, but some missed features can be work arounded easily.

It's sample script to create one xml for more than 100 objects.

$midgard = new midgard_connection();
$midgard->open("my_configuration");

$qb = new midgard_query_builder("midgard_language");
$ret = $qb->execute();

$big_xml = "<?xml";

$xml_root = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$xml_ns = "<midgard_object  xmlns=\"http://www.midgard-project.org/midgard_object/1.8\">";
$xml_ns_end = "</midgard_object>";

$xml_data = "";

foreach($ret as $lang) {

    $xml = midgard_replicator::serialize($lang);
    $xml = str_replace($xml_root, "", $xml);
    $xml = str_replace($xml_ns, "", $xml);
    $xml = str_replace($xml_ns_end, "", $xml);

    $xml_data .= $xml;
}

$big_xml = $xml_root.$xml_ns.$xml_data.$xml_ns_end;

file_put_contents("languages.xml", $big_xml);

You can import this file with import_from_xml method, once it's written. And so, datagard does it to give you more than 180 ready to use languages.

Back

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