def real_call(self, request, *args, **kwargs): instance = copy.copy(self) instance.request = request instance.storage = get_storage(instance.storage_name, instance.get_wizard_name(), instance.request) response = instance.process_request(*args, **kwargs) response = instance.storage.update_response(response) return instance, response
def get_storage_should_return_correct_class(): assert get_storage('formwizard.storage.Storage') == Storage assert get_storage('formwizard.storage.CookieStorage') == CookieStorage assert get_storage('formwizard.storage.DummyStorage') == DummyStorage assert get_storage('formwizard.storage.SessionStorage') == SessionStorage with Assert.raises(MissingStorageModule): get_storage('formwizard.idontexist.NonExistentStorage') with Assert.raises(MissingStorageClass): get_storage('formwizard.storage.NonExistentStorage')
def get_storage(self): if self.storage is None: view = '%s.%s' % (self.__class__.__module__, self.__class__.__name__) raise ImproperlyConfigured("%s.storage is not specified." % view) if isinstance(self.storage, basestring): storage_class = get_storage(self.storage) return storage_class(name=self.name, namespace=self.namespace, file_storage=self.get_file_storage()) else: return self.storage
def __call__(self, request, *args, **kwargs): """ This method gets called by the routing engine. The first argument is `request` which contains a `HttpRequest` instance. The request is stored in `self.request` for later use. After processing the request using the `process_request` method, the response gets updated by the storage engine (for example add cookies). """ self.request = request self.storage = get_storage(self.storage_name, self.get_wizard_name(), self.request) response = self.process_request(*args, **kwargs) response = self.storage.update_response(response) return response
def __call__(self, request, *args, **kwargs): """ This method gets called by the routing engine. The first argument is `request` which contains a `HttpRequest` instance. The request is stored in `request` for later use. After processing the request using the `process_request` method, the response gets updated by the storage engine (for example add cookies). """ storage = get_storage(self.storage_name, self.get_wizard_name(), request, getattr(self, 'file_storage', None)) response = self.process_request(request, storage, *args, **kwargs) storage.update_response(response) if kwargs.get('testmode', False): return response, storage else: return response
def dispatch(self, request, *args, **kwargs): """ This method gets called by the routing engine. The first argument is `request` which contains a `HttpRequest` instance. The request is stored in `self.request` for later use. The storage instance is stored in `self.storage`. After processing the request using the `dispatch` method, the response gets updated by the storage engine (for example add cookies). """ # add the storage engine to the current wizardview instance self.prefix = self.get_prefix(*args, **kwargs) self.storage = get_storage(self.storage_name, self.prefix, request, getattr(self, 'file_storage', None)) self.steps = StepsHelper(self) response = super(WizardView, self).dispatch(request, *args, **kwargs) # update the response (e.g. adding cookies) self.storage.update_response(response) return response
def test_load_storage(self): self.assertEqual( type(get_storage('formwizard.storage.base.BaseStorage', 'wizard1')), BaseStorage)