Midgard2 - Content Repository for mobile applications
-
Upload
henri-bergius -
Category
Technology
-
view
2.322 -
download
1
description
Transcript of Midgard2 - Content Repository for mobile applications
![Page 1: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/1.jpg)
Midgard2
Content repository for mobile applications
![Page 2: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/2.jpg)
HenriBergius
Microblogs: @bergiehttp://bergie.iki.fi
![Page 3: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/3.jpg)
Content Repository
Don't invent your own file formats
![Page 4: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/4.jpg)
Content Repository
Objects instead of SQL
![Page 5: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/5.jpg)
Content Repository
Objects instead of SQL
http://xkcd.com/327/
![Page 6: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/6.jpg)
Content Repository
Signals about changes
![Page 7: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/7.jpg)
Content Repository
Data model is scriptable
![Page 8: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/8.jpg)
Content Repository
Synchronization and sharing
![Page 9: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/9.jpg)
With a content repositoryincredible power is at your disposal
![Page 10: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/10.jpg)
Free Content Repositories
• Schema-based, relational
• Query Builder
• C, glib, libgda
• LGPL
• D-Bus signals
• Library
midgard2.org
• Schema-free
• Javascript map/reduce
• Erlang
• Apache License
• JSON polling via HTTP
• Daemon
couchdb.apache.org
![Page 11: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/11.jpg)
...and they talk to each other
![Page 12: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/12.jpg)
The Midgard Project• Object-Relational
Mapping, trees, D-Bus signals
• APIs for C, PHP, Python, Vala, Objective-C, ...
• Linux, Mac, Maemo
• Free software project since 1999
• Contributors from most European countries
• Synchronized release model, every 6 months
![Page 13: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/13.jpg)
Midgard on Maemo 5
Conboy: notes on your phone
![Page 14: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/14.jpg)
Midgard on Maemo 5
Workstreamer: project tracking for N900
![Page 15: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/15.jpg)
Midgard on the web
Qaiku.com: conversational microblogging
![Page 16: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/16.jpg)
Getting started with Midgard
![Page 17: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/17.jpg)
Installation
• Linux distribution repositories (Ubuntu, Debian, RHEL, OpenSuse etc) on OBS: http://download.opensuse.org/repositories/home:/midgardproject:/mjolnir/
• After that Midgard is just an apt-get install python-midgard2 or apt-get install php5-midgard2 away
• Maemo 4 and 5 available in Extras Devel (soonExtras)
• On OS X use MacPortsor the ObjC bundle
![Page 18: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/18.jpg)
Objects are defined by MgdSchema<!-- This will be installed to /usr/share/midgard2/schema/ --><type name="midgard_person"> <property name="id" type="unsigned integer" primaryfield="id"> <description>Local non-replication-safe database identifier</description> </property> <property name="firstname" type="string" index="yes"> <description>First name of the person</description> </property> <property name="lastname" type="string" index="yes"> <description>Last name of the person</description> </property> <property name="birthdate" type="datetime"> <description>Birth date of the person</description> </property> <property name="email" type="string" index="yes"> <description>Email address of the person</description> </property></type>
![Page 19: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/19.jpg)
Midgard API for PHP<?php// Load the Midgard2 API extensiondl('midgard2.so');
// Set up the repository config$config = new midgard_config();$config->dbtype = 'SQLite';$config->database = 'midgardexample';// this will store to SQLite in ~/.midgard2/data/midgardexample.db
// Open a Midgard repository connection$midgard = midgard_connection::get_instance();$midgard->open_config($config);
// Prepare storage for your datamidgard_storage::create_base_storage();midgard_storage::create_class_storage('midgard_person');
![Page 20: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/20.jpg)
Midgard API for PHP// Create a new person object$person = new midgard_person();$person->firstname = 'Leif';$person->lastname = 'Eriksson';$person->create();
// Query system for all persons with lastname "Eriksson"$qb = new midgard_query_builder('midgard_person');$qb->add_constraint('lastname', '=', 'Eriksson');$persons = $qb->execute();foreach ($persons as $person){ echo "{$person->lastname}, {$person->firstname} has GUID {$person->guid}\n"; // Add an email address and update $person->email = '[email protected]'; $person->update();}
![Page 21: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/21.jpg)
import antigravity
http://xkcd.com/353/
![Page 22: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/22.jpg)
import antigravity# Load the Midgard2 API extensionimport _midgard as midgard
# Set up the repository configconfiguration = midgard.config()configuration.dbtype = 'SQLite'configuration.database = 'midgardexample'# this will store to SQLite in ~/.midgard2/data/midgardexample.db
# Open a Midgard repository connectionconnection = midgard.connection()connection.open_config(configuration)
# Prepare storage for your datamidgard.storage.create_base_storage()midgard.storage.create_class_storage('midgard_person')
![Page 23: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/23.jpg)
Midgard API: PHP vs. Python// Create a new person object$person = new midgard_person();$person->firstname = 'Leif';$person->lastname = 'Eriksson';$person->create();
// Query system for all persons with // lastname "Eriksson"$qb = new midgard_query_builder('midgard_person');$qb->add_constraint('lastname', '=',
'Eriksson');$persons = $qb->execute();foreach ($persons as $person){ echo "{$person->lastname},”
. ” {$person->firstname}”
. “ has GUID {$person->guid}\n"; // Add an email address and update $person->email = '[email protected]'; $person->update();}
# Create a new person objectperson = midgard.mgdschema.midgard_person()person.firstname = 'Leif'person.lastname = 'Eriksson'person.create()
# Query system for all persons with # lastname "Eriksson"qb = midgard.query_builder('midgard_person')qb.add_constraint('lastname', '=', 'Eriksson')persons = qb.execute()for person in persons: print "%s, %s has GUID %s" \ % (person.lastname, person.firstname, \ person.guid) # Add an email address and update person.email = '[email protected]' person.update()
![Page 24: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/24.jpg)
Oh, and Vala too!/* valac --debug --pkg midgard2 -o midgard-vala-example example.vala --vapidir=./ */using GLib;using Midgard;namespace MidgardValaExample {
void main() {Midgard.init();
Midgard.Config config = new Midgard.Config();config.read_file ("midgard_test", true);Midgard.Connection cnc = new Midgard.Connection();cnc.open_config (config)
Midgard.Object person = new Midgard.Object (cnc, "midgard_person", null);person.set ("firstname", "Leif");if (person.create()) {
string guid;person.get ("guid", out guid);GLib.print ("Created new person identified by GUID %s \n", guid);
}
![Page 25: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/25.jpg)
any tools you use, Midgard is there
![Page 26: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/26.jpg)
...maybe even in your finger
![Page 27: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/27.jpg)
How about Qt?
• Midgard already works in PySide applications
• Would be great to have proper Qt support
• Anybody want to help with this?
![Page 28: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/28.jpg)
Tree access
• Parent-child relations• get_parent()• list_children()
• Access via named paths• get_by_path()
![Page 29: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/29.jpg)
Extending objects
• Subclasses in MgdSchema<type name="bossa_attendee" extends="midgard_person"> <property name="likesbeer" type="boolean" default="true" /></type>
• Ad-hoc additional propertiesobject.set_parameter('bossa', 'key', 'value')value = object.get_parameter('bossa', 'key')
• Binary attachments are also supported• Metadata in repository, file in filesystem• API provides access to filehandles
![Page 30: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/30.jpg)
Midgard MVC
Put your content repository on the web
![Page 31: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/31.jpg)
Midgard MVC
• Very efficient MVC framework for PHP
• Python and D-Bus for background processing
• Gettext + intl i18n• TAL templating• Full WebDAV support• Git for packaging and
deployment
![Page 32: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/32.jpg)
Midgard MVC
Tomboy web synchronization with Midgard
![Page 33: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/33.jpg)
Midgard Runtime
![Page 34: Midgard2 - Content Repository for mobile applications](https://reader034.fdocuments.in/reader034/viewer/2022052619/55669f45d8b42acd288b48e8/html5/thumbnails/34.jpg)
Explore the possibilities of content repositories
midgard2.org #midgard on FreeNode @MidgardProject