I apologize. I thought I made all required changes but I missed one:
In controller replace:
friends = db(User.id==Link.source)
(Link.target==me).select(orderby=alphabetical)
requests = db(User.id==Link.target)
(Link.source==me).select(orderby=alphabetical)
with:
friends = db(Link.target==me).select()
requests = db(Link.source==me).select()
and change the friends.html view into:
{{extend 'layout.html'}}
<h2>Friendship Offered</h2>
<table>
{{for friend in friends:}}
<tr>
<td>{{=A(name_of(db.auth_user(friend.source)),_href=URL('wall',args=friend.source))}}
</td>
<td>{{if friend.accepted:}}accepted{{else:}}<button
onclick="ajax('{{=URL('friendship',args=('accept',friend.source))}}',
[],null); $(this).parent().html('accepted')">accept</button>{{pass}}</
td>
<td><button
onclick="ajax('{{=URL('friendship',args=('deny',friend.source))}}',
[],null); $(this).parent().html('denied')">deny</button></td>
</tr>
{{pass}}
</table>
<h2>Friendship Requested</h2>
<table>
{{for friend in requests:}}
<tr>
<td>{{=A(name_of(db.auth_user(friend.target)),_href=URL('wall',args=friend.target))}}
</td>
<td>{{if friend.accepted:}}accepted{{else:}}pending{{pass}}</td>
<td><button
onclick="ajax('{{=URL('friendship',args=('deny',friend.target))}}',
[],null); $(this).parent().html('removed')">remove</button></td>
</tr>
{{pass}}
</table>
This is because GAE cannot do joins.
I also think that on GAE the current Query
query = reduce(lambda a,b:a&b,
[User.first_name.contains(k)|
User.last_name.contains(k) \
for k in tokens])
is too complex and should be
query =
(User.first_name==tokens[0])&(User.last_name==tokens[1])
On Mar 24, 6:06 am, Arbie Samong <[email protected]> wrote:
> I actually tried the tutorial posted here:
>
> http://blip.tv/file/4912976
>
> and here are some information that wasn't mentioned but might be helpful for
> absolute beginners like me:
>
> -
>
> You must first register with janrain and take note of the application
> name
> -
>
> In models/db_janrain.py, you need to set domain to the application name
> you registered with. In the tutorial it is set to web2py. It is
> https://blabla.rpxnow.com/, where blabla is the applciation name.
> -
>
> The file janrain_api_key.txt will contain only the secret api key, which
> you can see in the janrain dashboard.
> -
>
> The web2py source does not have app.yaml. So you copy the one in
> google_appengine/new_project_template over to web2py/.
> -
>
> Edit the file and set the application (first line) to the one you
> registered with in app engine. Then set script to gaehandler.py (under
> handlers)
> -
>
> When running the local app engine instance for the first time to build
> indexes, be sure to change the url in models/db_janrain.py from
> localhost:8000 to localhost:8080. If you don't it will redirect to the
> web2py instance instead of the app engine instance, and the indexes will
> not
> be built causing an error when running it in appspot.com
> -
>
> When deploying, appcfg can be found under the google_appengine/ folder,
> so just copy the full path.
>
> Now, for the question. The friends and search pages do not work when
> deploying on GAE, both on localhost:8080 and on the real server. It works
> fine when using the web2py server but not on the GAE. My best guess are
> database issues, since GAE might not be supporting the db calls used in the
> tutorial. The errors are:
>
> -
>
> on friends/default/friends/ when viewing the page
>
> ERROR 2011-03-24 07:34:36,785 restricted.py:55] In FILE:
>
> /home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/a
> pplications/friends/controllers/default.py
>
> Traceback (most recent call last):
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/restricted.py",
> line 188, in restricted
>
> exec ccode in environment
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> applications/friends/controllers/default.py:friends",
> line 93, in <module>
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/globals.py",
> line 124, in <lambda>
>
> self._caller = lambda f: f()
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/tools.py",
> line 2331, in f
>
> return action(*a, **b)
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> applications/friends/controllers/default.py:friends",
> line 68, in friends
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/dal.py",
> line 5009, in select
>
> return self.db._adapter.select(self.query,fields,attributes)
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/dal.py",
> line 2892, in select
>
> (items, tablename, fields) = self.select_raw(query,fields,attributes)
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/dal.py",
> line 2841, in select_raw
>
> tablename = self.get_table(query)
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/dal.py",
> line 955, in get_table
>
> raise RuntimeError, "Too many tables selected"
>
> RuntimeError: Too many tables selected
>
> -
>
> on friends/default/search/ when trying to search
>
> ERROR 2011-03-24 07:35:23,136 restricted.py:55] In FILE:
>
> /home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/a
> pplications/friends/controllers/default.py
>
> Traceback (most recent call last):
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/restricted.py",
> line 188, in restricted
>
> exec ccode in environment
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> applications/friends/controllers/default.py:search",
> line 93, in <module>
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/globals.py",
> line 124, in <lambda>
>
> self._caller = lambda f: f()
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/tools.py",
> line 2331, in f
>
> return action(*a, **b)
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> applications/friends/controllers/default.py:search",
> line 59, in search
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/dal.py",
> line 5009, in select
>
> return self.db._adapter.select(self.query,fields,attributes)
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/dal.py",
> line 2892, in select
>
> (items, tablename, fields) = self.select_raw(query,fields,attributes)
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/dal.py",
> line 2849, in select_raw
>
> filters = self.expand(query)
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/dal.py",
> line 2734, in expand
>
> return expression.op(expression.first, expression.second)
>
> File
>
> "/home/arbie/Documents/python/workspace/supaprends/google_appengine/web2py/
> gluon/dal.py",
> line 2595, in OR
>
> def OR(self,first,second): raise SyntaxError, "Not supported"
>
> SyntaxError: Not supported
>
> It would be great if somebody would post a way to get around these
> limitations assuming they are issues on the db layer. I *typed* the code in
> the video as verbatim as it could be.