Добавление функциональности аутентификации для намыливания сервера (Используя Пехлеви)?

Можно объявить атрибут на Вашем ModelForm класс, названный formfield_callback. Это должно быть функцией, которая берет экземпляр модели Field Django в качестве аргумента и возвращает форму Field экземпляр для представления его в форме.

Тогда все, что необходимо сделать, надеются видеть, передало ли образцовое поле в, экземпляр DateField и, если так, возвратите пользовательское поле/виджет. В противном случае образцовое поле будет иметь метод названным formfield, что можно звонить для возврата его поля формы по умолчанию.

Так, что-то как:

def make_custom_datefield(f):
    if isinstance(f, models.DateField):
        # return form field with your custom widget here...
    else:
        return f.formfield()

class SomeForm(forms.ModelForm)
    formfield_callback = make_custom_datefield

    class Meta:
        # normal modelform stuff here...
6
задан David Snabel-Caunt 8 July 2009 в 22:17
поделиться

1 ответ

I have exactly the same problem and I have the following thoughts:

I do not know if SOAP is/should be state-full or stateless, can we open a session and if the user has supplied some form of credential keep her logged in for some period of time?

The other way I am thinking of solving this is through API-keys, say for example giving a key: ABCDKEY and having the url as:

http://####/services/soap-server/ABCDKEY

This introduces security risks (the magic link attack), but I've seen it implemented in RSS personalized feeds etc. Any comments?

0
ответ дан 17 December 2019 в 00:13
поделиться
Другие вопросы по тегам:

Похожие вопросы: