django-payments
django-payments copied to clipboard
Replace `get_payment_model` with a parametrized `process_data` view
Currently we require an explicit setting pointing to a payment model but there is no technical requirement for that. Instead we could offer a view that accepts the model and let people bind the URLs themselves:
def build_urls(payment_model):
return patterns(
'',
url(
r'^process/(?P<token>[\w-]+)$',
process_data, {'model': payment_model},
name='process_payment'),
url(r'^static/(?P<variant>[\w-]+)$', static_callback,
name='static_process_payment'))
urlpatterns = patterns(
'',
url('^payment/', include(build_urls(MyPayment))),
...)
@mociepka, what do you think? This would allow us to have more than one payment model in the same project and get rid of this awkward API of specifying Python paths in a settings file.
@patrys now it is more "Django way" like with user. Yours solution looks simpler I don't see any contraindications.
One of the many cases of "Django" versus "pythonic" ;)