Hi Vincent, On Wed, Mar 6, 2013 at 11:36 AM, Vincent Massol <[email protected]> wrote:
> Resending since I've made mistakes (it's only about ObjectReference, not > Properties), sorry about that. Here's the new version: > > ------------ > > Hi devs, > > ATM in the model module there's no ability to reference an xobject other > than by using a free form name. We made this on purpose. > The problem is that this is not really usable. This is why we introduced > the BaseObjectReference in oldcore. > We have introduce the BaseObjectReference in oldcore simply to easily support the current storage implementation. At that time, we had a discussion about using the object number (not to be confuse with the index) or the object UUID. And, since the object UUID was suspicious in some edge case, you convince me to use the object number to create the free form name of these old objects (I should have resist more since I still do not have evidence of these edge case). > However this is major PITA since we can't have clean code that create an > object reference and that doesn't depend on oldcore. > Creating a reference to the third object of a given class in a document (or object number 3, or even the third object of a document) has absolutely no meaning unless you have already that object at hand, and so you already have a source for its reference (solved not nicely by the BaseObjectReference actually, but this was another story). > I'd like to propose the following: > * Modify ObjectReference to add 2 named parameters: Class reference and > position > Since position is really fragile without any real meaning, having a reference using a position will be a source for spurious issues, I am definitely -1 for any positional reference. > * Make the name optional in EntityReference > This sounds like a sign of bad design to me... what is a entity without a name in general ? > This means that when we use an EntityReferenceResolver to resolve > "wiki:space.page^wiki2:space2.page2" we get an ObjetReference with: > * name = null > * param1: name = "classReference", value = EntityReference > * param2: name = "objectPosition", value = 0 > > Rationale: > * This is exactly what we already do for Locale (and what we'll do for > Version too probably) so it's logical to do it for Object References too > I agree with your sample and your rationale, there is a need to create a reference to the first (and probably the only for such use case) object of a given class in a given document without having to compose weird names or positional references. This has definitely a meaning, much more than the second or any numbered objects... And this object is not always "[0]" in base reference syntax ! However, resolving "wiki:space.page^wiki2:space2.page2" to that object is not valid, since you do not really know what you are doing here, are you speaking about the first object of a given class or an object named " wiki2:space2.page2" ? So if we need to resolve a string into the first (or, even if I am against, any) object of a given class, we need another syntax at least (BaseObjectReference had already cause some poor stuff in LocalUidReferenceSerializer where we had to remove wiki in a very bad way currently). > Consequences: > * We need to modify the Seralizers/Resolvers accordingly > According we have a new syntax for your kind of object reference, we may do so. I resolver/serializer (as well as setter of class reference) I suggest like Thomas that we support relative reference to classes based on the containing document, both simplifying creation and avoiding useless repetition. > * We need to modify EntityReference to support a null name > Do we really need that, or the name would simply reflect our special syntax ? > * We deprecate BaseObjectReference > Does it really true ? It does not have the same meaning (even for your initial proposal) since number and position are not the same and the BaseObjectReference is a special reference, not a general object reference, since it does not have a real free form name. Deprecating means we had to replace them everywhere, and I am not sure it is easy to use index in place of number in some places, like storage where we use reference for IDs. > * Probably some other stuff to modify like modifying event listeners > listening on objects since it's now going to be much easier, etc > > WDYT? > So, to resume, I understand the need to have a way to create reference to the first object of given class in a document. Even if using an object reference with, let say a special syntax, will introduce some bad consequences on the implementation of equals and related methods on entity reference (like those we have for locale or version), we should probably consider it (Note that it will also affect property reference). I am definitely -1 for any positional reference which are meaningless. Thanks, > > Thanks > -Vincent > _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

