[google-appengine] Google User as an Expando

2011-12-09 Thread Rein Petersen
Hey, wouldn't it be nice if Google's User class were an expando that I 
could add properties. Otherwise it seems I have to keep a reference to 
their User object in my own User model. Can anyone offer an elegant way to 
extend Google's User object(model?) ?

Thanks in advance :) 

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/qwfXD94GlzEJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: Polymodels - immutable or mutable?

2010-11-29 Thread Rein Petersen
I have found it accessible in IE8 but doesn't quite work as well as FF
or Chrome - expecting better things from IE9 and prepared to drop
support for the browser entirely if they don't.

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



Re: [google-appengine] Polymodels - immutable or mutable?

2010-11-29 Thread Rein Petersen
Robert,


Thanks for saving me a bunch of time in discovering that Polymodel
class field is unchangeable - I will take your word for it because I am
too lazy to do the testing ;)


I like your idea for using Expando - I will probably go that route
unless my Expando class has to inherit from a PolyModel class - then I
am back to square one and will have to dig up the source on PolyModel
and discover why the class field is unchangeable and how I might
overcome that.


Thanks again
Rein

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



[google-appengine] Polymodels - immutable or mutable?

2010-11-28 Thread Rein Petersen
Hi all, looking for some guidance here...

I often find myself using inheritance in such a way that it also
indicates state. For example, we might have a PlacedOrder class that
will go through an approval process before it becomes the more
specialized ApprovedOrder class. The ApprovedOrder class is still a
PlacedOrder and maintains all the same attributes while adding a few.

The problem comes when classes are immutable - you have to create the
new class, copy all the attributes, then destroy the old - thats a
drag. I would much prefer to just change the class type then fill in
the outstanding attributes. Polymodel, to me, seems to be mutable in
that way and I just wanted to get some advice and opinions about it
before I charge ahead...

Thanks in advance, Rein

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



Re: [google-appengine] Polymodels - immutable or mutable?

2010-11-28 Thread Rein Petersen
Thanks Jeff,

You're right - the way you have described is the way I should do it.
But something bothers me about not being able to model relationships
and state using inheritance. When I think about the problem domain, I
really do want to model it the way I have described. I have achieved it
on the client, in javascript, using __proto__ (you can hear the gasps
of disgust) and it works great although undocumented and not permitted,
in general, for that reason.

When I was looking at the composition of the polymodel, it became clear
that I could probably manipulate it's 'class' field to change it's type
(at serialization to the db), without actually changing the type (in my
case python). Afterwards, the next deserialization results in the new
type.

I know it breaks the rules but I actually haven't seen any rules that
expressly say that I cannot change an object's type - in python or
javascript or in OOP - maybe I just haven't done enough reading.

Rein

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



[google-appengine] Re: Polymodels - immutable or mutable?

2010-11-28 Thread Rein Petersen
It turns out that after listening to advice and doing some more reading
that I have corrections to make and an admission that what I have
suggestied is probably a bad idea (although there is a strong
likelihood I will do it anyway). I found in Python documentation that
an object's type may not be changed although what I am proposing is
changing a class property that will change the Polymodel object's type
at serialization, not during runtime.

Digging into Javascript on the subject suggests that it is a
dynamically-typed language in that you may bound and unbound a variable
from one object of one type to another object of another type. I
suppose you can call that dynamic typing but the way I have proposed
doing it (which works for me in the latest generation of browsers), is
undocumented and clearly an internal variable not intended for general
usage.

Searching around OOP information hasn't yielded any definitive
information on the subject so I can't really decide if this is probably
just a risky practice to achieve an end or if it is unwise and
unrecommended as well.

The correction: my subject line didn't really describe the subject
well... of course Polymodels are mutable - of course you can change
it's attributes. Rather I would have preferred the subject line to have
been Polymodel class type - mutable?

I just want to end saying that if you are reading this post - please
don't think that I am endorsing the use of javascript __proto__ to
change a type, nor the class property of the Polymodel to change type -
it is very likely a bad idea (even though I am going to do it anyway).

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



[google-appengine] Re: XMPP message types

2010-05-18 Thread Rein Petersen
It would be really cool if headline and error message stanza types
were supported...

if anyone else feels the same and wants to support the feature
request, please visit

http://code.google.com/p/googleappengine/issues/detail?id=3236

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



[google-appengine] XMPP message types

2010-05-14 Thread Rein Petersen
Hi, I'm interested if there may be future support for handling XMPP
message of any type. Why is it restricted to only chat and normal?
Thanks, Rein

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



[google-appengine] gae user groups

2009-11-13 Thread Rein Petersen
Hi All,
I've been wanting to organize my users into groups and apply
permissions to handlers for certain group membership but I find the
functionality absent in the SDK. I've investigated using other group
membership models (Iike google groups :
http://groups.google.com/group/google-appengine/browse_thread/thread/c5f95212f27abbd2/1e6e5a0590d1b6c4?lnk=gstq=user+group+membership#1e6e5a0590d1b6c4
) but there is no API.

I've also considered using group membership in google mail api but i
would still have to build in my own permissions. would much rather see
group membership as part of GAE and be able to markup app.yaml with
something like:

- url: /criteria/.*
  script: criteria.py
  login: admin, myusergroup1, myusergroup2

Is anything like this already being considered or is it worth
consideration?

Thanks, Rein

--

You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=.




[google-appengine] @login_required

2009-11-13 Thread Rein Petersen
The sdk documentation reports:


@login_required

A Python annotation for webapp request handler methods that
verifies that the user is signed in with a Google account, and
redirects the user to the sign-in page if not signed in. The sign-in
page redirects back to the request URL.

This annotation only works for GET requests.


Is this really the case? Why only GET requests? Somebody please tell
me that it can decorate POST, UPDATE, and DELETE as well and they just
forgot to update the sdk...

--

You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=.




[google-appengine] Re: @login_required

2009-11-13 Thread Rein Petersen
Correction:
 Somebody please tell me that it can decorate POST, *PUT*, and DELETE as well 
 ...

--

You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=.




[google-appengine] Re: ReferenceProperty troubles

2009-04-01 Thread Rein Petersen

Maybe a bit of pared down code will help get a response for this
problem:

from google.appengine.ext import db

class exModel(db.Model):
  state = db.ReferenceProperty()
  name = db.StringProperty()
  @classmethod
  def forEncode(self):
baseDct = {name:self.name}
if self.state: baseDct[state] = self.state.forEncode()
return baseDct

class exStateModel(db.Model):
  desc = db.StringProperty()
  @classmethod
  def forEncode(self):
return {desc:self.description }


The line [ baseDct[state]:self.state.forEncode() ] found in the
forEncode method of exModel coughs up this:

AttributeError: 'ReferenceProperty' object has no attribute
'forEncode'

i get a similar error asking for any attribute. i just can't get at
the instance or anything about like the documentation demonstrates.
And i know its there, i confirmed it using the data viewer and the
reference and referenced instance are there... help me before i blow a
gasket...

Thanks, Rein

On Mar 31, 11:29 pm, Rein Petersen rein.peter...@gmail.com wrote:
 Hi,

 i have a model with a referenceproperty that points to another
 instance of a model. i know the entity is stored because i can see the
 reference property and the referenced entity in the dataviewer.

 But, when i try to access the referenced instance or anything about
 the referenced instance (as i understand from the online docs), i just
 get the following error:

 AttributeError: 'ReferenceProperty' object has no attribute ...

 How can i instance a model entity with a ReferenceProperty object?
 This should be trivial i think but the docs say that just by accessing
 an attribute should trigger the fetch. i dont see that happening when
 i execute :

 modelAinstance.modelBref.myattribute

 where modelAinstance is an instance of ModelA which contains the
 attribute ModelBref which is a ReferenceProperty holding a reference
 to an instance of ModelB

 What am i missing?

 Thanks for the help...

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



[google-appengine] Re: ReferenceProperty troubles

2009-04-01 Thread Rein Petersen

Thanks Andy, it works now

On Apr 1, 12:29 pm, Andy Freeman ana...@earthlink.net wrote:
    @classmethod
    def forEncode(self):

 Because of @classmethod, self isn't an instance, it's the class
 (probably either exModel or exStateModel).  While the
 ReferenceProperty object itself is part of the class, the actual
 values are associated with instances.

 On Apr 1, 9:06 am, Rein Petersen rein.peter...@gmail.com wrote:

  Maybe a bit of pared down code will help get a response for this
  problem:

  from google.appengine.ext import db

  class exModel(db.Model):
    state = db.ReferenceProperty()
    name = db.StringProperty()
    @classmethod
    def forEncode(self):
      baseDct = {name:self.name}
      if self.state: baseDct[state] = self.state.forEncode()
      return baseDct

  class exStateModel(db.Model):
    desc = db.StringProperty()
    @classmethod
    def forEncode(self):
      return {desc:self.description }

  The line [ baseDct[state]:self.state.forEncode() ] found in the
  forEncode method of exModel coughs up this:

  AttributeError: 'ReferenceProperty' object has no attribute
  'forEncode'

  i get a similar error asking for any attribute. i just can't get at
  the instance or anything about like the documentation demonstrates.
  And i know its there, i confirmed it using the data viewer and the
  reference and referenced instance are there... help me before i blow a
  gasket...

  Thanks, Rein

  On Mar 31, 11:29 pm, Rein Petersen rein.peter...@gmail.com wrote:

   Hi,

   i have a model with a referenceproperty that points to another
   instance of a model. i know the entity is stored because i can see the
   reference property and the referenced entity in the dataviewer.

   But, when i try to access the referenced instance or anything about
   the referenced instance (as i understand from the online docs), i just
   get the following error:

   AttributeError: 'ReferenceProperty' object has no attribute ...

   How can i instance a model entity with a ReferenceProperty object?
   This should be trivial i think but the docs say that just by accessing
   an attribute should trigger the fetch. i dont see that happening when
   i execute :

   modelAinstance.modelBref.myattribute

   where modelAinstance is an instance of ModelA which contains the
   attribute ModelBref which is a ReferenceProperty holding a reference
   to an instance of ModelB

   What am i missing?

   Thanks for the help...

   Rein- Hide quoted text -

  - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] ReferenceProperty troubles

2009-03-31 Thread Rein Petersen

Hi,

i have a model with a referenceproperty that points to another
instance of a model. i know the entity is stored because i can see the
reference property and the referenced entity in the dataviewer.

But, when i try to access the referenced instance or anything about
the referenced instance (as i understand from the online docs), i just
get the following error:

AttributeError: 'ReferenceProperty' object has no attribute ...

How can i instance a model entity with a ReferenceProperty object?
This should be trivial i think but the docs say that just by accessing
an attribute should trigger the fetch. i dont see that happening when
i execute :

modelAinstance.modelBref.myattribute

where modelAinstance is an instance of ModelA which contains the
attribute ModelBref which is a ReferenceProperty holding a reference
to an instance of ModelB

What am i missing?

Thanks for the help...

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



[google-appengine] PolyModel needs to be rethought

2009-03-28 Thread Rein Petersen

Hi,

At risk of sounding too critical (believe me - i am so very
appreciative of GAE), something about PolyModel has been bothering me
enough that i must get it off my chest in the hope that it might be
reworked. The PolyModel was created to allow developers to access all
child entities through the base. i think it is an important ability
for the GAE and PolyModel addresses the need.

But, (here it comes) every extension (field) is stored in the same
table? (entity group) along with an extra field (list) that stores the
class names. The problem with this is that if you have an inheritance
hierarchy in which your outermost descendant(s) extend several fields,
you've loaded your base entities with a mass of irrelevant fields
containing an unusual missing (i've never seen that before).

if you are building an application that, say for example, reads the
fields (columns?) in the entity for display to the user (like the
Dashboard's Data Viewer), you end up presenting irrelevant fields. How
the unnecessary fetching of these extension fields affects performance
i cannot say but i would guess it is not helpful.

i tend to think that each subclass entity justifies its own distinct
table? / entity ? and would only contain the fields which extend it's
base class which resides in the same entity group as the parent.

PolyModel could then, instead, walk the parent chain adding fields as
necessary until it reaches the root entity. The subclassed entity
would be presented as a composite of all the fields within itself and
it's ascendants. since the superclass entities are assigned to the
subclass entities by parent, the reside in the same entity group and
shouldn't be an impediment to scalability or within a transaction

it seems to make so much sense to me that i can only guess there was
some obstacle preventing it being so and the only solution was what we
have now. if that is the case, please tell me so i can just give up on
this... otherwise comments are always welcome -

thanks :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Get the root entity for a given Model

2009-02-19 Thread Rein Petersen

Hey,

I find myself wanting to get at the very root entity for a given Model
that may be part of a longer entity chain. Wondering what others think
about suggesting a feature request:

add instance method to db.Model

root() Returns a model instance for the root (top parent) entity
within the entity chain of this instance, or None if this instance
does not have a parent

Thanks in advance for any comments...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] deserialize json to python object

2009-02-10 Thread Rein Petersen

what is wrong with this:

from django.utils import simplejson
...
obj = simplejson.loads({'id':'KS1-0','type':'activity','units':
1,'priceper':450})
self.response.out.write(p + obj.type + /p);

I get the error:
File C:\Program Files\Google\google_appengine\lib\django\django\utils
\simplejson\decoder.py, line 127, in JSONObject
raise ValueError(errmsg(Expecting property name, s, end))
ValueError: Expecting property name: line 1 column 1 (char 1)

What am I not understanding? Maybe my eyes are tired...

Thanks in advance :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: deserialize json to python object

2009-02-10 Thread Rein Petersen

Hey thanks for the reply - that was the problem. Thanks again :)

On Feb 10, 4:41 am, livibetter livibet...@gmail.com wrote:
 On Feb 10, 5:23 pm, Rein Petersen rein.peter...@gmail.com wrote:

      obj = simplejson.loads({'id':'KS1-0','type':'activity','units':
  1,'priceper':450})

 The string of JSON is wrapped with double quote. (http://json.org/)

 This will work
   obj = simplejson.loads('{id:KS1-0,type:activity,units:
 1,priceper:450}')
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---