hi tim. Yes i have already implemented my own implementation. Tho i didnt use 
list properties as many users could be writting to the same entity and 
concurrency issues could begin. Tho i know that a fork-join-queue could be used 
to post the work from a queue. Thanks for the code i will take a look at this 
in 
more detail.

 
Regards
 
 
Martin Webb


 
The information contained in this email is confidential and may contain 
proprietary information. It is meant solely for the intended recipient. Access 
to this email by anyone else is unauthorised. If you are not the intended 
recipient, any disclosure, copying, distribution or any action taken or omitted 
in reliance on this, is prohibited and may be unlawful. No liability or 
responsibility is accepted if information or data is, for whatever reason 
corrupted or does not reach its intended recipient. No warranty is given that 
this email is free of viruses. The views expressed in this email are, unless 
otherwise stated, those of the author 

 
 




________________________________
From: Tim Hoffman <[email protected]>
To: Google App Engine <[email protected]>
Sent: Tue, 21 September, 2010 10:09:50
Subject: [google-appengine] Re: parent relationships

Hi

If you many levels deep you definately need to look at a different
approach. (unless you do want them all in the same entity group.)

I have implemented  non entity group relation ship with the following
basic approach.  Here is just a bit of the code to give you some
ideas.
The whole lot can be found at.  (http://code.google.com/p/bfg-pages/
source/browse/trunk/pages/models.py#406  you will see zope'isms in the
real code)
I plan to add some transaction management around this based on some of
Nick Johnsons articles.

class ContentishMixin(db.Model):

    parent_ = db.ReferenceProperty(collection_name='children_')
    path_elements_ = db.StringListProperty(default=[])
    display_order = db.IntegerProperty(default=5)

    def setParent(self,obj):
        self.parent_ = obj

class FolderishMixin(db.Model):

    children_keys = db.ListProperty(db.Key,default=[])
    children_names = db.StringListProperty(str,default=[])

    def addContent(self,obj,name):

        if name in self.contentNames():
            raise DuplicateName('duplicate name %s'%name)

        self.children_keys.append(obj.key())

        self.children_names.append(name)
        obj.setParent(self)
        obj.path_elements_ = self.path_elements
        obj.put()

        self.put()

    def __getitem__(self,name):

        name = unquote(name))

        if name in self.children_names:
            idx = self.children_names.index(name)
            result = self._get(self.children_keys[idx])
            result.__parent__ = self
            return result
        else:
            raise KeyError(name)

    def __contains__(self,name):
        if name in self.children_names:
            return True
        else:
            return False

There is no transactions around any of this so if you have multiple
concurrent addContent calls to the same folder you will run into
trouble.

T


On Sep 21, 4:52 pm, Martin Webb <[email protected]> wrote:
> @tim
>
> If i do need to store children with in children - and if i have childs that
> could run to say one level but perhaps 500-1000 entities is it best to use a
> different aproach?
> Thinking about this i do need to store children with-in children so it sounds
> like i would have a problem getting the right level etc.
> Am i correct.
>
> Regards
>
> Martin Webb
> The information contained in this email is confidential and may contain
> proprietary information. It is meant solely for the intended recipient. Access
> to this email by anyone else is unauthorised. If you are not the intended
> recipient, any disclosure, copying, distribution or any action taken or 
omitted
> in reliance on this, is prohibited and may be unlawful. No liability or
> responsibility is accepted if information or data is, for whatever reason
> corrupted or does not reach its intended recipient. No warranty is given that
> this email is free of viruses. The views expressed in this email are, unless
> otherwise stated, those of the author
>
> ________________________________
> From: Tim Hoffman <[email protected]>
> To: Google App Engine <[email protected]>
> Sent: Tue, 21 September, 2010 9:34:23
> Subject: [google-appengine] Re: parent relationships
>
> Hi
>
> On Sep 21, 3:52 pm, Martin Webb <[email protected]> wrote:> Hi is it 
>possible to add a entity of a model with a parent set to a key or
> > another entity of the same model class.
>
> Parents can be any entity class.
>
> > If so; does this make finding the
> > siblings easier? If i load the parent or the sibling (child) is it easier to
> > find the relating party(s).
>
> Yes, if you only have one level of children below the parent. Children
> within in children will mean you will get all children when doing a
> straight ancestor query.
>
> Remember you are also creating an entity group.  So make sure you
> don't create  huge tree with a single parent ;-)
>
> T
>
>
>
> > Regards
>
> > Martin Webb
>
> > The information contained in this email is confidential and may contain
> > proprietary information. It is meant solely for the intended recipient. 
>Access
> > to this email by anyone else is unauthorised. If you are not the intended
> > recipient, any disclosure, copying, distribution or any action taken or
> omitted
> > in reliance on this, is prohibited and may be unlawful. No liability or
> > responsibility is accepted if information or data is, for whatever reason
> > corrupted or does not reach its intended recipient. No warranty is given 
that
> > this email is free of viruses. The views expressed in this email are, unless
> > otherwise stated, those of the author
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group 
>athttp://groups.google.com/group/google-appengine?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.


      

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to