API - . , , .
. Facebook, publish.py " ". , . :.
def authorise_application(user):
def post_anwser(anwser):
:
# views.py
def post_anwser(request):
...
if form.is_valid():
form.save()
publish.post_anwser(form.instance)
, :
def ignore_api_error(fun):
def res(*args, **kwargs):
try:
return fun(*args, **kwargs):
except someservice.ApiError:
return None
return res
@ignore_api_error
def authorised_application(user):
@ignore_api_error
def posted_anwser(user, anwser):
, , :
def some_function(user, message):
pass
def my_view():
...
publish.ignore_api_error(publish.some_function)(user, message)
...