[google-appengine] Re: How to handle form submit with 1 handler only?

2011-01-26 Thread Claude Vedovini
You are right, this is only true of Django queries :)

On Jan 23, 6:33 pm, djidjadji djidja...@gmail.com wrote:
 This is not true.
 They are equivalent. They modify the query IN-PLACE. They do not
 return a new one.
 All the db.Query methods return self. You can choose to chain them all
 in one line or in separate lines.
 No need to assign to the items variable after the create call [ Item.all() ].

 2011/1/23 ClaudeVedovinicla...@vedovini.net:







  I also noticed that your code to retrieve the records from the DB is
  wrong, this won't work as you expect:

  items = Item.all()
  items.filter(type =, merchandise_type)
  items.order(-points)

  because filter and order methods do not modify the query, they return
  a new one, so your code be:

  items = Item.all()
  items = items.filter(type =, merchandise_type)
  items = items.order(-points)

  or the shorter

  items = Item.all().filter(type =, merchandise_type).order(-points)

-- 
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: How to handle form submit with 1 handler only?

2011-01-26 Thread Claude Vedovini
At any point, if you want to know the value of the type variable you
need to pass it to your handler
You have at least 3 ways of doing so:
1. having a dedicated handler with a dedicated URL
2. passing the variable as a GET parameter (/directorysubmithandler?
dir_type=...)
3. passing the variable as a POST parameter (adding input
type=hidden name=dir_type value=... inside your form)

to do 2 and 3 you just need to change the output of the handle that
returns the form's page


On Jan 23, 11:02 pm, Zeynel azeyn...@gmail.com wrote:
 On Jan 23, 3:12 am, ClaudeVedovinicla...@vedovini.net wrote:

  to do that you need to have your form action posted to /dir?type=xxx

 I have

 action=/directorysubmithandler

 I don't understand why form handler needs to be the final url. Can you
 explain.

  but a better way is to add a hidden field type in the form in the
  get method and then retrieve it in the post method

 I've been trying to do this all day yesterday with no success. Both
 Directory and DirectorySubmitHandler are herehttp://pastebin.com/wG7BNZ5m

 I would appreciate it if you could explain how this is done without
 using templates.

 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] Re: How to handle form submit with 1 handler only?

2011-01-23 Thread Claude Vedovini
to do that you need to have your form action posted to /dir?type=xxx
but a better way is to add a hidden field type in the form in the
get method and then retrieve it in the post method


On Jan 23, 4:10 am, Zeynel azeyn...@gmail.com wrote:
 On Jan 22, 9:06 pm, Calvin calvin.r...@gmail.com wrote:

  First thing: there shouldn't be an else: at the top of this code.  def get()
  and def post() are two separate methods of the DirectoryHandler class.

 Thanks! I fixed that and now post writes to the database but I still
 cannot get the url parameter saved in get into post? Any suggestions
 about how to do this? The code is herehttp://pastebin.com/QkQt874J

 Thanks for your help.

-- 
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: How to handle form submit with 1 handler only?

2011-01-23 Thread Claude Vedovini
I also noticed that your code to retrieve the records from the DB is
wrong, this won't work as you expect:

items = Item.all()
items.filter(type =, merchandise_type)
items.order(-points)

because filter and order methods do not modify the query, they return
a new one, so your code be:

items = Item.all()
items = items.filter(type =, merchandise_type)
items = items.order(-points)

or the shorter

items = Item.all().filter(type =, merchandise_type).order(-points)




On Jan 23, 9:12 am, Claude Vedovini cla...@vedovini.net wrote:
 to do that you need to have your form action posted to /dir?type=xxx
 but a better way is to add a hidden field type in the form in the
 get method and then retrieve it in the post method

 On Jan 23, 4:10 am, Zeynel azeyn...@gmail.com wrote:







  On Jan 22, 9:06 pm, Calvin calvin.r...@gmail.com wrote:

   First thing: there shouldn't be an else: at the top of this code.  def 
   get()
   and def post() are two separate methods of the DirectoryHandler class.

  Thanks! I fixed that and now post writes to the database but I still
  cannot get the url parameter saved in get into post? Any suggestions
  about how to do this? The code is herehttp://pastebin.com/QkQt874J

  Thanks for your help.

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



Re: [google-appengine] Re: How to handle form submit with 1 handler only?

2011-01-23 Thread djidjadji
This is not true.
They are equivalent. They modify the query IN-PLACE. They do not
return a new one.
All the db.Query methods return self. You can choose to chain them all
in one line or in separate lines.
No need to assign to the items variable after the create call [ Item.all() ].

2011/1/23 Claude Vedovini cla...@vedovini.net:
 I also noticed that your code to retrieve the records from the DB is
 wrong, this won't work as you expect:

 items = Item.all()
 items.filter(type =, merchandise_type)
 items.order(-points)

 because filter and order methods do not modify the query, they return
 a new one, so your code be:

 items = Item.all()
 items = items.filter(type =, merchandise_type)
 items = items.order(-points)

 or the shorter

 items = Item.all().filter(type =, merchandise_type).order(-points)

-- 
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: How to handle form submit with 1 handler only?

2011-01-23 Thread Zeynel
On Jan 23, 3:12 am, Claude Vedovini cla...@vedovini.net wrote:

 to do that you need to have your form action posted to /dir?type=xxx

I have

action=/directorysubmithandler

I don't understand why form handler needs to be the final url. Can you
explain.

 but a better way is to add a hidden field type in the form in the
 get method and then retrieve it in the post method

I've been trying to do this all day yesterday with no success. Both
Directory and DirectorySubmitHandler are here http://pastebin.com/wG7BNZ5m

I would appreciate it if you could explain how this is done without
using templates.

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] Re: How to handle form submit with 1 handler only?

2011-01-22 Thread Zeynel
Also, this is the mapping I use:

 ('/dir', DirectoryHandler),

Thanks.

On Jan 22, 8:29 pm, Zeynel azeyn...@gmail.com wrote:
 I am still trying to resolve the question that I asked 
 here:http://groups.google.com/group/google-appengine/browse_thread/thread/...

 I tried to use only one handler instead of two.

 The new DirectoryHandler is here:http://pastebin.com/7RX32R6D

 On line 40 I test if title of the form is empty

 if empty form is not submitted and I get the merchandise_type from the
 database and display by points.

 This part works but else part does not work. On line 57 I try to write
 form info to database:

 else:
     def post(self):
         merchandise_type = self.request.get(type, )
         item = Item()
         item.title = self.request.get(title)
         item.url = self.request.get(url)
         item.type = merchandise_type
         item.user_who_liked_this_item = user
         item.put()

 If the form is submitted the /dir is displayed without the url
 parameters.

 else part is never executed. I would appreciate help with this. Or the
 best way to solve this problem. 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] Re: How to handle form submit with 1 handler only?

2011-01-22 Thread Zeynel
On Jan 22, 9:06 pm, Calvin calvin.r...@gmail.com wrote:

 First thing: there shouldn't be an else: at the top of this code.  def get()
 and def post() are two separate methods of the DirectoryHandler class.

Thanks! I fixed that and now post writes to the database but I still
cannot get the url parameter saved in get into post? Any suggestions
about how to do this? The code is here http://pastebin.com/QkQt874J

Thanks for your help.

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