[google-appengine] Re: non-users need easy url

2008-12-15 Thread thebrianschott

niklasr,

Thank you for sharing your approach. It is very illuminating.

 Andy,

I think I understand a little better and have revised our app but have
not deployed the change yet. The class Group has not been changed, and
we have not yet finalized a way to make the key_name unique by adding
a definition of class Keysorsomething() for that purpose and
enabling a dialog with the user if his/her choice has been taken. But,
I can show you the basic idea by in relation to the original group =
Group() and group.put() section.

Earlier in this thread I had suggested the following sequence of
commands and they were almost correct, but in the last line of the
sequence, instead of key, we needed g_place. With that change and
corresponding changes in two similar places in our maps.py, I think we
have what we want except that we need to add the features which direct
the user to select a unique key_name.

 def post(self):
g_place = self.request.get('place')
group  = Group(key_name=g_place)
group.place = g_place
key = group.put()
self.redirect(/?place=%s % key)

So, yes, I appreciate your further explanation of the differences
between key_name s and id s. I am not sure I have the full picture,
but I am past a major hurdle, for me.

Brian

--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-14 Thread Bill

Brian,

That's quite an info dump :)  Suggestion -- work your way through the
documentation since it's pretty good and give yourself a few hours to
test out ideas on the local app server.  I think you'll learn a lot by
using a Console (http://con.appspot.com/console/help/about).  If you
have these kind of questions, just interactively use the console.

I don't really have the time for a complete analysis, but I think you
may be confusing key_name with a key.

Another page in the documentation not to be missed:
http://code.google.com/appengine/docs/datastore/keysandentitygroups.html

It says:
A key has several components: a path describing a parent-child
relationship between the entity and another entity, the kind of the
entity, and either a name assigned to the entity by the application or
a numeric ID assigned by the datastore.

The key_name is just one part of a Key object.  When you get a string-
encoded key, it's the mapping of the Key object data into URL-friendly
characters.


On Dec 13, 10:48 pm, thebrianschott schott.br...@gmail.com wrote:
 Looking at the rest of that last example, maybe they are saying not
 that susan5 is the key, but that using Key.from_path(,susan5) can
 get the key?

 m = Employee(name=Susan, key_name=susan5)
 m.put()
 e = Employee(name=Bob, manager=m.key())
 e.put()

 m_key = Key.from_path(Employee, susan5)    #did I miss the
 importance of this?
 e = Employee(name=Jennifer, manager=m_key)

 Oh, and I see a typo below where I meant key_name, I typed key_word.

 Brian

 On Dec 14, 1:02 am, thebrianschott schott.br...@gmail.com wrote:

  I know I am going in circles here, but it sure seems like my earlier
  solution using key_word should have worked and I am worried there is
  some bug. Consider the example at this link which uses the reserved
  word key_word.

 http://code.google.com/appengine/docs/datastore/typesandpropertyclass...
  m = Employee(name=Susan, key_name=susan5)
  m.put()

  What is going on?

  Brian

  On Dec 14, 12:22 am, thebrianschott schott.br...@gmail.com wrote:

   Wait, I see a flaw: key_name is a reserved word only allowed in the
   model class.
--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-14 Thread thebrianschott

Bill,

I admit that it was quite a core dump, but believe it or not I have
done and am doing all that you said includeing using a local app
server. But I am brandnew to python and did misunderstand keys and
ids. That typo in the documentation was a real stumper, though. The
worda  kind and type are used in both technical and nontechnical ways
in the manual, which threw me. Other documentation wording such as how
the two parts of an and or or pair was vague to me.

The page you just referred me to (...keysandentitygroups.html) was not
that helpful because it wants me to use the id as the url path, but
the id is not helpful to my intended clients because it is a
meaningless number. I want the url path to be more word-like.

But discussions with folks like you helped so much.

Thanks, so much.

Brian

On Dec 14, 6:02 am, Bill billk...@gmail.com wrote:
 Brian,

 That's quite an info dump :)  Suggestion -- work your way through the
 documentation since it's pretty good and give yourself a few hours to
 test out ideas on the local app server.  I think you'll learn a lot by
 using a Console (http://con.appspot.com/console/help/about).  If you
 have these kind of questions, just interactively use the console.

 I don't really have the time for a complete analysis, but I think you
 may be confusing key_name with a key.

 Another page in the documentation not to be 
 missed:http://code.google.com/appengine/docs/datastore/keysandentitygroups.html

 It says:
 A key has several components: a path describing a parent-child
 relationship between the entity and another entity, the kind of the
 entity, and either a name assigned to the entity by the application or
 a numeric ID assigned by the datastore.

 The key_name is just one part of a Key object.  When you get a string-
 encoded key, it's the mapping of the Key object data into URL-friendly
 characters.


--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-14 Thread niklasr

I want the url path to be more word-like.

friendly url isn't standardized though I do [id]/[slugify(title)]
e.g.
/113488/bigbonus-ganhe-dinheiro-indicando-pessoas-e-compr(.htm(l))
markup a href=/{{article.key.id}}/{{article.title|slugify}}
{{article.title|fix_ampersands }}/a
#rewrite / handler / dispatch
('/([0-9]*)/([^/]*)',  ArticleById),
class ArticleById(webapp.RequestHandler):
 def get(self, id, title):
 key = str(db.Key.from_path('Article', int(id)))
 article = db.get(db.Key(key))

It disregards the non-unique title while keeping it in the url for
intelligibility.

Niklas








--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-13 Thread thebrianschott

Because no one has replied, perhaps I need to say more.

There are two main pages in this application:

1add_place.html which is directed toward the group organizers who
contribute mostly to the class Group(db.Model) , and

2map.html which is used later by individuals who contribute
mostly to the class Pins(db.Model).

Then, maps.py is the python program which does the magic by taking the
information from add_place.html and creates the information needed by
map.html.

Currently on line 93 of maps.py you will find the group.put() which
is based on a default key ID, not on a key_name, but I think a
key_name is required -- check me on this, please -- in order to create
a simpler url that will direct the ultimate individual users to
their own map. I am having no luck implementing the key_name idea and
am looking for help doing that or for help doing this another way.

93id=group.put()
94self.redirect(/?place=%s % id)

I have experimented with the following lines leading up to line 93,
but then errors occur near line 42 which baffle me. For example, do I
need to add key_name to the Model for group, and how?

obj = Group.get_by_key_name(str(group.place))
if not obj:
group = Group(key_name=str(group.place))
id = group.put
()   #notice this is
line 93 above
self.redirect(/?place=%s % str(group.place))




On Dec 13, 10:21 am, thebrianschott schott.br...@gmail.com wrote:
 Carpoolfinder.appspot.com has two levels of users: organizers who
 must have a google account because they create ridesharing maps, and
 individuals who are *not* google account holders and who use one or
 more of the existing ridesharing maps after being informed of an
 existing map by an organizer. To route the individuals to their
 correct map, the organizer must provide his/her users with a distinct
 (unique) url that is easy to type in, so using the map's huge key is
 impractical  (but that is as far as we have gotten).

 How can we make each map easy to use for these individuals? I want the
 distinguishing feature of the url to be very similar to the
 group.place value of the map. Also, I need pretty detailed
 instructions because I am a very new web programmer.

 http://code.google.com/p/carpoolfinder/

 Thanks,

 Brian in Atlanta
--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-13 Thread Bill

Brian,

Take a look at this recipe for creating id-based urls:
http://appengine-cookbook.appspot.com/recipe/mapping-keys-to-urls

Note that the put() returns a key, not the id as your line 93 would
suggest.

You should also look at some of the open source projects to see how
others are doing their apps:
http://groups.google.com/group/google-appengine/web/google-app-engine-open-source-projects

Good luck,
Bill

On Dec 13, 2:51 pm, thebrianschott schott.br...@gmail.com wrote:
 Because no one has replied, perhaps I need to say more.

 There are two main pages in this application:

 1        add_place.html which is directed toward the group organizers who
 contribute mostly to the class Group(db.Model) , and

 2        map.html which is used later by individuals who contribute
 mostly to the class Pins(db.Model).

 Then, maps.py is the python program which does the magic by taking the
 information from add_place.html and creates the information needed by
 map.html.

 Currently on line 93 of maps.py you will find the group.put() which
 is based on a default key ID, not on a key_name, but I think a
 key_name is required -- check me on this, please -- in order to create
 a simpler url that will direct the ultimate individual users to
 their own map. I am having no luck implementing the key_name idea and
 am looking for help doing that or for help doing this another way.

 93        id=group.put()
 94        self.redirect(/?place=%s % id)

 I have experimented with the following lines leading up to line 93,
 but then errors occur near line 42 which baffle me. For example, do I
 need to add key_name to the Model for group, and how?

         obj = Group.get_by_key_name(str(group.place))
         if not obj:
             group = Group(key_name=str(group.place))
         id = group.put
 ()                                                   #notice this is
 line 93 above
         self.redirect(/?place=%s % str(group.place))

 On Dec 13, 10:21 am, thebrianschott schott.br...@gmail.com wrote:

  Carpoolfinder.appspot.com has two levels of users: organizers who
  must have a google account because they create ridesharing maps, and
  individuals who are *not* google account holders and who use one or
  more of the existing ridesharing maps after being informed of an
  existing map by an organizer. To route the individuals to their
  correct map, the organizer must provide his/her users with a distinct
  (unique) url that is easy to type in, so using the map's huge key is
  impractical  (but that is as far as we have gotten).

  How can we make each map easy to use for these individuals? I want the
  distinguishing feature of the url to be very similar to the
  group.place value of the map. Also, I need pretty detailed
  instructions because I am a very new web programmer.

 http://code.google.com/p/carpoolfinder/

  Thanks,

  Brian in Atlanta
--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-13 Thread thebrianschott

Bill,

Thank you very much for your extremely helpful reply.
Looking at that recipe again, (I have seen it before) I am beginning
to question my overall understanding of keys. By the way, you are
right that I was thinking of the put() returning the id, not the key.

I think can explain my problem better now. I define the model class as
follows.

class Group(db.Model):
date = db.DateTimeProperty(auto_now_add=True)
center_lat = db.FloatProperty()
center_lng = db.FloatProperty()
zoom = db.IntegerProperty()
place = db.StringProperty()
people = db.StringProperty()
contact =  db.StringProperty()
moreinfo =  db.StringProperty()

I want each instance of group to have a key_name that can be part of
the URL. For now, let's say that the key_name is supposed to be the
same as group.place value. I find that when I execute this
*abbreviated* next snippet, key is not g_place but is a random key
assigned by the system. I know from the results and from debugging
print statements that are not shown.

def post(self):
g_place = self.request.get('place')
group  = Group(key_name=g_place)
group.place = g_place
key = group.put()
self.redirect(/?place=%s % key)

So, can anyone suggest an easy way around this problem?

Brian

--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-13 Thread thebrianschott

Wait, I see a flaw: key_name is a reserved word only allowed in the
model class.
But I still don't see a way to accomplish what I want.

Can instances even have key's? I cannot see an example of the
definition at this link.
http://code.google.com/appengine/docs/datastore/keyclass.html#Key
What does this mean: class Key(encoded=None)?

Brian

On Dec 13, 10:43 pm, thebrianschott schott.br...@gmail.com wrote:
 Bill,

 Thank you very much for your extremely helpful reply.
 Looking at that recipe again, (I have seen it before) I am beginning
 to question my overall understanding of keys. By the way, you are
 right that I was thinking of the put() returning the id, not the key.

 I think can explain my problem better now. I define the model class as
 follows.

 class Group(db.Model):
     date = db.DateTimeProperty(auto_now_add=True)
     center_lat = db.FloatProperty()
     center_lng = db.FloatProperty()
     zoom = db.IntegerProperty()
     place = db.StringProperty()
     people = db.StringProperty()
     contact =  db.StringProperty()
     moreinfo =  db.StringProperty()

 I want each instance of group to have a key_name that can be part of
 the URL. For now, let's say that the key_name is supposed to be the
 same as group.place value. I find that when I execute this
 *abbreviated* next snippet, key is not g_place but is a random key
 assigned by the system. I know from the results and from debugging
 print statements that are not shown.

     def post(self):
         g_place = self.request.get('place')
         group  = Group(key_name=g_place)
         group.place = g_place
         key = group.put()
         self.redirect(/?place=%s % key)

 So, can anyone suggest an easy way around this problem?

 Brian
--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-13 Thread thebrianschott

I know I am going in circles here, but it sure seems like my earlier
solution using key_word should have worked and I am worried there is
some bug. Consider the example at this link which uses the reserved
word key_word.

http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html
m = Employee(name=Susan, key_name=susan5)
m.put()

What is going on?

Brian

On Dec 14, 12:22 am, thebrianschott schott.br...@gmail.com wrote:
 Wait, I see a flaw: key_name is a reserved word only allowed in the
 model class.

--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-13 Thread thebrianschott

Looking at the rest of that last example, maybe they are saying not
that susan5 is the key, but that using Key.from_path(,susan5) can
get the key?

m = Employee(name=Susan, key_name=susan5)
m.put()
e = Employee(name=Bob, manager=m.key())
e.put()

m_key = Key.from_path(Employee, susan5)#did I miss the
importance of this?
e = Employee(name=Jennifer, manager=m_key)

Oh, and I see a typo below where I meant key_name, I typed key_word.

Brian

On Dec 14, 1:02 am, thebrianschott schott.br...@gmail.com wrote:
 I know I am going in circles here, but it sure seems like my earlier
 solution using key_word should have worked and I am worried there is
 some bug. Consider the example at this link which uses the reserved
 word key_word.

 http://code.google.com/appengine/docs/datastore/typesandpropertyclass...
 m = Employee(name=Susan, key_name=susan5)
 m.put()

 What is going on?

 Brian

 On Dec 14, 12:22 am, thebrianschott schott.br...@gmail.com wrote:

  Wait, I see a flaw: key_name is a reserved word only allowed in the
  model class.
--~--~-~--~~~---~--~~
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: non-users need easy url

2008-12-13 Thread thebrianschott

I think I have found an error in the documentation: in the example I
have been using where Key.from_path() is used, it should be
db.Key.from_path() [notice the db.]. Things work better that way.

http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html

On Dec 14, 1:48 am, thebrianschott schott.br...@gmail.com wrote:
 Looking at the rest of that last example, maybe they are saying not
 that susan5 is the key, but that using Key.from_path(,susan5) can
 get the key?

 m = Employee(name=Susan, key_name=susan5)
 m.put()
 e = Employee(name=Bob, manager=m.key())
 e.put()

 m_key = Key.from_path(Employee, susan5)    #did I miss the
 importance of this?
 e = Employee(name=Jennifer, manager=m_key)


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---