Commits

Anonymous committed dda8be8 Merge

Automated merge with ssh://bitbucket.org/Ludia/pyramid_facebook

  • Participants
  • Parent commits 3e61315, 85b23f3

Comments (0)

Files changed (5)

+* Fixed bug which raised configuration conflict because `pyramid_facebook` was
+  not commiting config via `config.commit`
+
 0.0
 ---
 
 
 #. Define your facebook canvas view::
 
-      from pyramid_facebook import facebook_canvas
+      from pyramid_facebook.canvas import facebook_canvas
 
       @facebook_canvas()
       def canvas(context, request):

File pyramid_facebook/__init__.py

 
     """
     settings = config.registry.settings
-    log.debug('Configuration settings: %s',pprint.pformat(settings))
+    log.debug('Configuration settings: %s', pprint.pformat(settings))
 
     config.set_authentication_policy(FacebookAuthenticationPolicy())
     config.set_authorization_policy(ACLAuthorizationPolicy())
     config.include('pyramid_facebook.canvas',    route_prefix=facebook_path)
     config.include('pyramid_facebook.credits',   route_prefix=facebook_path)
     config.include('pyramid_facebook.real_time', route_prefix=facebook_path)
+    config.commit()

File pyramid_facebook/security.py

                     )
         return None
 
+    @reify
+    def user(self):
+        return self.facebook_data['user']
+
+    @reify
+    def user_country(self):
+        return self.user['country']
+
     def __repr__(self):
         return '<%s facebook_data=%r>' % (
             self.__class__.__name__,

File pyramid_facebook/tests/unittests/test_security.py

     from pyramid_facebook.lib import encrypt_signed_request
     return encrypt_signed_request(
         conf['facebook.secret_key'],
-        {'user_id': user_id if user_id else TEST_USER}
+        {
+            'user_id': user_id if user_id else TEST_USER,
+            'user': {
+                'country': 'ca'
+                }
+            }
         )
 
 def _get_request(signed_request=None):
             ctx.__acl__
             )
         self.assertEqual(
-            {u'user_id': 123, u'algorithm': u'HMAC-SHA256'},
+            {u'user_id': 123, u'algorithm': u'HMAC-SHA256', u'user': {u'country': u'ca'}},
             ctx.facebook_data
             )
+        self.assertEqual({u'country': u'ca'}, ctx.user)
+        self.assertEqual(u'ca', ctx.user_country)
 
     def test_init_malformated_signed_request(self):
         from pyramid_facebook.security import SignedRequestContext
         ctx = SignedRequestContext(_get_request())
 
         self.assertEqual(
-            "<SignedRequestContext facebook_data={u'user_id': 123, u'algorithm': u'HMAC-SHA256'}>",
+            "<SignedRequestContext facebook_data={u'user_id': 123, u'user': {u'country': u'ca'}, u'algorithm': u'HMAC-SHA256'}>",
             ctx.__repr__()
             )