Skip to content

ReactPy Support #195

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

Merged
merged 100 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
2475d18
needs polishing
ZeroIntensity Jun 15, 2024
d3e60e3
remove program.prof
ZeroIntensity Jun 15, 2024
7391c0a
add some error handling shenanigans
ZeroIntensity Jun 15, 2024
342ed91
add test.py for testing purposes
ZeroIntensity Jun 16, 2024
7fe9286
add many docstrings
ZeroIntensity Jun 16, 2024
542d7b0
even more docstrings
ZeroIntensity Jun 16, 2024
1a75cdf
fix circular imports
ZeroIntensity Jun 16, 2024
9f6efdf
c api changes
ZeroIntensity Jun 16, 2024
55fb261
remove dead html folder
ZeroIntensity Jun 16, 2024
94645da
fix redef
ZeroIntensity Jun 16, 2024
c3ce6b7
add pth file
ZeroIntensity Jun 16, 2024
55b7f54
nevermind it doesn't work
ZeroIntensity Jun 16, 2024
87bd1be
working reactpy support
ZeroIntensity Jun 16, 2024
cc49d45
run formatter
ZeroIntensity Jun 16, 2024
90f1315
remove test.py
ZeroIntensity Jun 16, 2024
cc110a5
finish reactpy integration
ZeroIntensity Jun 16, 2024
13cf4ed
add some c api docstrings
ZeroIntensity Jun 17, 2024
affe5bf
broken as of now
ZeroIntensity Jun 17, 2024
da12deb
still a bit broken
ZeroIntensity Jun 17, 2024
5773ea6
literally like all tests failing
ZeroIntensity Jun 17, 2024
f50ab89
add expect_errors for fun
ZeroIntensity Jun 17, 2024
5a05d20
run formatter
ZeroIntensity Jun 17, 2024
b119d6f
i hate the vscode c formatter
ZeroIntensity Jun 17, 2024
0bde2da
fix is_http with error responses
ZeroIntensity Jun 18, 2024
a07dfdc
refactor c api
ZeroIntensity Jun 18, 2024
6c7e261
more c api docstrings
ZeroIntensity Jun 18, 2024
783e183
docstrings galore
ZeroIntensity Jun 18, 2024
84bd92f
they call me docstring hudson
ZeroIntensity Jun 18, 2024
db3bef2
add map docstrings
ZeroIntensity Jun 19, 2024
c0671c4
guess what
ZeroIntensity Jun 19, 2024
ae7b574
bugfixes for new features
ZeroIntensity Jun 19, 2024
ce03fa7
fix import
ZeroIntensity Jun 19, 2024
25401ce
fix response
ZeroIntensity Jun 19, 2024
2839b68
fix cookies
ZeroIntensity Jun 19, 2024
fbcfec4
actually fix cookies
ZeroIntensity Jun 19, 2024
74e2881
trying to get live reload working
ZeroIntensity Jun 19, 2024
1aa1ac6
fix server logging
ZeroIntensity Jun 19, 2024
434e44e
Add module slots
ZeroIntensity Jun 22, 2024
b2f6db1
Implement #186 - use a PEP 7 compliant uncrustify configuration
ZeroIntensity Jun 22, 2024
67fb206
Update changelog with C API reformat
ZeroIntensity Jun 22, 2024
c3e7e0c
Add -g3 flag to _view
ZeroIntensity Jun 22, 2024
5db8792
Clean up .gitignore
ZeroIntensity Jun 22, 2024
bfc1f94
Remove dead ext/ folder
ZeroIntensity Jun 22, 2024
5d0ced5
Add NULL check for PyModule_Create
ZeroIntensity Jun 22, 2024
c5a3d27
Remove module slots, since they don't work on PyModule_Create
ZeroIntensity Jun 22, 2024
8e29aab
Remove escape() from needs_dep()
ZeroIntensity Jun 22, 2024
ee081e5
Fix reference leak in handle_result
ZeroIntensity Jun 23, 2024
6bfd080
Fix PyDict_Next position in PyTuple_SET_ITEM
ZeroIntensity Jun 23, 2024
958d17c
Fix cookie parsing
ZeroIntensity Jun 23, 2024
e0c485b
Upgrade PyAwaitable vendor and fix reference leaks
ZeroIntensity Jun 25, 2024
6b421b5
There's a tornado nearby so I have to commit in case my laptop gets d…
ZeroIntensity Jun 26, 2024
30c0eb9
Update changelog and update log messages
ZeroIntensity Jun 26, 2024
16cd310
Partial implementation of #51
ZeroIntensity Jun 26, 2024
5ce5d21
Fix reference and leak and only use -O3 in release builds
ZeroIntensity Jun 27, 2024
a52123c
Fix header iterable containing strings instead of bytes
ZeroIntensity Jun 27, 2024
10dfc82
Add new except clause to public Typecode API
ZeroIntensity Jun 27, 2024
f596e66
Fix missing pos initializer for PyDict_Next
ZeroIntensity Jun 27, 2024
c3536b7
Add debugging information to workflows
ZeroIntensity Jun 27, 2024
bcdf65f
Fix missing exception in cast_from_typecodes
ZeroIntensity Jun 27, 2024
3389b04
Fix test segfaults
ZeroIntensity Jun 27, 2024
0f42894
Switch to PyErr_Clear() to fix union support
ZeroIntensity Jun 27, 2024
1ddbddc
Fix parameter mismatch in build_data_inputs()
ZeroIntensity Jun 27, 2024
8cf1fc6
Add backport.h to route implementation.
ZeroIntensity Jul 8, 2024
e7ec43c
Update CHANGELOG
ZeroIntensity Jul 10, 2024
a9806ea
Add test for isinstance() on a type that supports __view_result__
ZeroIntensity Jul 10, 2024
5f602d2
Add test for call_result()
ZeroIntensity Jul 10, 2024
1c7658e
Add ctx parameter to the call_result() test
ZeroIntensity Jul 10, 2024
609801a
Fix context data reference counting.
ZeroIntensity Jul 11, 2024
c83fdbd
Fix some more reference problems.
ZeroIntensity Jul 12, 2024
b71512b
Switch to Hatch (#190)
ZeroIntensity Jul 14, 2024
7aadb2b
Remove coverage file.
ZeroIntensity Jul 14, 2024
4a45f6f
Update workflows to build with Hatch.
ZeroIntensity Jul 14, 2024
5f4924d
Fix TOML formatting.
ZeroIntensity Jul 14, 2024
1c570fe
Fix stolen reference problem with PyErr_GetRaisedException()
ZeroIntensity Jul 15, 2024
7405d12
Merge branch 'master' into reactpy
ZeroIntensity Jul 16, 2024
e657129
I made these changes a while ago so I don't remember.
ZeroIntensity Jul 29, 2024
191deb8
Update contributors file.
ZeroIntensity Aug 3, 2024
252d5d6
Update the classifiers.
ZeroIntensity Aug 3, 2024
f34bb82
Switch to PyAwaitable PyPI build.
ZeroIntensity Aug 4, 2024
775a162
Add PYAWAITABLE_THIS_FILE_INIT define.
ZeroIntensity Aug 4, 2024
6f3bfb6
Update testing workflow.
ZeroIntensity Aug 5, 2024
9c20364
Shenanigans.
ZeroIntensity Aug 5, 2024
b9b43de
Still broken.
ZeroIntensity Aug 8, 2024
2555575
Fix merge conflicts.
ZeroIntensity Aug 23, 2024
e9501b2
Fix failing build.
ZeroIntensity Aug 23, 2024
4489e18
Temporarily fix failing build.
ZeroIntensity Aug 23, 2024
dc484c7
Reformat code.
ZeroIntensity Aug 24, 2024
c8a89dd
Change build type to RelWithDebInfo
ZeroIntensity Aug 24, 2024
4061dda
Remove useless build script.
ZeroIntensity Aug 24, 2024
2e3d47a
Run formatter.
ZeroIntensity Aug 24, 2024
54284f4
Shenanigans.
ZeroIntensity Sep 21, 2024
bb8b82c
Run formatter.
ZeroIntensity Sep 22, 2024
8700413
Check for Pydantic 2.0 sentinel in typecodes.
ZeroIntensity Oct 26, 2024
d241d3e
Changes to build steps.
ZeroIntensity Oct 26, 2024
218064e
Remove valgrind shenanigans.
ZeroIntensity Oct 26, 2024
ac6be1c
Remove suppressions.
ZeroIntensity Oct 26, 2024
dd5e0f0
Fix docs.
ZeroIntensity Oct 26, 2024
74ac546
Bump classifiers and PyAwaitable version.
ZeroIntensity Oct 31, 2024
c2da1c6
Switch to multi phase init
ZeroIntensity Nov 4, 2024
f933736
Break the rest of the code.
ZeroIntensity Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
i hate the vscode c formatter
  • Loading branch information
ZeroIntensity committed Jun 17, 2024
commit b119d6ff6819388a777ca5551d7b3a0f7b303f9a
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed unstable `components` functions from top-level `view` module
- Added native support for `ReactPy` component routes
- Added the `expect_errors` utility
- Added the `HeaderDict` class
- Changed the `headers` attribute on `Context` to a `HeaderDict` instance of a `dict`
- **Breaking Change:** Renamed `Error` to `HTTPError`
- **Breaking Change:** `__view_result__` is now given a `Context` parameter
- **Breaking Change:** `to_response` is now asynchronous
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/creating_a_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ pipx run view-py init

view.py doesn't actually need any big project structure. In fact, you can run an app in just a single Python file, but larger structures like this might be more convenient for big projects. The only real requirement for something to be a view app is that it calls `new_app`, but again, more on that later.

Some "hello world" code for manually starting a view project would look like this:
Some "hello world" code for manually starting a view.py project would look like this:

```py
from view import new_app
Expand Down
7 changes: 7 additions & 0 deletions src/_view/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,13 @@ HOT static PyObject* app(
return NULL;
}

if (PyAwaitable_SaveIntValues(awaitable, 1, is_http) < 0) {
Py_DECREF(awaitable);
return NULL;
}

printf("is_http: %d, r->is_http: %d\n", is_http, r->is_http);

if (r->inputs_size != 0) {
if (!r->has_body) {
if (handle_route_query(
Expand Down
13 changes: 6 additions & 7 deletions src/_view/awaitable.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
Follows PEP 7, not the _view style.
*/
#include "Python.h"
#include "pyerrors.h"
#include <view/awaitable.h>
#include <view/view.h>
#include <stdarg.h>
#include <stdbool.h>

Expand Down Expand Up @@ -169,7 +169,7 @@ fire_err_callback(PyObject *self, PyObject *await, awaitable_callback *cb)
return 0;
}

static PyObject *
HOT static PyObject *
gen_next(PyObject *self)
{
GenWrapperObject *g = (GenWrapperObject *) self;
Expand Down Expand Up @@ -224,8 +224,8 @@ gen_next(PyObject *self)
}

if (cb->callback == NULL) {
// coro is done, but with a result
// we can disregard the result if theres no callback
// Coro is done, but with a result.
// We can disregard the result if theres no callback
g->gw_current_await = NULL;
PyErr_Clear();
return gen_next(self);
Expand All @@ -252,8 +252,8 @@ gen_next(PyObject *self)
Py_INCREF(aw);
int result = cb->callback((PyObject *) aw, value);
if (result < -1) {
// -2 or lower denotes that the error should be deferred
// regardless of whether a handler is present
// -2 or lower denotes that the error should be deferred,
// regardless of whether a handler is present.
return NULL;
}

Expand Down Expand Up @@ -282,7 +282,6 @@ awaitable_next(PyObject *self)
{
PyAwaitableObject *aw = (PyAwaitableObject *) self;


if (aw->aw_done) {
PyErr_SetString(PyExc_RuntimeError, "cannot reuse awaitable");
return NULL;
Expand Down
9 changes: 7 additions & 2 deletions src/_view/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,11 @@ int route_error(
&method_str) < 0)
return -1;

int is_http;

if (PyAwaitable_UnpackIntValues(awaitable, &is_http) < 0)
return -1;

if (tp == self->error_type)
{
PyObject* status_obj = PyObject_GetAttrString(
Expand Down Expand Up @@ -664,7 +669,7 @@ int route_error(
NULL,
message,
method_str,
r->is_http) < 0)
is_http) < 0)
{
Py_DECREF(status_obj);
Py_DECREF(msg_obj);
Expand All @@ -676,7 +681,7 @@ int route_error(
return 0;
}

if (!r->is_http)
if (!is_http)
{
// send a websocket error code
PyObject* send_dict;
Expand Down
Loading