[google-appengine] Re: Forward request or webapp.RequestHandler chaining (like Actions framework in java)

2009-03-17 Thread Serega.Sheypak

Yes, Java made my mind tooo complicated. You've  written clear
solution: invoke one handler from another.
That is why I've immediately started to learn Python+ GAE (wow), Ruby
+RoR (awesome! cool!) and Lisp(brain blast) .

Java made my mind Javable... :(

On Mar 16, 12:44 am, Jarek Zgoda  wrote:
> It would be easier if you do not use WebApp but follow Django way of
> request handling (easy to achieve even without Django, ie. using
> Werkzeug to lay out application in model-view-template style):
>
> def handler_a(request):
>   return response('a')
>
> def handler_b(request):
>   return handler_a(request)
>
> In handler_b you just called handler_a with a request object from
> handler_b. You can modify request object before passing it to another
> view function as you please.
>
> On 15 Mar, 12:06, "Serega.Sheypak"  wrote:
>
> > Hello, I would like to know is it possible to forward request?
>
> > For example in Java I can forward request from one servlet (like
> > webapp.RequestHandler) to another or from servlet to jsp (like Django
> > template).
> > self.redirect("/someUrl") clears response and doesn't "transfer"
> > request object. That is why I need redirect.
>
> > The task is:
> > I have a view (Django template)
> > Person can perform silmpe crud: Create something, delete something,
> > update something.
>
> > Here is a code:
>
> > #prepare view data, show news
> > class AdminPage(webapp.RequestHandler):
> >         def get(self):
> >                 message = self.request.get('message')
> >                 if not message:
> >                         message = 'You are in admin console.'
> >                 logging.debug("Did message came -> " + message);
> >                 offset = self.request.get('offset')
> >                 limit = self.request.get('limit')
> >                 news = get_news(offset, limit, False)
> >                 values = {
> >                         'page': 'admin',
> >                         'news': news,
> >                         'count': get_news_count(),
> >                         'message': message
> >                 }
> >                 path = 
> > os.path.join(os.path.dirname(__file__),'html/admin.html')
> >                 self.response.out.write( template.render(path, values) )
>
> > #Hide news from user and send to view preparation
> > class HideNews(webapp.RequestHandler):
> >         def get(self):
> >                 key = self.request.get('key')
> >                 logging.debug("hide news with key["+key+"]")
> >                 hide_news( key )
> >                 values = {
> >                         'message':'News was hidden'
> >                 }
> >                 self.redirect("/admin")
>
> > As you can see "HideNews" performs an action and wants to send message
> > to the news requestHandler.
> > But it can't do it.
>
> > Is there any opportunity to forward request processing in GAE?
>
> > P.S
> > I've tried to do this:
> > class HideNews(webapp.RequestHandler):
> >         def get(self):
> >                 key = self.request.get('key')
> >                 logging.debug("hide news with key["+key+"]")
> >                 hide_news( key )
> >                 message = "Some str with russian chars".decode('utf-8')
> >                 url = "/admin?message=".decode('utf-8')+message
> >                 self.redirect(url)
>
> > And I get:
> > self.response.headers['Location'] = str(absolute_url)
> > UnicodeEncodeError: 'ascii' codec can't encode characters in position
> > 36-42: ordinal not in range(128)
>
> > It doesn't accept utf-8 chars?
> > What to try next?
>
> > 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: Forward request or webapp.RequestHandler chaining (like Actions framework in java)

2009-03-16 Thread xml2jsonp

Yes, ok.
You could open a "New Issue"...

On Mar 15, 10:44 pm, Jarek Zgoda  wrote:
> It would be easier if you do not use WebApp but follow Django way of
> request handling (easy to achieve even without Django, ie. using
> Werkzeug to lay out application in model-view-template style):
>
> def handler_a(request):
>   return response('a')
>
> def handler_b(request):
>   return handler_a(request)
>
> In handler_b you just called handler_a with a request object from
> handler_b. You can modify request object before passing it to another
> view function as you please.
>
> On 15 Mar, 12:06, "Serega.Sheypak"  wrote:
>
> > Hello, I would like to know is it possible to forward request?
>
> > For example in Java I can forward request from one servlet (like
> > webapp.RequestHandler) to another or from servlet to jsp (like Django
> > template).
> > self.redirect("/someUrl") clears response and doesn't "transfer"
> > request object. That is why I need redirect.
>
> > The task is:
> > I have a view (Django template)
> > Person can perform silmpe crud: Create something, delete something,
> > update something.
>
> > Here is a code:
>
> > #prepare view data, show news
> > class AdminPage(webapp.RequestHandler):
> >         def get(self):
> >                 message = self.request.get('message')
> >                 if not message:
> >                         message = 'You are in admin console.'
> >                 logging.debug("Did message came -> " + message);
> >                 offset = self.request.get('offset')
> >                 limit = self.request.get('limit')
> >                 news = get_news(offset, limit, False)
> >                 values = {
> >                         'page': 'admin',
> >                         'news': news,
> >                         'count': get_news_count(),
> >                         'message': message
> >                 }
> >                 path = 
> > os.path.join(os.path.dirname(__file__),'html/admin.html')
> >                 self.response.out.write( template.render(path, values) )
>
> > #Hide news from user and send to view preparation
> > class HideNews(webapp.RequestHandler):
> >         def get(self):
> >                 key = self.request.get('key')
> >                 logging.debug("hide news with key["+key+"]")
> >                 hide_news( key )
> >                 values = {
> >                         'message':'News was hidden'
> >                 }
> >                 self.redirect("/admin")
>
> > As you can see "HideNews" performs an action and wants to send message
> > to the news requestHandler.
> > But it can't do it.
>
> > Is there any opportunity to forward request processing in GAE?
>
> > P.S
> > I've tried to do this:
> > class HideNews(webapp.RequestHandler):
> >         def get(self):
> >                 key = self.request.get('key')
> >                 logging.debug("hide news with key["+key+"]")
> >                 hide_news( key )
> >                 message = "Some str with russian chars".decode('utf-8')
> >                 url = "/admin?message=".decode('utf-8')+message
> >                 self.redirect(url)
>
> > And I get:
> > self.response.headers['Location'] = str(absolute_url)
> > UnicodeEncodeError: 'ascii' codec can't encode characters in position
> > 36-42: ordinal not in range(128)
>
> > It doesn't accept utf-8 chars?
> > What to try next?
>
> > 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: Forward request or webapp.RequestHandler chaining (like Actions framework in java)

2009-03-15 Thread Jarek Zgoda

It would be easier if you do not use WebApp but follow Django way of
request handling (easy to achieve even without Django, ie. using
Werkzeug to lay out application in model-view-template style):

def handler_a(request):
  return response('a')

def handler_b(request):
  return handler_a(request)

In handler_b you just called handler_a with a request object from
handler_b. You can modify request object before passing it to another
view function as you please.

On 15 Mar, 12:06, "Serega.Sheypak"  wrote:
> Hello, I would like to know is it possible to forward request?
>
> For example in Java I can forward request from one servlet (like
> webapp.RequestHandler) to another or from servlet to jsp (like Django
> template).
> self.redirect("/someUrl") clears response and doesn't "transfer"
> request object. That is why I need redirect.
>
> The task is:
> I have a view (Django template)
> Person can perform silmpe crud: Create something, delete something,
> update something.
>
> Here is a code:
>
> #prepare view data, show news
> class AdminPage(webapp.RequestHandler):
>         def get(self):
>                 message = self.request.get('message')
>                 if not message:
>                         message = 'You are in admin console.'
>                 logging.debug("Did message came -> " + message);
>                 offset = self.request.get('offset')
>                 limit = self.request.get('limit')
>                 news = get_news(offset, limit, False)
>                 values = {
>                         'page': 'admin',
>                         'news': news,
>                         'count': get_news_count(),
>                         'message': message
>                 }
>                 path = 
> os.path.join(os.path.dirname(__file__),'html/admin.html')
>                 self.response.out.write( template.render(path, values) )
>
> #Hide news from user and send to view preparation
> class HideNews(webapp.RequestHandler):
>         def get(self):
>                 key = self.request.get('key')
>                 logging.debug("hide news with key["+key+"]")
>                 hide_news( key )
>                 values = {
>                         'message':'News was hidden'
>                 }
>                 self.redirect("/admin")
>
> As you can see "HideNews" performs an action and wants to send message
> to the news requestHandler.
> But it can't do it.
>
> Is there any opportunity to forward request processing in GAE?
>
> P.S
> I've tried to do this:
> class HideNews(webapp.RequestHandler):
>         def get(self):
>                 key = self.request.get('key')
>                 logging.debug("hide news with key["+key+"]")
>                 hide_news( key )
>                 message = "Some str with russian chars".decode('utf-8')
>                 url = "/admin?message=".decode('utf-8')+message
>                 self.redirect(url)
>
> And I get:
> self.response.headers['Location'] = str(absolute_url)
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 36-42: ordinal not in range(128)
>
> It doesn't accept utf-8 chars?
> What to try next?
>
> 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: Forward request or webapp.RequestHandler chaining (like Actions framework in java)

2009-03-15 Thread xml2jsonp

Why have the Java developers a complex mind?

I think this is more simple:
values = {'message':'News was hidden'}

# self.redirect("/admin")
path = os.path.join(os.path.dirname(__file__),'html/admin.html')
self.response.out.write( template.render(path, values) )
.
.
.
On Mar 15, 12:06 pm, "Serega.Sheypak" 
wrote:
> Hello, I would like to know is it possible to forward request?
>
> For example in Java I can forward request from one servlet (like
> webapp.RequestHandler) to another or from servlet to jsp (like Django
> template).
> self.redirect("/someUrl") clears response and doesn't "transfer"
> request object. That is why I need redirect.
>
> The task is:
> I have a view (Django template)
> Person can perform silmpe crud: Create something, delete something,
> update something.
>
> Here is a code:
>
> #prepare view data, show news
> class AdminPage(webapp.RequestHandler):
>         def get(self):
>                 message = self.request.get('message')
>                 if not message:
>                         message = 'You are in admin console.'
>                 logging.debug("Did message came -> " + message);
>                 offset = self.request.get('offset')
>                 limit = self.request.get('limit')
>                 news = get_news(offset, limit, False)
>                 values = {
>                         'page': 'admin',
>                         'news': news,
>                         'count': get_news_count(),
>                         'message': message
>                 }
>                 path = 
> os.path.join(os.path.dirname(__file__),'html/admin.html')
>                 self.response.out.write( template.render(path, values) )
>
> #Hide news from user and send to view preparation
> class HideNews(webapp.RequestHandler):
>         def get(self):
>                 key = self.request.get('key')
>                 logging.debug("hide news with key["+key+"]")
>                 hide_news( key )
>                 values = {
>                         'message':'News was hidden'
>                 }
>                 self.redirect("/admin")
>
> As you can see "HideNews" performs an action and wants to send message
> to the news requestHandler.
> But it can't do it.
>
> Is there any opportunity to forward request processing in GAE?
>
> P.S
> I've tried to do this:
> class HideNews(webapp.RequestHandler):
>         def get(self):
>                 key = self.request.get('key')
>                 logging.debug("hide news with key["+key+"]")
>                 hide_news( key )
>                 message = "Some str with russian chars".decode('utf-8')
>                 url = "/admin?message=".decode('utf-8')+message
>                 self.redirect(url)
>
> And I get:
> self.response.headers['Location'] = str(absolute_url)
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 36-42: ordinal not in range(128)
>
> It doesn't accept utf-8 chars?
> What to try next?
>
> 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
-~--~~~~--~~--~--~---