From 5ac91e488339c71c9fef9cb41a320e6ee9ed8278 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Mon, 23 Mar 2015 18:11:35 +0500 Subject: [PATCH] DOC remove Dynamic Creation of Item Classes section It was a hack, and dicts-as-items cover most use cases. Dicts don't allow to attach metadata to fields, but e.g. adding "_meta" key and removing it in a custom serializer is no worse than creating classes dynamically. --- docs/topics/practices.rst | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/docs/topics/practices.rst b/docs/topics/practices.rst index 9e65c07be..3ec7bc29b 100644 --- a/docs/topics/practices.rst +++ b/docs/topics/practices.rst @@ -183,21 +183,3 @@ If you are still unable to prevent your bot getting banned, consider contacting .. _testspiders: https://github.com/scrapinghub/testspiders .. _Twisted Reactor Overview: http://twistedmatrix.com/documents/current/core/howto/reactor-basics.html .. _Crawlera: http://crawlera.com - -.. _dynamic-item-classes: - -Dynamic Creation of Item Classes -================================ - -For applications in which the structure of item class is to be determined by -user input or other changing conditions you can return regular Python -dicts from spiders. - -Another option is to dynamically create Item classes:: - - from scrapy.item import DictItem, Field - - def create_item_class(class_name, field_list): - fields = {field_name: Field() for field_name in field_list} - - return type(class_name, (DictItem,), {'fields': fields})