Hi, I was thinking that instead of introducing a new notation, we might add a parameter like "objectCreationPolicy=update|updateOrCreate|...". If this parameter is not present everything works as today. If this parameter is present we might choose what to do. So it's up to the user to decide what to put there. The object editor, for example, would put objectCreationPolicy=updateOrCreate and use the standard notation to send POST data. Objects will be updated or created according to the fact that they already exists or not. The only problem I foresee are race conditions between create/update behaviour depending on multiple users editing the same page... Today we have locks that should prevent this. In the future I don't know - but I guess even the current behaviour is problematic from this point of view. Thanks, Fabio On Thu, Apr 10, 2014 at 12:00 PM, Jean SIMARD <[email protected]> wrote:
Yes, I won't know if it's updated or created.
Now, using 'XWiki.XWikiRights_users = XWiki.Me' would not be sufficient for the use case; what happens if you want to create 2 objects 'XWiki.XWikiRights'?
Can we imagine to introduce a new notation to explicitly mean that you want to create a new object, like 'new_XWiki.XWikiRights_0_users' or 'XWiki.XWikiRights_new_0_users' or 'XWiki.XWikiRights_n0_users'?
This way, we can filter as following: * If you try to update an object with 'XWiki.XWikiRights_0_users' and the object #0 exists, the property is updated (use case already existing) * If you try to update an object with 'XWiki.XWikiRights_0_users' and the object #0 doesn't exist, the parameter has no effect (use case already existing) * If you try to create an object with 'new_XWiki.XWikiRights_0_users' and the object #0 exists, the parameter has no effect * If you try to create an object with 'new_XWiki.XWikiRights_0_users' and the object #0 doesn't exist, the object is created and the property initialized
Thanks -- Jean
On jeu., 2014-04-10 at 11:59 +0300, Marius Dumitru Florea wrote:
So if I put XWiki.XWikiRights_56_users on the request and there's no rights object what do you do? Create an object with number 0? Create an object with number 56? And if you want to add a new object how would you know the object number to put on the request so that you don't update existing objects instead?
The current behaviour is this:
1) You ask the system to add a new object (i.e. allocate an object number) using the object add action, possibly passing property values like this
XWiki.XWikiRights_users = XWiki.Me
2) You use the allocated number to update the object, passing property values like this
XWiki.XWikiRights_N_users = XWiki.Me
where N is the allocated object number.
What you want is to do this in a single step, but you won't know/control if the object is added or updated.
Thanks, Marius
On Thu, Apr 10, 2014 at 11:36 AM, Jean SIMARD <[email protected]> wrote:
Hi devs,
In XWiki, if you send a POST request at the following URL ('MySpace.MyPage' is a document that doesn't exist at the moment)
/bin/save/MySpace/MyPage
with the following HTTP parameters:
* template=MySpace.MyTemplate * XWiki.XWikiRights_0_users=XWiki.Me * <others parameters>
with 'MySpace.MyTemplate' a template document and 'XWiki.Me' a user of the wiki.
2 cases:
1. If 'MySpace.MyTemplate' contains a 'XWiki.XWikiRights' object, then the resulting document 'MySpace.MyPage' will have this object with its property 'users' initialize with the value 'XWiki.Me' (see HTTP parameters) 2. If 'MySpace.MyTemplate' does not contain a 'XWiki.XWikiRights' object, the resulting document 'MySpace.MyPage' will not contain it either
### PROPOSAL Create automatically the objects if they don't exist in the template document. ###
To make it possible, it seems that we would need to refactor the method 'readObjectsFromForm(EditForm, XWikiContext)' in the 'com.xpn.xwiki.doc.XWikiDocument' class. And probably modify also the 'getObject(String)' from 'com.xpn.xwiki.web.EditForm' class.
2 things to take care: * It seems there is no unit test for these methods. * May this proposal be a security problem?
WDYT? -- Jean
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs