Permalink
Browse files

first draft on read only mode, handy when load testing etc.

  • Loading branch information...
1 parent b638357 commit 7d89ae2bdcc51ac351225e966fb43cb4ee1954b6 @tschellenbach committed Mar 10, 2012
Showing with 10 additions and 1 deletion.
  1. +1 −1 django_facebook/__init__.py
  2. +3 −0 django_facebook/settings.py
  3. +6 −0 open_facebook/api.py
@@ -4,7 +4,7 @@
__license__ = 'BSD'
-__version__ = '3.5.6'
+__version__ = '3.5.7'
__maintainer__ = 'Thierry Schellenbach'
__email__ = 'thierryschellenbach@gmail.com'
__status__ = 'Production'
@@ -27,6 +27,9 @@
FACEBOOK_DEBUG_REDIRECTS = getattr(settings, 'FACEBOOK_DEBUG_REDIRECTS', False)
FACEBOOK_STORE_ALL_ACCESS_TOKENS = getattr(settings, 'FACEBOOK_STORE_ALL_ACCESS_TOKENS', False)
+#READ only mode, convenient when doing load testing etc.
+FACEBOOK_READ_ONLY = getattr(settings, 'FACEBOOK_READ_ONLY', False)
+
# check for required settings
required_settings = ['FACEBOOK_APP_ID', 'FACEBOOK_APP_SECRET']
locals_dict = locals()
View
@@ -81,6 +81,12 @@ def _request(cls, url, post_data=None, timeout=REQUEST_TIMEOUT,
urllib2 raises errors on different status codes so use a try except
'''
logger.info('requesting url %s with post data %s', url, post_data)
+
+ if post_data is not None and facebook_settings.FACEBOOK_READ_ONLY:
+ response = dict(id=12345)
+ return response
+
+
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Open Facebook Python')]
# give it a few shots, connection is buggy at times

0 comments on commit 7d89ae2

Please sign in to comment.