Skip to content

Commit efe07ce

Browse files
committed
Add pyramid test project
1 parent 4344f7e commit efe07ce

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

test-pyramid/main.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import os
2+
3+
import sentry_sdk
4+
from pyramid.config import Configurator
5+
from pyramid.response import Response
6+
from waitress import serve
7+
8+
sentry_sdk.init(
9+
dsn=os.environ.get("SENTRY_DSN"),
10+
environment=os.environ.get("ENV", "test"),
11+
traces_sample_rate=1.0,
12+
profiles_sample_rate=1.0,
13+
debug=True,
14+
_experiments={"trace_lifecycle": "stream"},
15+
)
16+
17+
18+
def index(request):
19+
return Response("Hello from Pyramid!")
20+
21+
22+
def error(request):
23+
raise ValueError("help! an error!")
24+
25+
26+
def message(request):
27+
name = request.matchdict.get("name", "World")
28+
return Response(f"Hello, {name}!")
29+
30+
31+
def create_app():
32+
with Configurator() as config:
33+
config.add_route("index", "/")
34+
config.add_view(index, route_name="index")
35+
36+
config.add_route("error", "/error")
37+
config.add_view(error, route_name="error")
38+
39+
config.add_route("message", "/message/{name}")
40+
config.add_view(message, route_name="message")
41+
42+
app = config.make_wsgi_app()
43+
44+
return app
45+
46+
47+
if __name__ == "__main__":
48+
app = create_app()
49+
print("Serving on http://localhost:8000")
50+
serve(app, host="0.0.0.0", port=8000)

test-pyramid/pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[project]
2+
name = "test-pyramid"
3+
version = "0"
4+
requires-python = ">=3.12"
5+
6+
dependencies = [
7+
"ipdb>=0.13.13",
8+
"pyramid>=2.0",
9+
"sentry-sdk[pyramid]",
10+
"waitress>=3.0",
11+
]
12+
13+
[tool.uv.sources]
14+
sentry-sdk = { path = "../../sentry-python", editable = true }

test-pyramid/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# exit on first error
4+
set -euo pipefail
5+
6+
# Install uv if it's not installed
7+
if ! command -v uv &> /dev/null; then
8+
curl -LsSf https://astral.sh/uv/install.sh | sh
9+
fi
10+
11+
# Run the script
12+
uv run python main.py

0 commit comments

Comments
 (0)