[google-appengine] How does google_apps_namespace() work?

2011-01-25 Thread tobik
I'm writing an application for Google Apps and I want to support
multitenancy. So I used Namespace API as described in the
documentation (using google_apps_namespace()), deployed my app and
added to my domain (using 'Add domain' in settings). But the function
namespace_manager.google_apps_namespace() returns an empty string.
What do I have to do to get it working? Do I have to use Users API to
authenticate users? Or do I have to access my app using url mapped to
my domain (like myapp.mydomain.com, not myapp.appspot.com)? But I
couldn't use Namespace API for apps in Marketplace then as apps in
Marketplace can have only one url for all domains.

Please, is there anyone who uses Namespace API with Google Apps?

-- 
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] Google Apps domain and Namespace API

2011-01-25 Thread tobik
According to the documentation: "The following code sample shows you
how to set the current namespace to the Google Apps domain that was
used to _map_ the URL."

Does that mean, that google_apps_namespace() returns used Google Apps
only when the app is really mapped to the domain? Something like
myapp.example.com. I just need to confirm that (simple yes or no)
because I don't have the permission to map to url right now.

I deployed the official Namespace example (guestbook_namespace) and it
doesn't work, google_apps_namespace() returns an empty string when I
try to access it via myapp.appspot.com. The app is properly deployed
to my Google Apps domain though.

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: Google Apps domain and Namespace API

2011-01-25 Thread tobik
Hi,
using openid domain seems like a good idea for namespaces. My problem
is that I use Django's authentication system not Google's. And with
Django the users are stored in datastore so in order to get the
namespace I have to access the datastore which is impossible because I
don't know the proper namespace :) Right now I'm thinking of sessions
or secure cookies. Is it a good idea? I could go back to Google User
API? butI use Django because I like the features like groups,
permission or messages

Anyway, getAuthDomain is really useful for namespaces with Google
Apps. I wonder why it is not directly in Namespace API documentation.
Thank you for your answer.

On 25 led, 23:36, yuvi  wrote:
> Hi,
> I'm using java ...
> If you plan a multi-tenant application used by many Google Apps
> Domains then the Namespace is useful
> to separate between different Domains data. In case you use openid for
> authentication, the  java API getAuthDomain()
> provide a domain unique string that can be good for Namespace .
>
> Note: you need to both read and write using Namespace
>
> http://code.google.com/appengine/docs/java/javadoc/com/google/appengi...
>
> On Jan 25, 2:46 pm, tobik  wrote:
>
> > According to the documentation: "The following code sample shows you
> > how to set the current namespace to the Google Apps domain that was
> > used to _map_ the URL."
>
> > Does that mean, that google_apps_namespace() returns used Google Apps
> > only when the app is really mapped to the domain? Something like
> > myapp.example.com. I just need to confirm that (simple yes or no)
> > because I don't have the permission to map to url right now.
>
> > I deployed the official Namespace example (guestbook_namespace) and it
> > doesn't work, google_apps_namespace() returns an empty string when I
> > try to access it via myapp.appspot.com. The app is properly deployed
> > to my Google Apps domain though.
>
> > 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: Google Apps domain and Namespace API

2011-01-26 Thread tobik
 import Cookie
>
> import os
>
> import re
>
> from google.appengine.api import namespace_manager
>
> _USE_SERVER_NAME = 0
>
> _USE_GOOGLE_APPS_DOMAIN = 1
>
> _USE_COOKIE = 2
>
> _NAMESPACE_PICKER = _USE_SERVER_NAME
>
> def namespace_manager_default_namespace_for_request():
>
> """Determine which namespace is to be used for a request.
>
> The value of _NAMESPACE_PICKER has the following effects:
>
> If _USE_SERVER_NAME, we read server name
>
> foo.guestbook-isv.appspot.com and set the namespace.
>
> If _USE_GOOGLE_APPS_DOMAIN, we allow the namespace manager to infer
>
> the namespace from the request.
>
> If _USE_COOKIE, then the ISV might have a gateway page that sets a
>
> cookie called 'namespace', and we set the namespace to the cookie's value
>
> """
>
> name = None
>
> if _NAMESPACE_PICKER == _USE_SERVER_NAME:
>
> try:
>
>     domain = os.environ['SERVER_NAME']
>
>     if re.search('appspot.', domain):
>
>         name = re.sub('appspot.','',domain)
>
>     else:
>
>       name = os.environ['SERVER_NAME']
>
> except:
>
> name = None
>
>   elif _NAMESPACE_PICKER == _USE_GOOGLE_APPS_DOMAIN:
>
> name = namespace_manager.google_apps_namespace()
>
> elif _NAMESPACE_PICKER == _USE_COOKIE:
>
> cookies = os.environ.get('HTTP_COOKIE', None)
>
> if cookies:
>
> name = Cookie.BaseCookie(cookies).get('namespace')
>
> return name
>  ---
>
> ok so when a request, i.e browser requests a URL say client.mydomain.com,,
> the SERVER_NAME is always equal to the namespace,
>
>  in the following piece i force the client to use the namespace even if its
> landing on sayhttps://client.mydomain.appspot.com
>
> try:
>
>     domain = os.environ['SERVER_NAME']
>
>     if re.search('appspot.', domain):
>
>         name = re.sub('appspot.','',domain)
>
>     else:
>
>       name = os.environ['SERVER_NAME']
>
> except:
>
> name = None
>
> 
>
> Bottom line works for me, on 
> bothhttp://client.mydomain.comandhttps://client.mydomain.appspot.com, with 
> the exception of an SSL
> certificate error
>
> Ok on the dns side, every new client appends a unique name to my domain, and
> mapped using dns providers as client.mydomain.com, simple
>
> I bet people have better solutions, I would love to hear about it. But this
> works for me for now
>
> Regard
>
> Saim
>
> On Tue, Jan 25, 2011 at 5:46 PM, tobik  wrote:
> > According to the documentation: "The following code sample shows you
> > how to set the current namespace to the Google Apps domain that was
> > used to _map_ the URL."
>
> > Does that mean, that google_apps_namespace() returns used Google Apps
> > only when the app is really mapped to the domain? Something like
> > myapp.example.com. I just need to confirm that (simple yes or no)
> > because I don't have the permission to map to url right now.
>
> > I deployed the official Namespace example (guestbook_namespace) and it
> > doesn't work, google_apps_namespace() returns an empty string when I
> > try to access it via myapp.appspot.com. The app is properly deployed
> > to my Google Apps domain though.
>
> > 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.
>
>

-- 
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] Namespace vulnerabilities?

2011-01-26 Thread tobik
Google mentions some vulnerabilities when working with Namespaces:

Note: An application that reads Keys, or other namespace-aware
objects, from untrusted sources (like the web browser client)
introduces security vulnerabilities. Applications that rely on keys
from untrusted sources must incorporate a security layer verifying
that the current user is authorized to access the requested
namespace.
http://code.google.com/intl/cs/appengine/docs/python/multitenancy/multitenancy.html#Using_Namespaces_with_the_Datastore

I'm not sure if I understand it correctly. What kind of
vulnerabilities does Google mean? Could you provide me some example,
what should I be careful about?

-- 
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 does google_apps_namespace() work?

2011-01-26 Thread tobik
Thanks for your answers. I thought my question was lost because it
didn't appear for a long time and in the meanwhile I started a new
thread. I look like a spammer now...

I am now using the domain as a namespace. It's working quite well
although I have to test it a little bit to avoid some security holes.
See 
http://groups.google.com/group/google-appengine/browse_thread/thread/d6c8aa10bb23e343/6425a1fa51ab7e00
(last post)

-- 
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: Namespace vulnerabilities?

2011-01-26 Thread tobik
Thank you! That's what I wanted to know.

So basically passing Keys in urls is not a good idea, but using pure
IDs and Model.get_by_id() should be secure enough. Or am I wrong? I
tried to get access to data across namespaces but it ended up with
request error. So it worked as expected.


On 27 led, 01:37, Uros Trebec  wrote:
> If you read about the Key class (http://code.google.com/intl/cs/
> appengine/docs/python/datastore/keyclass.html) you'll come across the
> fact that Key is defined by a few values: appid, kind, id/name,
> namespace, parent, etc.
> You would think that this is all good and well until you come to the
> fact that you can get the Key object encoded into a string which can
> be passed around the application (helpful when you're doing some stuff
> with TaskQueues). Now, sometimes it is useful to use the encoded key
> as a reference to something in a GET/POST request from the client.
> There's nothing wrong with that if you don't use the namespaces.
> However, when namespaces are used to separate the objects in the
> Datastore and you rely on the fact that the namespace_manager will
> manage the namespace for queries, things get complicated.
>
> See, the encoded key can be decoded directly to a Key object and as
> such can have the namespace value defined. This means that if you use
> this Key to fetch an object from the Datastore the fetched object
> might be from other namespace as currently defined in the
> namespace_manager and should not be accessible. This is a potential
> vulnerability if you do not validate the namespace in the Key before
> using it.
>
> Did I got this right?
>
> Regards,
> Uros
>
> On Jan 26, 10:09 pm, tobik  wrote:
>
> > Google mentions some vulnerabilities when working with Namespaces:
>
> > Note: An application that reads Keys, or other namespace-aware
> > objects, from untrusted sources (like the web browser client)
> > introduces security vulnerabilities. Applications that rely on keys
> > from untrusted sources must incorporate a security layer verifying
> > that the current user is authorized to access the requested
> > namespace.http://code.google.com/intl/cs/appengine/docs/python/multitenancy/mul...
>
> > I'm not sure if I understand it correctly. What kind of
> > vulnerabilities does Google mean? Could you provide me some example,
> > what should I be careful about?
>
>

-- 
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: Namespace vulnerabilities?

2011-01-27 Thread tobik
Great, thanks.

On 27 led, 16:06, Geoffrey Spear  wrote:
> On Thursday, January 27, 2011 2:52:48 AM UTC-5, tobik wrote:
>
> > Thank you! That's what I wanted to know.
>
> > So basically passing Keys in urls is not a good idea, but using pure
> > IDs and Model.get_by_id() should be secure enough. Or am I wrong? I
> > tried to get access to data across namespaces but it ended up with
> > request error. So it worked as expected.
>
> Yes; IDs are only unique within a namespace, entity group, and kind, so
> passing an ID from one namespace to an instance using a different namespace
> will either get you a different entity from the calling instance's namespace
> or nothing, never the entity in the original namespace.

-- 
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: Namespace vulnerabilities?

2011-01-27 Thread tobik
That's funny because passing clear ids in url is quite common in
classic webs written in PHP. Practically all PHP frameworks/CMS
(including the big ones like Joomla or MODx) do that so I never
thought of it as a possible vulnerability. Or is there something more
I should worry about in this particular situation (Python,
AppEngine...)?

On 27 led, 19:34, Jeff Schwartz  wrote:
> IMHO passing clear ids as text in urls is not a good idea because anything a
> hacker can gleam about data is opening up a can of worms that they could use
> to try to exploit your site and even corrupt your data. I'd look to encrypt
> the id or at least apply a hash such as base64 at a a minimum to obfuscate
> the actual id. While base64 wont deter a committed hacker it will deter many
> malcontents who will move on to easier pickings. Best if you can, generate
> an encrypted id on the server and pass that back via the url from the
> client.
>
>
>
> On Thu, Jan 27, 2011 at 1:06 PM, tobik  wrote:
> > Great, thanks.
>
> > On 27 led, 16:06, Geoffrey Spear  wrote:
> > > On Thursday, January 27, 2011 2:52:48 AM UTC-5, tobik wrote:
>
> > > > Thank you! That's what I wanted to know.
>
> > > > So basically passing Keys in urls is not a good idea, but using pure
> > > > IDs and Model.get_by_id() should be secure enough. Or am I wrong? I
> > > > tried to get access to data across namespaces but it ended up with
> > > > request error. So it worked as expected.
>
> > > Yes; IDs are only unique within a namespace, entity group, and kind, so
> > > passing an ID from one namespace to an instance using a different
> > namespace
> > > will either get you a different entity from the calling instance's
> > namespace
> > > or nothing, never the entity in the original namespace.
>
> > --
> > 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.
>
> --
> *Jeff Schwartz*

-- 
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] AppEngine seems slow to me. Is it normal?

2011-02-22 Thread tobik
I built a page using Django's Paginator which displays a simple table
with 20 items from around 1000 total stored in database. I don't know
how the Paginator works from the inside, but according to the
appstats, it makes two queries (first counts items, second selects
given page) and each one of them takes around 130ms of cpu time. Is it
a normal value? The truth is that the page loads noticeably slower
than a page without any queries. And I also counted, that with 6.5 cpu
hours limit I can afford around 3000 such queries every day which is a
quite small number. And it's only 1000 entries in the database.

So far I've been using PHP+MySQL and I am used to that such simple
queries are really fast, even on poor free hostings. I tried to apply
caching on every single page generated by Paginator and it naturally
reduced the loading time to minimum. So is it the right approach to
AppEngine? Cache everything as much as possible?

-- 
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: AppEngine seems slow to me. Is it normal?

2011-02-22 Thread tobik
Ok, just to be clear, I found this about 'offset' in the
documentation:

"The query has performance characteristics that correspond linearly
with the offset amount plus the limit."

If I understand it correctly, the more entries I skip the more time
consuming it will be. I guess Paginator simply uses 'offset', that's
why it's slow.

On 22 ún, 23:31, Chris Copeland  wrote:
> Django's Paginator is not going to be efficient on GAE and is definitely not
> going to scale.
>
> GAE provides cursors which are a very efficient way to page through query
> results:http://code.google.com/appengine/docs/python/datastore/queries.html#Q...
>
> On Tue, Feb 22, 2011 at 3:57 PM, tobik  wrote:
> > I built a page using Django's Paginator which displays a simple table
> > with 20 items from around 1000 total stored in database. I don't know
> > how the Paginator works from the inside, but according to the
> > appstats, it makes two queries (first counts items, second selects
> > given page) and each one of them takes around 130ms of cpu time. Is it
> > a normal value? The truth is that the page loads noticeably slower
> > than a page without any queries. And I also counted, that with 6.5 cpu
> > hours limit I can afford around 3000 such queries every day which is a
> > quite small number. And it's only 1000 entries in the database.
>
> > So far I've been using PHP+MySQL and I am used to that such simple
> > queries are really fast, even on poor free hostings. I tried to apply
> > caching on every single page generated by Paginator and it naturally
> > reduced the loading time to minimum. So is it the right approach to
> > AppEngine? Cache everything as much as possible?
>
> > --
> > 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.
>
>

-- 
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: AppEngine seems slow to me. Is it normal?

2011-02-22 Thread tobik
Sorry, one more tricky question. What about namespaces. If I had 10
namespaces and in each namespace 10 entries, would the performance be
the same as if I had only one namespace but with 100 entries?

On 22 ún, 23:31, Chris Copeland  wrote:
> Django's Paginator is not going to be efficient on GAE and is definitely not
> going to scale.
>
> GAE provides cursors which are a very efficient way to page through query
> results:http://code.google.com/appengine/docs/python/datastore/queries.html#Q...
>
> On Tue, Feb 22, 2011 at 3:57 PM, tobik  wrote:
> > I built a page using Django's Paginator which displays a simple table
> > with 20 items from around 1000 total stored in database. I don't know
> > how the Paginator works from the inside, but according to the
> > appstats, it makes two queries (first counts items, second selects
> > given page) and each one of them takes around 130ms of cpu time. Is it
> > a normal value? The truth is that the page loads noticeably slower
> > than a page without any queries. And I also counted, that with 6.5 cpu
> > hours limit I can afford around 3000 such queries every day which is a
> > quite small number. And it's only 1000 entries in the database.
>
> > So far I've been using PHP+MySQL and I am used to that such simple
> > queries are really fast, even on poor free hostings. I tried to apply
> > caching on every single page generated by Paginator and it naturally
> > reduced the loading time to minimum. So is it the right approach to
> > AppEngine? Cache everything as much as possible?
>
> > --
> > 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.
>
>

-- 
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: AppEngine seems slow to me. Is it normal?

2011-02-23 Thread tobik
Independent? Now I'm confused. Does it or does it not matter whether I
select first page or 100th using offset?

I checked the cursors, it looks nice, but it seems to me, that it's
good only for "next next next" type of pagination. If the user jumped
from the first to the 100th page and then back to the 50th page, I
would still need to go through all previous entries and it would be
slow. Or am I wrong? Naturally, I know that "next next" type of
pagination would be suitable for most of cases.

Ok and really last question, I hope I don't bother you much. What
about pagination based on time periods. For example like "all entries
created today, yesterday, last week, last month".  It would use simple
filtering (greater than, less than) so it should be fast.. or not?


On 23 ún, 06:25, Robert Kluin  wrote:
> Performance is independent of the number of entities you have.
> Namespaces are great for segregating data, but you can't query across
> them -- you'll only get results from one.
>
> Like Chris mentioned, use cursors instead of offsets.  And if you can,
> then yes a well thought out caching strategy is a good way to improve
> performance.
>
> Robert
>
> On Tue, Feb 22, 2011 at 18:57, tobik  wrote:
> > Sorry, one more tricky question. What about namespaces. If I had 10
> > namespaces and in each namespace 10 entries, would the performance be
> > the same as if I had only one namespace but with 100 entries?
>
> > On 22 ún, 23:31, Chris Copeland  wrote:
> >> Django's Paginator is not going to be efficient on GAE and is definitely 
> >> not
> >> going to scale.
>
> >> GAE provides cursors which are a very efficient way to page through query
> >> results:http://code.google.com/appengine/docs/python/datastore/queries.html#Q...
>
> >> On Tue, Feb 22, 2011 at 3:57 PM, tobik  wrote:
> >> > I built a page using Django's Paginator which displays a simple table
> >> > with 20 items from around 1000 total stored in database. I don't know
> >> > how the Paginator works from the inside, but according to the
> >> > appstats, it makes two queries (first counts items, second selects
> >> > given page) and each one of them takes around 130ms of cpu time. Is it
> >> > a normal value? The truth is that the page loads noticeably slower
> >> > than a page without any queries. And I also counted, that with 6.5 cpu
> >> > hours limit I can afford around 3000 such queries every day which is a
> >> > quite small number. And it's only 1000 entries in the database.
>
> >> > So far I've been using PHP+MySQL and I am used to that such simple
> >> > queries are really fast, even on poor free hostings. I tried to apply
> >> > caching on every single page generated by Paginator and it naturally
> >> > reduced the loading time to minimum. So is it the right approach to
> >> > AppEngine? Cache everything as much as possible?
>
> >> > --
> >> > 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.
>
> > --
> > 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 
> > athttp://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
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: AppEngine seems slow to me. Is it normal?

2011-02-23 Thread tobik
Thanks a lot for all your tips. They are very useful.

On 23 ún, 19:03, Joseph Letness  wrote:
> You could try this:
>
> http://code.google.com/p/he3-appengine-lib/wiki/PagedQuery
>
> It's a complete module that uses cursors for a paging abstraction
> similar to Django's built-in pagination and just as easy to implement
> and you can jump to any page in your result set.
>
> On Feb 23, 3:59 am, tobik  wrote:
>
> > Independent? Now I'm confused. Does it or does it not matter whether I
> > select first page or 100th using offset?
>
> > I checked the cursors, it looks nice, but it seems to me, that it's
> > good only for "next next next" type of pagination. If the user jumped
> > from the first to the 100th page and then back to the 50th page, I
> > would still need to go through all previous entries and it would be
> > slow. Or am I wrong? Naturally, I know that "next next" type of
> > pagination would be suitable for most of cases.
>
> > Ok and really last question, I hope I don't bother you much. What
> > about pagination based on time periods. For example like "all entries
> > created today, yesterday, last week, last month".  It would use simple
> > filtering (greater than, less than) so it should be fast.. or not?
>
> > On 23 ún, 06:25, Robert Kluin  wrote:
>
> > > Performance is independent of the number of entities you have.
> > > Namespaces are great for segregating data, but you can't query across
> > > them -- you'll only get results from one.
>
> > > Like Chris mentioned, use cursors instead of offsets.  And if you can,
> > > then yes a well thought out caching strategy is a good way to improve
> > > performance.
>
> > > Robert
>
> > > On Tue, Feb 22, 2011 at 18:57, tobik  wrote:
> > > > Sorry, one more tricky question. What about namespaces. If I had 10
> > > > namespaces and in each namespace 10 entries, would the performance be
> > > > the same as if I had only one namespace but with 100 entries?
>
> > > > On 22 ún, 23:31, Chris Copeland  wrote:
> > > >> Django's Paginator is not going to be efficient on GAE and is 
> > > >> definitely not
> > > >> going to scale.
>
> > > >> GAE provides cursors which are a very efficient way to page through 
> > > >> query
> > > >> results:http://code.google.com/appengine/docs/python/datastore/queries.html#Q...
>
> > > >> On Tue, Feb 22, 2011 at 3:57 PM, tobik  wrote:
> > > >> > I built a page using Django's Paginator which displays a simple table
> > > >> > with 20 items from around 1000 total stored in database. I don't know
> > > >> > how the Paginator works from the inside, but according to the
> > > >> > appstats, it makes two queries (first counts items, second selects
> > > >> > given page) and each one of them takes around 130ms of cpu time. Is 
> > > >> > it
> > > >> > a normal value? The truth is that the page loads noticeably slower
> > > >> > than a page without any queries. And I also counted, that with 6.5 
> > > >> > cpu
> > > >> > hours limit I can afford around 3000 such queries every day which is 
> > > >> > a
> > > >> > quite small number. And it's only 1000 entries in the database.
>
> > > >> > So far I've been using PHP+MySQL and I am used to that such simple
> > > >> > queries are really fast, even on poor free hostings. I tried to apply
> > > >> > caching on every single page generated by Paginator and it naturally
> > > >> > reduced the loading time to minimum. So is it the right approach to
> > > >> > AppEngine? Cache everything as much as possible?
>
> > > >> > --
> > > >> > 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.
>
> > > > --
> > > > 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 
> > > > athttp://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
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] OpenID suddenly stopped working on localhost

2011-03-16 Thread tobik
I'm using OpenID to authenticate users from Google Apps. I'm writing
the app in django and the authentication process uses libraries
django_openid_auth and openid. It worked like a charm until yesterday
when I tried to login and I got this message:

OpenID authentication failed: Server denied check_authentication

Funny is that when I deploy the application to the server, it does
work! The same code fails on local dev server but works online! And I
have no idea what has changed on my pc. I have recently updated my
Linux box but how could that affect such thing like OpenID
authentication process? Maybe some Python update? I tried to update
the SDK but it didn't help.

I also checked the log and I found this warning:

WARNING  2011-03-16 10:51:21,933 urlfetch_stub.py:325] Stripped
prohibited headers from URLFetch request: ['Content-Length', 'Host']

This might have been there before but I didn't noticed it. And also
this warning appears only on dev server, it's not there when I checked
the log in appengine control panel. So it might be it however I have
no idea how to fix it.

And another problem appeared as well. The script which fetches users
from Google Apps Domain (using gdata) also stopped working, it prints
following message:

sequence item 0: expected string, int found

However again, it DOES work online, with no change in code. I found
that  I should use "gdata.alt.appengine.run_on_appengine(service)" but
it doesn't fix the problem on localhost and breaks it on real server
so I guess it shouldn't be there. And mentioned warning appears here
as well.

I think these two problems might be related so I'm posting them
together.

-- 
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: OpenID suddenly stopped working on localhost

2011-03-16 Thread tobik
I managed to fix it. The problem was indeed in the displayed warning
(Stripped
prohibited headers from URLFetch request: ['Content-Length', 'Host']).
I opened the file google/appengine/api/urlfetch_stub.py and I removed
content-length and host from _UNTRUSTED_REQUEST_HEADERS. Surprisingly,
it worked! I can now login again and also gdata seems to be fixed. But
since hacking into Google SDK isn't the best way to solve problems, I
would be still interested in what was really behind this weird
behavior. It's just a bug?


On 16 bře, 12:05, tobik  wrote:
> I'm using OpenID to authenticate users from Google Apps. I'm writing
> the app in django and the authentication process uses libraries
> django_openid_auth and openid. It worked like a charm until yesterday
> when I tried to login and I got this message:
>
> OpenID authentication failed: Server denied check_authentication
>
> Funny is that when I deploy the application to the server, it does
> work! The same code fails on local dev server but works online! And I
> have no idea what has changed on my pc. I have recently updated my
> Linux box but how could that affect such thing like OpenID
> authentication process? Maybe some Python update? I tried to update
> the SDK but it didn't help.
>
> I also checked the log and I found this warning:
>
> WARNING  2011-03-16 10:51:21,933 urlfetch_stub.py:325] Stripped
> prohibited headers from URLFetch request: ['Content-Length', 'Host']
>
> This might have been there before but I didn't noticed it. And also
> this warning appears only on dev server, it's not there when I checked
> the log in appengine control panel. So it might be it however I have
> no idea how to fix it.
>
> And another problem appeared as well. The script which fetches users
> from Google Apps Domain (using gdata) also stopped working, it prints
> following message:
>
> sequence item 0: expected string, int found
>
> However again, it DOES work online, with no change in code. I found
> that  I should use "gdata.alt.appengine.run_on_appengine(service)" but
> it doesn't fix the problem on localhost and breaks it on real server
> so I guess it shouldn't be there. And mentioned warning appears here
> as well.
>
> I think these two problems might be related so I'm posting them
> together.

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