github
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/simonw/datasette/pull/1842#issuecomment-1278306180 | https://api.github.com/repos/simonw/datasette/issues/1842 | 1278306180 | IC_kwDOBm6k_c5MMWeE | 22429695 | 2022-10-14T00:11:46Z | 2022-10-24T02:04:52Z | NONE | # [Codecov](https://codecov.io/gh/simonw/datasette/pull/1842?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) Report Base: **92.52**% // Head: **92.54**% // Increases project coverage by **`+0.02%`** :tada: > Coverage data is based on head [(`3623475`)](https://codecov.io/gh/simonw/datasette/pull/1842?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) compared to base [(`79aa0de`)](https://codecov.io/gh/simonw/datasette/commit/79aa0de083d38a9975915d5a4cc68ca6c74fbe3d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). > Patch coverage: 100.00% of modified lines in pull request are covered. <details><summary>Additional details and impacted files</summary> ```diff @@ Coverage Diff @@ ## main #1842 +/- ## ========================================== + Coverage 92.52% 92.54% +0.02% ========================================== Files 35 35 Lines 4415 4428 +13 ========================================== + Hits 4085 4098 +13 Misses 330 330 ``` | [Impacted Files](https://codecov.io/gh/simonw/datasette/pull/1842?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) | Coverage Δ | | |---|---|---| | [datasette/app.py](https://codecov.io/gh/simonw/datasette/pull/1842/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL2FwcC5weQ==) | `94.28% <100.00%> (+0.05%)` | :arrow_up: | | [datasette/views/database.py](https://codecov.io/gh/simonw/datasette/pull/1842/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3ZpZXdzL… | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1408561039 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279598878 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279598878 | IC_kwDOBm6k_c5MRSEe | 9599 | 2022-10-14T23:51:46Z | 2022-10-14T23:51:46Z | OWNER | Blogged about this here: https://simonwillison.net/2022/Oct/14/automating-screenshots/ | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279427618 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279427618 | IC_kwDOBm6k_c5MQoQi | 9599 | 2022-10-14T20:25:45Z | 2022-10-14T20:25:45Z | OWNER | Extracted a TIL: https://til.simonwillison.net/shot-scraper/subset-of-table-columns | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279415365 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279415365 | IC_kwDOBm6k_c5MQlRF | 9599 | 2022-10-14T20:11:55Z | 2022-10-14T20:11:55Z | OWNER | Twitter thread about this issue: https://twitter.com/simonw/status/1581012617526595584 | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279406134 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279406134 | IC_kwDOBm6k_c5MQjA2 | 9599 | 2022-10-14T20:01:13Z | 2022-10-14T20:01:13Z | OWNER | Here's the YAML I added to https://github.com/simonw/datasette-screenshots/blob/main/shots.yml for this issue: ```yaml - url: https://register-of-members-interests.datasettes.com/regmem/items?_search=hamper&_sort_desc=date height: 585 width: 960 output: regmem-search.png - url: https://register-of-members-interests.datasettes.com/regmem/items?_search=hamper selector: "#export" output: advanced-export.png padding: 10 - url: https://congress-legislators.datasettes.com/legislators/legislator_terms?_facet=type&_facet=party&_facet=state&_facet_size=10 selectors_all: - .suggested-facets a - tr:not(tr:nth-child(n+4)) td:not(:nth-child(n+11)) padding: 10 output: faceting-details.png - url: https://latest.datasette.io/fixtures/binary_data selector: table javascript: |- Array.from( document.querySelectorAll('tr:nth-child(n+3)'), el => el.parentNode.removeChild(el) ); padding: 10 output: binary-data.png ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279405429 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279405429 | IC_kwDOBm6k_c5MQi11 | 9599 | 2022-10-14T20:00:26Z | 2022-10-14T20:00:26Z | OWNER | New images are now live on these pages: - https://docs.datasette.io/en/latest/csv_export.html - https://docs.datasette.io/en/latest/binary_data.html - https://docs.datasette.io/en/latest/facets.html - https://docs.datasette.io/en/latest/full_text_search.html - https://docs.datasette.io/en/latest/changelog.html#v0-23 (was a duplicate of the advanced export image) | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279392717 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279392717 | IC_kwDOBm6k_c5MQfvN | 9599 | 2022-10-14T19:44:44Z | 2022-10-14T19:45:54Z | OWNER | OK, the URLs to use in the docs are: * https://raw.githubusercontent.com/simonw/datasette-screenshots/0.62/advanced-export.png (retina) * https://raw.githubusercontent.com/simonw/datasette-screenshots/0.62/non-retina/regmem-search.png * https://raw.githubusercontent.com/simonw/datasette-screenshots/0.62/binary-data.png (retina) * https://raw.githubusercontent.com/simonw/datasette-screenshots/0.62/non-retina/faceting-details.png | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279349314 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279349314 | IC_kwDOBm6k_c5MQVJC | 9599 | 2022-10-14T18:50:42Z | 2022-10-14T19:34:37Z | OWNER | I'm going to link the documentation screenshots directly to the images in the https://github.com/simonw/datasette-screenshots repository - but I don't want those images to reflect `main` when the documentation may reflect a specific version. So I'm going to start tagging releases of `datasette-screenshots` so I can get permanent URLs to those images. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279383121 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279383121 | IC_kwDOBm6k_c5MQdZR | 9599 | 2022-10-14T19:33:49Z | 2022-10-14T19:33:49Z | OWNER | I'm going to tag `datasette-screenshots` with the current Datasette version, `0.62`. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279311487 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279311487 | IC_kwDOBm6k_c5MQL5_ | 9599 | 2022-10-14T18:06:53Z | 2022-10-14T19:33:24Z | OWNER | I just spotted some other out-dated screenshots in the `docs/` directory: - [x] [advanced_export.png](https://github.com/simonw/datasette/blob/main/docs/advanced_export.png "advanced_export.png") - [x] [binary_data.png](https://github.com/simonw/datasette/blob/main/docs/binary_data.png "binary_data.png") - [x] [facets.png](https://github.com/simonw/datasette/blob/main/docs/facets.png "facets.png") - [x] [full_text_search.png](https://github.com/simonw/datasette/blob/main/docs/full_text_search.png "full_text_search.png") | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279382674 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279382674 | IC_kwDOBm6k_c5MQdSS | 9599 | 2022-10-14T19:33:16Z | 2022-10-14T19:33:16Z | OWNER | That's the last two screenshots: <img src="https://raw.githubusercontent.com/simonw/datasette-screenshots/1b56cd4177089b72de9436749a8995921fe8e870/non-retina/binary-data.png"> <img src="https://raw.githubusercontent.com/simonw/datasette-screenshots/1b56cd4177089b72de9436749a8995921fe8e870/non-retina/faceting-details.png"> | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279348239 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279348239 | IC_kwDOBm6k_c5MQU4P | 9599 | 2022-10-14T18:49:22Z | 2022-10-14T18:49:22Z | OWNER | This works: ``` shot-scraper 'https://congress-legislators.datasettes.com/legislators/legislator_terms?_facet=type&_facet=party&_facet=state&_facet_size=10' \ -s '.suggested-facets a' \ --selector-all 'tr:not(tr:nth-child(n+4)) td:not(:nth-child(n+11))' \ -p 10 ``` ![congress-legislators-datasettes-com-legislators-legislator_terms 6](https://user-images.githubusercontent.com/9599/195919422-97616694-3ec0-4e05-afc2-c509275c767c.png) | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279339124 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279339124 | IC_kwDOBm6k_c5MQSp0 | 9599 | 2022-10-14T18:38:22Z | 2022-10-14T18:42:58Z | OWNER | This seems to get every table cell in that table for the first 3 rows and the columns up to `party`: document.querySelectorAll('tr:not(:nth-child(n+4)) td:not(:nth-child(n+10))') | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279334694 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279334694 | IC_kwDOBm6k_c5MQRkm | 9599 | 2022-10-14T18:33:41Z | 2022-10-14T18:34:32Z | OWNER | I'm going to use this page for the facets screenshot: https://congress-legislators.datasettes.com/legislators/legislator_terms?_facet=type&_facet=party&_facet=state&_facet_size=10 Trying for this bit: <img width="976" alt="image" src="https://user-images.githubusercontent.com/9599/195916927-74636861-c02b-4744-bfac-68e0b6147b48.png"> Which incorporates `.suggested-facets` but also the first 3 rows and 10 columns of the table, I wonder if I can specify that in a single selector? | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279325685 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279325685 | IC_kwDOBm6k_c5MQPX1 | 9599 | 2022-10-14T18:23:22Z | 2022-10-14T18:23:22Z | OWNER | Here's the new advanced export image: <img src="https://github.com/simonw/datasette-screenshots/blob/1fc70adc3f20ee19cadff21653718d5f1a7bcb1f/advanced-export.png?raw=true"> | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279325003 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279325003 | IC_kwDOBm6k_c5MQPNL | 9599 | 2022-10-14T18:22:35Z | 2022-10-14T18:22:35Z | OWNER | So: ``` shot-scraper 'https://latest.datasette.io/fixtures/binary_data' \ -j "Array.from(document.querySelectorAll('tr:nth-child(n+3)'), el => el.parentNode.removeChild(el));" \ -s table -p 10 ``` ![latest-datasette-io-fixtures-binary_data 1](https://user-images.githubusercontent.com/9599/195915092-be81db43-5672-4375-bd66-4316211b1afc.png) | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279323714 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279323714 | IC_kwDOBm6k_c5MQO5C | 9599 | 2022-10-14T18:21:03Z | 2022-10-14T18:21:03Z | OWNER | For this image: <img src="https://github.com/simonw/datasette/blob/79aa0de083d38a9975915d5a4cc68ca6c74fbe3d/docs/binary_data.png?raw=true"> https://latest.datasette.io/fixtures/binary_data has an extra row these days: <img width="537" alt="image" src="https://user-images.githubusercontent.com/9599/195914820-b3f7d820-e229-4668-bf90-a4f3d0e95e79.png"> This deletes every row past the first two (first three including the header row): ```javascipt Array.from(document.querySelectorAll('tr:nth-child(n+3)'), el => el.parentNode.removeChild(el)); ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279314400 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279314400 | IC_kwDOBm6k_c5MQMng | 9599 | 2022-10-14T18:10:07Z | 2022-10-14T18:13:36Z | OWNER | For the advanced export one: shot-scraper 'https://register-of-members-interests.datasettes.com/regmem/items?_search=hamper' -s '#export' -p 10 Produces: ![register-of-members-interests-datasettes-com-regmem-items 2](https://user-images.githubusercontent.com/9599/195913614-448557aa-5ec6-4a83-98cf-8837d3117204.png) Current image is: <img src="https://github.com/simonw/datasette/blob/main/docs/advanced_export.png?raw=true"> | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/simonw/datasette/issues/1844#issuecomment-1279316670 | https://api.github.com/repos/simonw/datasette/issues/1844 | 1279316670 | IC_kwDOBm6k_c5MQNK- | 9599 | 2022-10-14T18:12:39Z | 2022-10-14T18:12:39Z | OWNER | New screenshot of FTS, from https://register-of-members-interests.datasettes.com/regmem/items?_search=hamper&_sort_desc=date <img src="https://raw.githubusercontent.com/simonw/datasette-screenshots/c636f07fa94bd0bfbeea087c245e7212a4190b1e/non-retina/regmem-search.png"> | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1409679008 | |
https://github.com/dogsheep/twitter-to-sqlite/issues/60#issuecomment-1279249898 | https://api.github.com/repos/dogsheep/twitter-to-sqlite/issues/60 | 1279249898 | IC_kwDODEm0Qs5MP83q | 7908073 | 2022-10-14T16:58:26Z | 2022-10-14T16:58:26Z | NONE | You could try using `msys2`. I've had better luck running python CLIs within that system on Windows. Here is a guide: https://github.com/chapmanjacobd/lb/blob/main/Windows.md#prep | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1063982712 | |
https://github.com/dogsheep/github-to-sqlite/issues/51#issuecomment-1279224780 | https://api.github.com/repos/dogsheep/github-to-sqlite/issues/51 | 1279224780 | IC_kwDODFdgUs5MP2vM | 7908073 | 2022-10-14T16:34:07Z | 2022-10-14T16:34:07Z | NONE | also, it says that authenticated requests have a much higher "rate limit". Unauthenticated requests only get 60 req/hour ?? seems more like a quota than a "rate limit" (although I guess that is semantic equivalence) You would want to use `x-ratelimit-reset` ``` time.sleep(r['x-ratelimit-reset'] + 1 - time.time()) ``` But a more complete solution would bring authenticated requests to the other subcommands. I'm surprised only `github-to-sqlite get` is using the `--auth=` CLI flag | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
703246031 | |
https://github.com/simonw/datasette/issues/1843#issuecomment-1278537920 | https://api.github.com/repos/simonw/datasette/issues/1843 | 1278537920 | IC_kwDOBm6k_c5MNPDA | 9599 | 2022-10-14T06:19:55Z | 2022-10-14T06:20:06Z | OWNER | Maybe I need to explicitly close those SQLite connections held by the Datasette instance after this line: https://github.com/simonw/datasette/blob/79aa0de083d38a9975915d5a4cc68ca6c74fbe3d/tests/fixtures.py#L165 | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1408757705 | |
https://github.com/simonw/datasette/issues/1843#issuecomment-1278480437 | https://api.github.com/repos/simonw/datasette/issues/1843 | 1278480437 | IC_kwDOBm6k_c5MNBA1 | 9599 | 2022-10-14T04:51:10Z | 2022-10-14T04:51:10Z | OWNER | Extracted a TIL: https://til.simonwillison.net/python/too-many-open-files-psutil | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1408757705 | |
https://github.com/simonw/datasette/issues/1843#issuecomment-1278478042 | https://api.github.com/repos/simonw/datasette/issues/1843 | 1278478042 | IC_kwDOBm6k_c5MNAba | 9599 | 2022-10-14T04:46:29Z | 2022-10-14T04:46:29Z | OWNER | I did `pip install psutil` and then ran this in the debugger for one of these errors: ```python import psutil for f in psutil.Process().open_files(): print(f) ``` The output looked like this: ``` popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpq31d2af1/fixtures.db', fd=11) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpoxdpxj6w/fixtures.db', fd=12) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpfd3oyo10/fixtures.dot.db', fd=13) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpezwfu7w8/fixtures.db', fd=14) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpq31d2af1/fixtures.db', fd=15) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpq31d2af1/fixtures.db', fd=16) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpz6e2anqw/fixtures.db', fd=17) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpoxdpxj6w/fixtures.db', fd=18) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpdp4we7hb/fixtures.db', fd=19) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpfd3oyo10/fixtures.dot.db', fd=20) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmp4ljq_ai0/fixtures.db', fd=21) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpezwfu7w8/fixtures.db', fd=22) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmp907xmnzb/fixtures.db', fd=24) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpz6e2anqw/extra database.db', fd=25) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpz6e2anqw/fixtures.db', fd=26) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpzlwn6bqm/fixtures.db', fd=27) popenfile(path='/private/var/folders/wr/hn3206rs1yzgq3r49bz8nvnh0000gn/T/tmpdp4we7hb/fixtures.db', fd=28) popenfil… | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1408757705 | |
https://github.com/simonw/datasette/issues/1829#issuecomment-1278302478 | https://api.github.com/repos/simonw/datasette/issues/1829 | 1278302478 | IC_kwDOBm6k_c5MMVkO | 9599 | 2022-10-14T00:06:19Z | 2022-10-14T00:06:19Z | OWNER | I'll finish this in a PR: - https://github.com/simonw/datasette/pull/1842 | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1396948693 | |
https://github.com/simonw/datasette/issues/1829#issuecomment-1278300241 | https://api.github.com/repos/simonw/datasette/issues/1829 | 1278300241 | IC_kwDOBm6k_c5MMVBR | 9599 | 2022-10-14T00:03:52Z | 2022-10-14T00:04:28Z | OWNER | Here's what I've got so far: ```diff diff --git a/datasette/app.py b/datasette/app.py index 5fa4955c..df9eae49 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -1,5 +1,5 @@ import asyncio -from typing import Sequence, Union, Tuple +from typing import Sequence, Union, Tuple, Optional import asgi_csrf import collections import datetime @@ -707,7 +707,7 @@ class Datasette: Raises datasette.Forbidden() if any of the checks fail """ - assert actor is None or isinstance(actor, dict) + assert actor is None or isinstance(actor, dict), "actor must be None or a dict" for permission in permissions: if isinstance(permission, str): action = permission @@ -732,23 +732,34 @@ class Datasette: else: raise Forbidden(action) - async def check_visibility(self, actor, action, resource): + async def check_visibility( + self, + actor: dict, + action: Optional[str] = None, + resource: Optional[str] = None, + permissions: Optional[ + Sequence[Union[Tuple[str, Union[str, Tuple[str, str]]], str]] + ] = None, + ): """Returns (visible, private) - visible = can you see it, private = can others see it too""" - visible = await self.permission_allowed( - actor, - action, - resource=resource, - default=True, - ) - if not visible: + if permissions: + assert ( + not action and not resource + ), "Can't use action= or resource= with permissions=" + else: + permissions = [(action, resource)] + try: + await self.ensure_permissions(actor, permissions) + except Forbidden: return False, False - private = not await self.permission_allowed( - None, - action, - resource=resource, - default=True, -… | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1396948693 |