Changeset 1838:e1c89f3252ea

Show
Ignore:
Timestamp:
11/06/09 16:39:15 (9 months ago)
Author:
Pablo Hoffman <pablo@…>
Branch:
default
Message:

removed deprecated ScrapedItem? (previously kept for backwards compatibility)

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • examples/googledir/googledir/settings.py

    r1606 r1838  
    88SPIDER_MODULES = ['googledir.spiders'] 
    99NEWSPIDER_MODULE = 'googledir.spiders' 
    10 DEFAULT_ITEM_CLASS = 'scrapy.item.ScrapedItem' 
     10DEFAULT_ITEM_CLASS = 'scrapy.item.Item' 
    1111USER_AGENT = '%s/%s' % (BOT_NAME, BOT_VERSION) 
    1212 
  • scrapy/item.py

    r1581 r1838  
    8484    __metaclass__ = ItemMeta 
    8585 
    86  
    87 class ScrapedItem(BaseItem): 
    88  
    89     def __init__(self, data=None): 
    90         """ 
    91         A ScrapedItem can be initialised with a dictionary that will be 
    92         squirted directly into the object. 
    93         """ 
    94         import warnings 
    95         warnings.warn("scrapy.item.ScrapedItem is deprecated, use scrapy.item.Item instead", 
    96             DeprecationWarning, stacklevel=2) 
    97         if isinstance(data, dict): 
    98             for attr, value in data.iteritems(): 
    99                 setattr(self, attr, value) 
    100         elif data is not None: 
    101             raise TypeError("Initialize with dict, not %s" % data.__class__.__name__) 
    102  
    103     def __repr__(self): 
    104         """ 
    105         Generate the following format so that items can be deserialized 
    106         easily: ClassName({'attrib': value, ...}) 
    107         """ 
    108         reprdict = dict(items for items in self.__dict__.iteritems() \ 
    109             if not items[0].startswith('_')) 
    110         return "%s(%s)" % (self.__class__.__name__, repr(reprdict)) 
    111  
  • scrapy/tests/test_item.py

    r1513 r1838  
    11import unittest 
    22 
    3 from scrapy.item import Item, Field, ScrapedItem 
     3from scrapy.item import Item, Field 
    44 
    55 
     
    128128 
    129129 
    130 # NOTE: ScrapedItem is deprecated and will be removed in the next stable 
    131 # release, and so will these tests. 
    132  
    133 class ScrapedItemTestCase(unittest.TestCase): 
    134  
    135     def test_item(self): 
    136          
    137         class MyItem(ScrapedItem): 
    138             pass 
    139  
    140         item = MyItem() 
    141         self.assertEqual(repr(item), 'MyItem({})') 
    142  
    143         item = ScrapedItem({'key': 'value'}) 
    144         self.assertEqual(item.key, 'value') 
    145  
    146         self.assertRaises(TypeError, ScrapedItem, 10) 
    147  
    148130if __name__ == "__main__": 
    149131    unittest.main()