Piotras' blog

Mjolnir - new stable Midgard2 release

Posted on 2009-11-18 15:02:12 EET.

Yes, we did it :)

Here is it latest and greatest Midgard2 stable release.

More flexibility for Midgard schemas

Posted on 2009-10-08 15:36:30 EEST.

Here it is. Well known Midgard MgdSchema is no longer such strict and limited. Since [Mjolnir][2] we will support user defined values which can extend class property even better. Till now, we supported only 'description' keyword, which allowed to add any text which could describe property.

Defining own values is plain and simple:

<type name "my_best_class" table="my_best_class_tbl">
    <property name="superproperty" type="string" field="super_property">
        <foo>bar</foo>
        <private>true</private>  
    </property>
</type>

Now, with API calls, one is able to get it quickly:

C:

MidgardObjectClass *klass = g_type_class_peek (g_type_from_name ("my_best_class"));
MidgardReflectionProperty *mrp = midgard_reflection_property_new (mgd, klass);
midgard_reflection_property_get_user_value (mrp, "superproperty", "private");

Python:

mrp = midgard.reflection_property ("my_best_class")
print mrp.get_user_value ("superproperty", "private")

or even PHP:

$mrp = new midgard_reflection_property ("my_best_class");
echo $mrp->get_user_value ("superproperty", "private");

Note, that I used private key by purpose. If you are developing Midgard derived application and you need some functionality which can be defined in schema (but it's not yet), or work on such functionality is in progress, and you need to make your application be aware of this (quickly), you can depend on self added values.

Python bindings and GObject derived class destructor

Posted on 2009-09-29 21:12:55 EEST.

Tero found interesting memory issue with Midgard2 Python bindings. The code he presented is very simple:

import _midgard as midgard

while True:
    qb = midgard.query_builder ("midgard_host")

Guess, what happens. Memory usage grows up till your machine is frozen. I started to investigate this issue and reproduced problem with different case:

import gobject

class my_memory_test (gobject.GObject):
    def __init__ (self):
        gobject.Object.__init (self)

while True:
    mmt = my_memory_test()

This script kills machine perfectly too.

As Python bindings for Midgard depends on GObject bindings I started to invent own destructor. Finally solution is plain and simple. Instead of derived destructor (the one assigned to tp_dealloc), I added new one:

void
_py_midgard_gobject_destructor (PyObject *self)
{
    PyGObject *pygobj = (PyGObject *) self;
    if (pygobj->obj && G_IS_OBJECT (pygobj->obj))
            g_object_unref (pygobj->obj);

    PyObject_GC_Del (self);
}

Now the question is: does derived class destructor inherits parent class' one if explicitly defined as none? Basic debug statements clearly showed that parent's destructor is invoked but why memory usage grew till death?

No more multilang in Midgard2

Posted on 2009-09-18 14:30:14 EEST.

In brief: I dropped multilang features from Midgard2 core today. Next week, I'll drop sitegroup's ones, which means the whole architecture is going to be simplified a lot. But do not worry, we - Midgard developers - have better plan for missed sitegroups and multilangs : contexts :)

Some vala for Midgard2

Posted on 2009-09-10 11:53:33 EEST.

Recently I decided to start some Midgard2 developing work using vala. I needed to implement simple GLib's GKeyFile wrapper, so vala seemed best choice.

First of all, vala is perfect (and sexy excellent) for boring and time consuming routines like GObject class' macros and standard hooks initialization. But with real, non standard code I started to hit the wall.

GLib.KeyFile

kf.set_comment (group, key, comment);

generates:

g_key_file_set_comment (self->priv->_keyfile, group, key, comment);

Obviosuly error pointer (or NULL) is missed so code won't compile.

kf.get_groups ();

generates:

return (_tmp1 = g_key_file_get_groups (self->priv->_keyfile, &_tmp0), *result_length1 = _tmp0, _tmp1);

&_tmp0 is expected to be size_t so code doesn't compile too.

Those are minor issues as you can always edit autogenerated code and fix bugs. But this is not the point.

GLib.List

GLib.List list = new GLib.List<string> ();
list.prepend (some_string_var);

generates code which doesn't compile cause of self->priv->g_dup_func missed member.

string

I created string array property, like this:

private string[] cfgs;

and constructor:

this.cfgs = new string[0];
this.cfgs = {};

and added more elements:

this.cfgs += some_string_var;

Code compiles and runs but greatly segfaults with 'double free or corruption'

I am using valac 0.5.7-1 on 64bit Ubuntu 9.04. Might be that all issues are on mine side.

Updated:

var arr = new GLib.Array<string> (false, false, (uint)sizeof (string));
arr.append_val (abspath.ndup(abspath.length));

doesn't compile:

error: lvalue required as unary ‘&’ operand

and C code:

g_array_append_val (arr, _tmp7 = g_strndup (abspath, (gsize) string_get_length (abspath)));

Qaiku as Mojito service on moblin

Posted on 2009-07-30 22:22:14 EEST.

Just started to add Qaiku as new Mojito service for Moblin:

I used kvm alpha2-20090311 image, and (unfortunately) haven't been surprised.

  • Had to install many (plenty of) dev(el) packages to start some work
  • Spent some time trying to find out how to install gconf, cause package is named Dbus-Gconf. Uh?
  • No apt-get! (yes, this is personal ;)

When I added Qaiku service, which is available in 'Web services' configuration, I started to wonder how could I start testing it before adding more code. The toolbar is available in Moblin beta release, but it's not in SDK image? Does it mean I should write code using SDK image, package it, install on other device with Moblin installed and test it at last?

So far I understood I should initialize another window manager, but mutter (no idea if it's the correct one) created two squares on my image screen - white and blue one.

Also it would be very nice if Mojito developers could add more authentication types support. You can use traditional username/password authentication for Qaiku but you can use an APIKey as well. I want Qaiku service to use APIKey, so had to define 'username' in Mojito's service, but this one as you see on screenshot is kind of confusing. I bet 99,99999% of users will type their username instead of their unique uuid.

Midgard2 API with Gtk-doc

Posted on 2009-07-08 22:48:57 EEST.

 

Not, a big deal. Many Gnome libraries use Gtk-doc as the tool for API documentation. Midgard is just another one. For long, long time I used Doxygen, but this wasn't good enough, and there are few Gtk-doc features I like very much.

Deprecated symbols are marked nice way in search panel.

 

All libraries in one place.

 

Quick access to new symbols.

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