removed some old code from scrapy.spider.models

This commit is contained in:
Pablo Hoffman 2009-12-02 23:30:00 -02:00
parent 41894c776e
commit fe88aad27d
1 changed files with 2 additions and 20 deletions

View File

@ -14,32 +14,14 @@ from scrapy.utils.trackref import object_ref
def _valid_domain_name(obj):
"""Check the domain name specified is valid"""
if not obj.domain_name:
raise ValueError("A site domain name is required")
def _valid_download_delay(obj):
"""Check the download delay is valid, if specified"""
delay = getattr(obj, 'download_delay', 0)
if not type(delay) in (int, long, float):
raise ValueError("download_delay must be numeric")
if float(delay) < 0.0:
raise ValueError("download_delay must be positive")
raise ValueError("Spider 'domain_name' attribute is required")
class ISpider(Interface, IPlugin) :
"""Interface to be implemented by site-specific web spiders"""
domain_name = Attribute(
"""The domain name of the site to be scraped.""")
download_delay = Attribute(
"""Optional delay in seconds to wait between web page downloads.
Note that this delay does not apply to image downloads.
A delay of less than a second can be specified.""")
user_agent = Attribute(
"""Optional User-Agent to use for this domain""")
domain_name = Attribute("The domain name of the site to be scraped.")
invariant(_valid_domain_name)
invariant(_valid_download_delay)
class BaseSpider(object_ref):
"""Base class for scrapy spiders. All spiders must inherit from this