If you only need some of these images some of the time
I would actually create a AvatarImage class
which has a blob property, image sizes, formats etc....
And an AvatarImageReference class
E.g (note code is not exact, there are typos etc... but you will get
the point)
class AvatarImageReference
avatar = ReferenceProperty(Avatar,collection_name="images")
image = ReferencePropery(AvatarImage)
image_type = StringProperty # put small, medium, large in this
And your avatar class as below minus any references to images
You can then get a all image references defined for the avatar with
myavatar.images
fetch each image with
for i in myavatar.images:
i.image
or filter images on size etc...... by looking at image type
That way you wont fetch an image unless you really need it
Rgds
T
On Sep 19, 5:57 am, Larkin2 <[email protected]> wrote:
> I have a three models for images:
>
> class SMALLAVATARS(db.Model,):
> author = db.UserProperty()
> phrase = db.ReferenceProperty(PHRASES)
> file = db.BlobProperty(default=None)
> creationDate = db.DateTimeProperty(auto_now_add=True)
> editDate = db.DateTimeProperty(auto_now=True)
>
> class MEDIUMAVATARS(db.Model,):
> author = db.UserProperty()
> phrase = db.ReferenceProperty(PHRASES)
> file = db.BlobProperty(default=None)
> creationDate = db.DateTimeProperty(auto_now_add=True)
> editDate = db.DateTimeProperty(auto_now=True)
>
> class LARGEAVATARS(db.Model,):
> author = db.UserProperty()
> phrase = db.ReferenceProperty(PHRASES)
> file = db.BlobProperty(default=None)
> creationDate = db.DateTimeProperty(auto_now_add=True)
> editDate = db.DateTimeProperty(auto_now=True)
>
> Is this optimal or would using a single model such as:
>
> class AVATARS(db.Model,):
> author = db.UserProperty()
> phrase = db.ReferenceProperty(PHRASES)
> small = db.BlobProperty(default=None)
> medium = db.BlobProperty(default=None)
> large = db.BlobProperty(default=None)
> creationDate = db.DateTimeProperty(auto_now_add=True)
> editDate = db.DateTimeProperty(auto_now=True)
>
> be better?
>
> Obviously the later is nice and simple, but I'm concerned that when I
> go to actually get the entity in question I will unnecessarily eat up
> more system resources if I only need one of the three images?
>
> As always, input is greatly appreciated!
>
> -Larkin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---