[Cubicweb] Link or merge two instances?

Florent Cayré florent at secondweb.fr
Mon Dec 6 17:55:08 CET 2010


Hi John,

If you just want to inject data from one instance into the other, you can
use very simple dump / reload scripts :

cubicweb-ctl shell CARDINSTANCE

import pickle
cards = []
out = file('/tmp/out.pickle', 'w')
for card in rql('Any C WHERE C is Card').entities(0):
  cards.append({'title': card.title, 'synopsis': card.synopsis, 'content':
card.content, 'wikiid': card.wikiid})
pickle.dump(cards, out)
out.close()

Then something like this to reimport in the other : cubicweb-ctl shell
OTHERINSTANCE import_data.py, with import_data.py being like :

import pickle
cards = pickle.load(file('/tmp/out.pickle'))
for card in cards:
  rql('INSERT Card C: C title %(title)s, C synopsis %(synopsis)s, C content
%(content)s, C wikiid %(wikiid)s', card)

Hope this helps,
Regards,
Florent.

2010/12/6 Nicolas Chauvat <nicolas.chauvat at logilab.fr>

> On Mon, Dec 06, 2010 at 02:38:32PM +0000, Fletcher, John P wrote:
> > 3.       Merge them so that the 20 cards are in the intranet.
> >
> > I favour (3) but lack information how to do it.  This would enable me to
> enrich it (with tags etc).
>
> This is called multi-source (option A) or datafeed (option B).
>
> Option A
> --------
>
> The cubicweb server can handle more than one source of data. You can
> for example configure it to transparently get data made available by
> other cubicweb servers.
>
> You need to add a source section to your etc/cubicweb.d/sources
> config, for example:
>
>  [otherdb]
>  adapter=pyrorql
>  pyro-ns-group=cubicweb
>  pyro-ns-id=otherdb
>  pyro-ns-host=some.host.net
>  mapping-file=mapping_here_other.py
>  cubicweb-user=admin
>  cubicweb-password=apassword
>  base-url=http://myotherapp.com/
>
> with etc/cubicweb.d/mapping_here_other.py:
>
>  support_entities = {'Card': True, }
>  support_relations = {}
>  dont_cross_relations = set()
>
> Do not forget to turn on pyro on both instances.
>
> Option B
> --------
>
> Is in development and does not really work for cards at the moment,
> but you can have a look at the blog cube for an example.
>
> http://hg.logilab.org/cubes/blog/file/503cdf0700a4/sobjects.py
>
> The idea is that you register parsers for different file formats and
> datafeed will use these parsers to import data into your instance.
>
>
> Conclusion
> ----------
>
> I am probably being a bit too terse for you to get this to work. What
> is your next question ? :)
>
> --
> Nicolas Chauvat
>
> logilab.fr - services en informatique scientifique et gestion de
> connaissances
> _______________________________________________
> Cubicweb mailing list
> Cubicweb at lists.cubicweb.org
> http://lists.cubicweb.org/mailman/listinfo/cubicweb
>



-- 
Ce message est la propriété de SecondWeb et peut contenir des informations
confidentielles. Si vous n'êtes pas le destinataire désigné, nous vous
remercions de bien vouloir nous en aviser immédiatement et de nous retourner
ce message ou de le détruire, sans faire un quelconque usage de son contenu,
ni le communiquer ou le diffuser, ni en prendre copie, électronique ou non.

This message is the property of SecondWeb and may contain confidential
information. If you are not the designated recipient, please notify us
immediately and return the message to us or destroy it, without making any
use whatsoever of the contents thereof. Furthermore you should not forward
or copy the message by electronic or other means.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20101206/3bfa835f/attachment.htm>


More information about the Cubicweb mailing list