Macro execution at the page save time.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro execution at the page save time.

kgardas

Hello,

I'm working on semantic extension for XWiki[1][2] and currently on
performance tunning to be ready for scaling up. The problem with current
implementation is that it always modifies semantics DB on all page
views. E.g. when I do have a page with

{{semProp value="http://purl.org/dc/elements/1.1/title::The Hobbit"/}}

to define property 'title' to value 'The Hobbit', this macro basically
saves this knowledge to the DB everytime the page is viewed which is
obvious performance killer. Of course there is a possibility to optimize
this call to first check if the property is already defined and if not,
do nothing, but it's still not the best.

What I think I'd like to do is to kind of check if the pages is saved or
viewed and based on this semProp will do its job (during page save) or
will do nothing (during page view).

Now, my question is if something like that is possible since I've not
found any hints about it so far.

Thanks!
Karel

[1]: http://extensions.xwiki.org/xwiki/bin/view/Extension/Semantic+XWiki
[2]: https://github.com/kgardas/semxwiki
_______________________________________________
devs mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/devs
Reply | Threaded
Open this post in threaded view
|

Re: Macro execution at the page save time.

Marius Dumitru Florea
Hi Karel,

I wouldn't put the knowledge save logic in the semProp macro itself
but rather in an event listener that catches the document save event.
The listener can retrieve all occurrences of the semProp macro from
the document content XDOM and save the corresponding semantic
properties in the knowledge DB.

See http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingEventListenerTutorial
.

Hope this helps,
Marius

On Thu, Jun 12, 2014 at 6:22 PM, Karel Gardas <[hidden email]> wrote:

>
> Hello,
>
> I'm working on semantic extension for XWiki[1][2] and currently on
> performance tunning to be ready for scaling up. The problem with current
> implementation is that it always modifies semantics DB on all page views.
> E.g. when I do have a page with
>
> {{semProp value="http://purl.org/dc/elements/1.1/title::The Hobbit"/}}
>
> to define property 'title' to value 'The Hobbit', this macro basically saves
> this knowledge to the DB everytime the page is viewed which is obvious
> performance killer. Of course there is a possibility to optimize this call
> to first check if the property is already defined and if not, do nothing,
> but it's still not the best.
>
> What I think I'd like to do is to kind of check if the pages is saved or
> viewed and based on this semProp will do its job (during page save) or will
> do nothing (during page view).
>
> Now, my question is if something like that is possible since I've not found
> any hints about it so far.
>
> Thanks!
> Karel
>
> [1]: http://extensions.xwiki.org/xwiki/bin/view/Extension/Semantic+XWiki
> [2]: https://github.com/kgardas/semxwiki
> _______________________________________________
> devs mailing list
> [hidden email]
> http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/devs