Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG+1] Improvements for docs on how to access settings #1302

Merged
merged 1 commit into from Jul 3, 2015

Conversation

@eliasdorneles
Copy link
Member

@eliasdorneles eliasdorneles commented Jun 14, 2015

Hey folks,

Here are some improvements to the settings docs, attempts to address the issues from #1300 .

Summary of the changes:

  • added example of accessing settings from a spider
  • adapted example of extension accessing settings to a more realistic-like scenario
  • rewrote some explanations to make easier to understand in the simpler cases
  • added watch in the help for docs Makefile

Does this look good?


class MyExtension(object):
def __init__(self, log_is_enabled=False):
if log_is_enabled:
print "log is enabled!"

This comment has been minimized.

@kmike

kmike Jun 15, 2015
Member

let's use Python 2+3 compatible example:

print("log is enabled!")
@kmike
Copy link
Member

@kmike kmike commented Jun 15, 2015

👍

@eliasdorneles eliasdorneles force-pushed the eliasdorneles:improving-access-settings-docs branch from ab6867e to 2de5c66 Jun 15, 2015
@eliasdorneles
Copy link
Member Author

@eliasdorneles eliasdorneles commented Jun 15, 2015

@kmike updated and rebased

@kmike kmike changed the title Improvements for docs on how to access settings [MRG+1] Improvements for docs on how to access settings Jun 15, 2015

@classmethod
def from_crawler(cls, crawler):
settings = crawler.settings
if settings['LOG_ENABLED']:
print "log is enabled!"
return cls(settings.getbool('LOG_ENABLED'))

This comment has been minimized.

@nramirezuy

nramirezuy Jun 15, 2015
Contributor

Why don't we use a useful example here?, disabling MyExtension.

if not settings.getbool('MYEXT_ENABLED'):
    raise NotConfigured

This comment has been minimized.

@eliasdorneles

eliasdorneles Jun 15, 2015
Author Member

Hmm, that example is more useful, but I don't know... I'm afraid this would attract too much attention to the subject of writing an extension.
I kinda prefer the "lame print", a bit more straightforward to follow.

curita added a commit that referenced this pull request Jul 3, 2015
…-docs

[MRG+1] Improvements for docs on how to access settings
@curita curita merged commit 8b3ca4f into scrapy:master Jul 3, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.