lukearno / selector Goto Github PK
View Code? Open in Web Editor NEWWSGI request delegation. (AKA routing.)
License: GNU General Public License v2.0
WSGI request delegation. (AKA routing.)
License: GNU General Public License v2.0
I guess these need to be rebuilt upon release, but I want it to be thoughtful and intentional. How do I detect out of date generated docs and complain when trying to release. ...I guess just generate them to a different temp folder and do some diffing?
For the moment, I will do it manually and open a ticket to add it to preflight checks.
Hi. It seems like the dot in number pattern was accedentally left unescaped.
As is the pattern will not only match .9
or 00.12
but also 123!45
, because unescaped dot matches any character.
More approrpiate pattern would be r'\d*\.?\d+'
fab clean
and fab html_coverage
not working on Ubuntu. Fabric uses bash on OS X, I guess.
It appears the latest release (v0.9.3, pulled from PyPI) is faulty. v0.8.11 is the last release to install without problems.
$ pip install selector
Downloading/unpacking selector
Downloading selector-0.9.3.tar.gz
Running setup.py egg_info for package selector
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "build/selector/setup.py", line 6, in <module>
with open('VERSION', 'rb') as version_file:
IOError: [Errno 2] No such file or directory: 'VERSION'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "build/selector/setup.py", line 6, in <module>
with open('VERSION', 'rb') as version_file:
IOError: [Errno 2] No such file or directory: 'VERSION'
----------------------------------------
Command python setup.py egg_info failed with error code 1
Util dir is a code smell. Move the CSV in under the tests and the python script into the fabfile.
Test installing to a fresh virt from pypi and importing.
Hi,
I have been writing a JSON REST api, using selector and yaro, plus a middleware of my own (to jsonify the easy way).
The fact is that I made some decorators int Bottle/Flask way (@app.get(url)), and the add_rule called for the same url, different verbs behaves as it souldn't. Here's an example:
from selector import Selector
def get_test(environ, start_response):
return None
def post_test(environ, start_response):
return None
app = Selector()
app.add('/', GET=get_test, POST=post_test)
print app.mappings
app = Selector()
app.add('/', GET=get_test)
app.add('/', POST=post_test)
print app.mappings
This is the result of those prints (prettyprinted):
[
(
<_sre.SRE_Pattern object at 0xb709d440>,
{
'POST': <function post_test at 0xb7062a04>,
'GET': <function get_test at 0xb7062aac>
}
)
]
[
(
<_sre.SRE_Pattern object at 0xb709d440>,
{
'GET': <function get_test at 0xb7062aac>
}
),
(
<_sre.SRE_Pattern object at 0xb709d440>,
{
'POST': <function post_test at 0xb7062a04>
}
)
]
As you can see, the same url ("/") gets two entries in the second app, causing a 405 in one of the methods (obviously, gets a hit in the first rule, but finds no method for the verb; does not continue checking).
Please take a look, although is not a critical issue
I updated PyPI manually last night, but I need to update setup.py too.
s = selector.Selector()
s.add("/foos/{fooid}", name='afoo')
assert s.url('afoo', fooid=11) == '/foo/'
Maybe parser can optionally return something like this instead of a regex string:
class EndPoint(object):
def __init__(self, construct=True):
self._construct = construct
def match(self, path_info):
# for simple parser, compile and use regex here
def url(self, *a, **kw):
if self._construct is True:
# build url with string.Template
else:
# raise something
I think type tuples for the parser could have an optional third: ('digit', '\d+', '%d')
. Defaulting to '%s'
, so ('word', '\w+')
is the same as ('word', '\w+', '%s')
.
The parser can implement this by building up a template for string.Template
as it goes, unless it hits a conditional portion ([]
square brackets), in which case it produces an EndPoint(contruct=False)
Partials seem like an obvious bonus here:
s.add('/books/{book}/chapters/{chapter}', GET=show_chapter)
chapter_url = s.url_parial('chapter', book=2)
assert chapter_url(chapter=15) == "/books/2/chapters/15"
Also, how do we support this in the mapping file format?
story: /stories/{story}
GET mymodule:show_story
might be the same as
s.add('/stories/{story}', name='story', GET=show_story)
... and if that is going to work, then I guess this wil
s.add('story: /stories/{story}', GET=show_story)
I don't think there is any existing reason to put whitespace in a path expression line in a mapping file, so I think len(pathexpr.strip().split())
should serve as a sufficient test for this case.
Question 1 on the RTD FAQ: you need to get whitelisted to install you project in a virtualenv so autodoc will work.
http://read-the-docs.readthedocs.org/en/latest/faq.html#my-project-isn-t-building-with-autodoc
Directory create by fab html_coverage
is not ignored by git.
Files and directories created by fab regenerate_api_docs
.
Add htmlcov
and docs/_build
to .gitignore.
I am not sure that I can build these docs on RTD when I am autodoc-ing the tests unless I properly install them. I don't think I want to A) make the test suite it's own package with it's own setup.py
or B) make the tests an installed part of Selector. If there is some way to install the tests selectively, or some other way to get RTD to build them, that would be cool.
I am going to back off of this, for now, and keep the issue open. I want to treat the tests as first class code and document them in this way, but, until I figure out how, I am going to be pragmatic and at least build the selector
module's public API docs in the mean time.
...OTOH, maybe should the API docs just be limited to the Public API that which I want to consider Selector's public API, WRT SemVer. I may potentially just choose to close this and leave it that way...
Just check the setting for RTD under Admin->Service Hooks
.
Preflight checks in fabfile should check that the gpg-agent
is available and git config user.signingkey
can be used to sign something. Git tag and src and egg distributions for pypi can then be signed.
Add docstring for _freshvirt()
and remove that puts(virt)
.
Regexes for types and path expressions should usable inline.
Path expressions that start with ^
should be taken as raw regexes. IOW, this should work without specifying any custom parser.
s.add(r'^\/endpoint\/$', ...)
Regexes for types should be definable inline with perlish slashes like this:
s.add('/foo/{fooname:/ANYREGEX/}', ...
Either case would set construct=False
WRT the proposed URL generation feature (so, no URL generation)
This will avoid confusion when newcomers look in that directory on GitHub.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.