pyferro 2.2.3__tar.gz → 2.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. {pyferro-2.2.3/src/pyferro.egg-info → pyferro-2.2.4}/PKG-INFO +2 -1
  2. {pyferro-2.2.3 → pyferro-2.2.4}/pyproject.toml +2 -1
  3. {pyferro-2.2.3 → pyferro-2.2.4/src/pyferro.egg-info}/PKG-INFO +2 -1
  4. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro.egg-info/requires.txt +1 -0
  5. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/__init__.py +1 -1
  6. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/jinja_engine.py +230 -5
  7. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/router.py +11 -3
  8. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/site_tree.py +21 -1
  9. {pyferro-2.2.3 → pyferro-2.2.4}/LICENSE +0 -0
  10. {pyferro-2.2.3 → pyferro-2.2.4}/README.md +0 -0
  11. {pyferro-2.2.3 → pyferro-2.2.4}/setup.cfg +0 -0
  12. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro.egg-info/SOURCES.txt +0 -0
  13. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro.egg-info/dependency_links.txt +0 -0
  14. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro.egg-info/top_level.txt +0 -0
  15. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/__main__.py +0 -0
  16. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/auth/__init__.py +0 -0
  17. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/auth/models.py +0 -0
  18. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/auth/passwords.py +0 -0
  19. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/auth/seeder.py +0 -0
  20. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/core/__init__.py +0 -0
  21. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/core/constants.py +0 -0
  22. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/core/session.py +0 -0
  23. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/core/session_data.py +0 -0
  24. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/core/tabular.py +0 -0
  25. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/crud/__init__.py +0 -0
  26. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/crud/engine.py +0 -0
  27. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/crud/rpc.py +0 -0
  28. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/crud/spec.py +0 -0
  29. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/db/__init__.py +0 -0
  30. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/db/base.py +0 -0
  31. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/db/engine.py +0 -0
  32. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/db/pagination.py +0 -0
  33. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/files/__init__.py +0 -0
  34. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/files/models.py +0 -0
  35. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/files/rpc.py +0 -0
  36. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/files/storage.py +0 -0
  37. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/frontend/dist/assets/index-DffKaKDX.js +0 -0
  38. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/frontend/dist/assets/index-n6LSffAT.css +0 -0
  39. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/frontend/dist/index.html +0 -0
  40. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/help/__init__.py +0 -0
  41. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/help/help_data.json +0 -0
  42. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/help/rpc.py +0 -0
  43. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/migrations/__init__.py +0 -0
  44. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/migrations/migration_v2_0_0.py +0 -0
  45. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/migrations/migration_v2_1_0.py +0 -0
  46. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/migrations/migration_v2_2_0.py +0 -0
  47. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/oauth/__init__.py +0 -0
  48. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/oauth/http_client.py +0 -0
  49. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/oauth/mailer.py +0 -0
  50. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/oauth/manager.py +0 -0
  51. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/oauth/models.py +0 -0
  52. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/oauth/providers.py +0 -0
  53. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/oauth/rpc.py +0 -0
  54. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/rpc/__init__.py +0 -0
  55. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/rpc/errors.py +0 -0
  56. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/rpc/router.py +0 -0
  57. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/__init__.py +0 -0
  58. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/detector.py +0 -0
  59. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/indexnow.py +0 -0
  60. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/models.py +0 -0
  61. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/page_cache.py +0 -0
  62. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/renderer.py +0 -0
  63. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/rpc.py +0 -0
  64. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/seo/sitemap.py +0 -0
  65. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/server/__init__.py +0 -0
  66. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/server/app.py +0 -0
  67. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/server/auth_rpc.py +0 -0
  68. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/server/test_client.py +0 -0
  69. {pyferro-2.2.3 → pyferro-2.2.4}/src/pyferro2/server/tokens.py +0 -0
  70. {pyferro-2.2.3 → pyferro-2.2.4}/tests/test_e2e_lifecycle.py +0 -0
  71. {pyferro-2.2.3 → pyferro-2.2.4}/tests/test_pagination.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyferro
3
- Version: 2.2.3
3
+ Version: 2.2.4
4
4
  Summary: High-performance reactive fullstack Python framework on Rust RSGI (Granian) with symmetric WSRPC (JSON-RPC 2.0) and Tabular Data Compression.
5
5
  Author-email: Alex Titoff <a.tit.off@gmail.com>
6
6
  License: MIT
@@ -15,6 +15,7 @@ Requires-Dist: orjson>=3.9.0
15
15
  Requires-Dist: pyjwt>=2.8.0
16
16
  Requires-Dist: cryptography>=42.0.0
17
17
  Requires-Dist: jinja2>=3.1.0
18
+ Requires-Dist: markupsafe>=2.1.0
18
19
  Requires-Dist: sqlalchemy[asyncio]>=2.0.0
19
20
  Requires-Dist: aiosqlite>=0.19.0
20
21
  Requires-Dist: greenlet>=3.0.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyferro"
7
- version = "2.2.3"
7
+ version = "2.2.4"
8
8
  description = "High-performance reactive fullstack Python framework on Rust RSGI (Granian) with symmetric WSRPC (JSON-RPC 2.0) and Tabular Data Compression."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -19,6 +19,7 @@ dependencies = [
19
19
  "pyjwt>=2.8.0",
20
20
  "cryptography>=42.0.0",
21
21
  "jinja2>=3.1.0",
22
+ "markupsafe>=2.1.0",
22
23
  "sqlalchemy[asyncio]>=2.0.0",
23
24
  "aiosqlite>=0.19.0",
24
25
  "greenlet>=3.0.0",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyferro
3
- Version: 2.2.3
3
+ Version: 2.2.4
4
4
  Summary: High-performance reactive fullstack Python framework on Rust RSGI (Granian) with symmetric WSRPC (JSON-RPC 2.0) and Tabular Data Compression.
5
5
  Author-email: Alex Titoff <a.tit.off@gmail.com>
6
6
  License: MIT
@@ -15,6 +15,7 @@ Requires-Dist: orjson>=3.9.0
15
15
  Requires-Dist: pyjwt>=2.8.0
16
16
  Requires-Dist: cryptography>=42.0.0
17
17
  Requires-Dist: jinja2>=3.1.0
18
+ Requires-Dist: markupsafe>=2.1.0
18
19
  Requires-Dist: sqlalchemy[asyncio]>=2.0.0
19
20
  Requires-Dist: aiosqlite>=0.19.0
20
21
  Requires-Dist: greenlet>=3.0.0
@@ -3,6 +3,7 @@ orjson>=3.9.0
3
3
  pyjwt>=2.8.0
4
4
  cryptography>=42.0.0
5
5
  jinja2>=3.1.0
6
+ markupsafe>=2.1.0
6
7
  sqlalchemy[asyncio]>=2.0.0
7
8
  aiosqlite>=0.19.0
8
9
  greenlet>=3.0.0
@@ -15,7 +15,7 @@ from pyferro2.seo import (
15
15
  register_sitemap_provider,
16
16
  )
17
17
 
18
- __version__ = "2.2.3"
18
+ __version__ = "2.2.4"
19
19
 
20
20
  __all__ = [
21
21
  "__version__",
@@ -282,6 +282,17 @@ class ModelQueryWrapper:
282
282
  return self._clone(offset_val=start)
283
283
  raise TypeError("ModelQueryWrapper поддерживает только срезы [:N] или [A:B]")
284
284
 
285
+ @staticmethod
286
+ def _coerce_filter_val(col: Any, v: Any) -> Any:
287
+ if v is None:
288
+ return None
289
+ try:
290
+ if hasattr(col, "type") and hasattr(col.type, "python_type") and col.type.python_type is int:
291
+ return int(v)
292
+ except Exception:
293
+ pass
294
+ return v
295
+
285
296
  async def count(self) -> int:
286
297
  if not self._is_allowed:
287
298
  return 0
@@ -291,7 +302,8 @@ class ModelQueryWrapper:
291
302
  for k, v in self.filters.items():
292
303
  col = getattr(model_cls, k, None)
293
304
  if col is not None:
294
- stmt = stmt.where(col.is_(None) if v is None else col == v)
305
+ c_val = self._coerce_filter_val(col, v)
306
+ stmt = stmt.where(col.is_(None) if c_val is None else col == c_val)
295
307
  val = (await session.execute(stmt)).scalar() or 0
296
308
  return int(val)
297
309
 
@@ -307,8 +319,8 @@ class ModelQueryWrapper:
307
319
  for k, v in self.filters.items():
308
320
  col = getattr(model_cls, k, None)
309
321
  if col is not None:
310
- stmt = stmt.where(col.is_(None) if v is None else col == v)
311
-
322
+ c_val = self._coerce_filter_val(col, v)
323
+ stmt = stmt.where(col.is_(None) if c_val is None else col == c_val)
312
324
  for fld in self.order_by_fields:
313
325
  desc_order = fld.startswith("-")
314
326
  clean_fld = fld[1:] if desc_order else fld
@@ -363,15 +375,228 @@ class ModelQueryWrapper:
363
375
  return _generator()
364
376
 
365
377
 
378
+ import html as _html
379
+ import re as _re
380
+ from markupsafe import Markup
381
+
382
+
383
+ def render_markdown_filter(md_text: Any) -> Markup:
384
+ """
385
+ Конвертирует Markdown в чистый семантический HTML5 для поисковых ботов:
386
+ - Заголовки: # -> <h2>, ## -> <h3>, ### -> <h4>
387
+ - Картинки: ![alt](url) -> <figure><img src="url" alt="alt" ... /><figcaption>alt</figcaption></figure>
388
+ - Ссылки: [text](url) -> <a href="url">text</a>
389
+ - Выделение: **bold**, *italic*, `code`
390
+ - Списки: - пункт
391
+ - Таблицы: | col1 | col2 |
392
+ - Цитаты: > цитата
393
+ """
394
+ if not md_text:
395
+ return Markup("")
396
+ raw = str(md_text)
397
+
398
+ # 1. Извлекаем блоки кода ```lang\ncode\n```
399
+ code_blocks: list[str] = []
400
+
401
+ def _save_code(m: _re.Match[str]) -> str:
402
+ code_body = _html.escape(m.group(2))
403
+ idx = len(code_blocks)
404
+ code_blocks.append(
405
+ f'<pre style="background:#1e293b;color:#f8fafc;padding:14px;border-radius:8px;overflow-x:auto;"><code>{code_body}</code></pre>'
406
+ )
407
+ return f"__CODE_BLOCK_{idx}__"
408
+
409
+ text = _re.sub(r"```([a-zA-Z0-9_-]*)\n([\s\S]*?)```", _save_code, raw)
410
+
411
+ # 2. Инлайн-элементы (картинки, ссылки, стили)
412
+ def _format_inline(s: str) -> str:
413
+ def _img(m: _re.Match[str]) -> str:
414
+ alt = _html.escape(m.group(1), quote=True)
415
+ src = _html.escape(m.group(2), quote=True)
416
+ caption = (
417
+ f'<figcaption style="font-size:13px;color:#64748b;margin-top:6px;">{alt}</figcaption>'
418
+ if alt
419
+ else ""
420
+ )
421
+ return (
422
+ f'<figure style="margin:18px 0;text-align:center;">'
423
+ f'<img src="{src}" alt="{alt}" loading="lazy" style="max-width:100%;height:auto;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.06);" />'
424
+ f"{caption}</figure>"
425
+ )
426
+
427
+ s = _re.sub(r"!\[(.*?)\]\((.*?)\)", _img, s)
428
+
429
+ def _link(m: _re.Match[str]) -> str:
430
+ t = _html.escape(m.group(1))
431
+ u = _html.escape(m.group(2), quote=True)
432
+ return f'<a href="{u}" style="color:#0f766e;text-decoration:underline;">{t}</a>'
433
+
434
+ s = _re.sub(r"\[(.*?)\]\((.*?)\)", _link, s)
435
+ s = _re.sub(r"\*\*(.*?)\*\*", lambda m: f"<strong>{m.group(1)}</strong>", s)
436
+ s = _re.sub(r"__(.*?)__", lambda m: f"<strong>{m.group(1)}</strong>", s)
437
+ s = _re.sub(r"\*(.*?)\*", lambda m: f"<em>{m.group(1)}</em>", s)
438
+ s = _re.sub(r"(?<![a-zA-Z0-9])_(.*?)_(?![a-zA-Z0-9])", lambda m: f"<em>{m.group(1)}</em>", s)
439
+ s = _re.sub(
440
+ r"`(.*?)`",
441
+ lambda m: f'<code style="background:#f1f5f9;color:#0f766e;padding:2px 6px;border-radius:4px;font-size:14px;">{_html.escape(m.group(1))}</code>',
442
+ s,
443
+ )
444
+ return s
445
+
446
+ lines = text.splitlines()
447
+ out_parts: list[str] = []
448
+ in_list = False
449
+ in_table = False
450
+ table_rows: list[list[str]] = []
451
+ para_lines: list[str] = []
452
+
453
+ def _flush_para() -> None:
454
+ nonlocal para_lines
455
+ if para_lines:
456
+ joined = " ".join(para_lines).strip()
457
+ if joined:
458
+ out_parts.append(
459
+ f'<p style="margin-bottom:14px;line-height:1.75;">{_format_inline(joined)}</p>'
460
+ )
461
+ para_lines = []
462
+
463
+ def _flush_list() -> None:
464
+ nonlocal in_list
465
+ if in_list:
466
+ out_parts.append("</ul>")
467
+ in_list = False
468
+
469
+ def _flush_table() -> None:
470
+ nonlocal in_table, table_rows
471
+ if in_table and table_rows:
472
+ html_t = [
473
+ '<table style="width:100%;border-collapse:collapse;margin:18px 0;font-size:14px;">'
474
+ ]
475
+ html_t.append('<thead><tr style="background:#f8fafc;border-bottom:2px solid #e2e8f0;">')
476
+ for cell in table_rows[0]:
477
+ html_t.append(
478
+ f'<th style="padding:10px 12px;text-align:left;font-weight:600;">{_format_inline(cell)}</th>'
479
+ )
480
+ html_t.append("</tr></thead><tbody>")
481
+ for row in table_rows[1:]:
482
+ html_t.append('<tr style="border-bottom:1px solid #f1f5f9;">')
483
+ for cell in row:
484
+ html_t.append(f'<td style="padding:8px 12px;">{_format_inline(cell)}</td>')
485
+ html_t.append("</tr>")
486
+ html_t.append("</tbody></table>")
487
+ out_parts.append("".join(html_t))
488
+ table_rows = []
489
+ in_table = False
490
+
491
+ for line in lines:
492
+ stripped = line.strip()
493
+
494
+ if stripped.startswith("__CODE_BLOCK_"):
495
+ _flush_para()
496
+ _flush_list()
497
+ _flush_table()
498
+ out_parts.append(stripped)
499
+ continue
500
+
501
+ if not stripped:
502
+ _flush_para()
503
+ _flush_list()
504
+ _flush_table()
505
+ continue
506
+
507
+ if stripped.startswith("|") and stripped.endswith("|"):
508
+ _flush_para()
509
+ _flush_list()
510
+ if _re.match(r"^\|[\s\-:|]+\|$", stripped):
511
+ continue
512
+ cells = [c.strip() for c in stripped.strip("|").split("|")]
513
+ table_rows.append(cells)
514
+ in_table = True
515
+ continue
516
+ elif in_table:
517
+ _flush_table()
518
+
519
+ if stripped.startswith("#### "):
520
+ _flush_para()
521
+ _flush_list()
522
+ out_parts.append(
523
+ f'<h5 style="margin-top:20px;margin-bottom:8px;font-size:16px;">{_format_inline(stripped[5:])}</h5>'
524
+ )
525
+ continue
526
+ if stripped.startswith("### "):
527
+ _flush_para()
528
+ _flush_list()
529
+ out_parts.append(
530
+ f'<h4 style="margin-top:22px;margin-bottom:10px;font-size:18px;">{_format_inline(stripped[4:])}</h4>'
531
+ )
532
+ continue
533
+ if stripped.startswith("## "):
534
+ _flush_para()
535
+ _flush_list()
536
+ out_parts.append(
537
+ f'<h3 style="margin-top:26px;margin-bottom:12px;font-size:20px;color:#0f766e;">{_format_inline(stripped[3:])}</h3>'
538
+ )
539
+ continue
540
+ if stripped.startswith("# "):
541
+ _flush_para()
542
+ _flush_list()
543
+ out_parts.append(
544
+ f'<h2 style="margin-top:30px;margin-bottom:14px;font-size:24px;border-bottom:1px solid #e2e8f0;padding-bottom:6px;">{_format_inline(stripped[2:])}</h2>'
545
+ )
546
+ continue
547
+
548
+ if stripped.startswith("> "):
549
+ _flush_para()
550
+ _flush_list()
551
+ q_txt = _format_inline(stripped[2:])
552
+ out_parts.append(
553
+ f'<blockquote style="border-left:4px solid #0f766e;padding:8px 14px;margin:16px 0;background:#f8fafc;color:#334155;border-radius:0 8px 8px 0;"><p style="margin:0;">{q_txt}</p></blockquote>'
554
+ )
555
+ continue
556
+
557
+ if stripped.startswith(("- ", "* ", "+ ")):
558
+ _flush_para()
559
+ if not in_list:
560
+ out_parts.append('<ul style="padding-left:22px;margin-bottom:16px;">')
561
+ in_list = True
562
+ out_parts.append(f'<li style="margin-bottom:6px;">{_format_inline(stripped[2:])}</li>')
563
+ continue
564
+ else:
565
+ _flush_list()
566
+
567
+ if stripped in ("---", "***", "___"):
568
+ _flush_para()
569
+ out_parts.append('<hr style="border:none;border-top:1px solid #e2e8f0;margin:24px 0;" />')
570
+ continue
571
+
572
+ if stripped.startswith("![") and stripped.endswith(")"):
573
+ _flush_para()
574
+ out_parts.append(_format_inline(stripped))
575
+ continue
576
+
577
+ para_lines.append(stripped)
578
+ _flush_para()
579
+ _flush_list()
580
+ _flush_table()
581
+
582
+ res = "\n".join(out_parts)
583
+ for idx, c_html in enumerate(code_blocks):
584
+ res = res.replace(f"__CODE_BLOCK_{idx}__", c_html)
585
+
586
+ return Markup(res)
587
+
588
+
366
589
  def get_jinja_env() -> SandboxedEnvironment:
367
590
  """Создает безопасное асинхронное окружение Jinja2."""
368
- return SandboxedEnvironment(
591
+ env = SandboxedEnvironment(
369
592
  enable_async=True,
370
593
  autoescape=True,
371
594
  trim_blocks=True,
372
595
  lstrip_blocks=True,
373
596
  )
374
-
597
+ env.filters["markdown"] = render_markdown_filter
598
+ env.filters["md"] = render_markdown_filter
599
+ return env
375
600
 
376
601
  def validate_jinja_template(template_str: str) -> dict[str, Any]:
377
602
  """
@@ -216,7 +216,14 @@ async def handle_bot_http(
216
216
  return True
217
217
 
218
218
  # 2. Проверяем кэш для Site Tree Engine
219
- found, cached = get_cached(path)
219
+ cache_query = {k: v for k, v in query.items() if k not in ("bot", "pf_bot_mode")}
220
+ if cache_query:
221
+ sorted_qs = "&".join(f"{k}={cache_query[k]}" for k in sorted(cache_query))
222
+ cache_key = f"{path}?{sorted_qs}"
223
+ else:
224
+ cache_key = path
225
+
226
+ found, cached = get_cached(cache_key)
220
227
  if found:
221
228
  if cached is None:
222
229
  return False
@@ -235,9 +242,10 @@ async def handle_bot_http(
235
242
  db=db,
236
243
  crud_engine=crud_engine,
237
244
  guest_permissions=guest_permissions,
245
+ query_params=query,
238
246
  )
239
247
  if page_data is not None:
240
- set_cached(path, ("site-tree", page_data))
248
+ set_cached(cache_key, ("site-tree", page_data))
241
249
  host = extract_header(scope, "host")
242
250
  html_content = render_seo_page(
243
251
  page_data, current_path=path, host=host, is_emulation=is_emulation
@@ -249,6 +257,6 @@ async def handle_bot_http(
249
257
  logger.error("[SEO] Ошибка обработки дерева сайта для %s: %s", path, exc)
250
258
 
251
259
  if not had_error:
252
- set_cached(path, None)
260
+ set_cached(cache_key, None)
253
261
 
254
262
  return False
@@ -556,6 +556,7 @@ async def render_static_node(
556
556
  db: Database | None = None,
557
557
  crud_engine: CrudEngine | None = None,
558
558
  guest_permissions: frozenset[str] | None = None,
559
+ query_params: dict[str, str] | None = None,
559
560
  ) -> SeoPageData:
560
561
  """Рендерит статический узел (например `/` или `/about`) со ссылками на дочерние разделы."""
561
562
  raw_title = node.get("meta_title") or node.get("title", "")
@@ -580,7 +581,13 @@ async def render_static_node(
580
581
  breadcrumbs=breadcrumbs,
581
582
  site_url=current_path,
582
583
  site_name=title,
583
- extra={"title": title, "description": description, "current_path": current_path},
584
+ extra={
585
+ "title": title,
586
+ "description": description,
587
+ "current_path": current_path,
588
+ "query": query_params or {},
589
+ "request": {"query": query_params or {}, "path": current_path},
590
+ },
584
591
  )
585
592
  try:
586
593
  body_html = await render_jinja_template(template_str, ctx)
@@ -636,6 +643,7 @@ async def render_collection_node(
636
643
  db: Database,
637
644
  crud_engine: CrudEngine,
638
645
  guest_permissions: frozenset[str] | None = None,
646
+ query_params: dict[str, str] | None = None,
639
647
  ) -> SeoPageData | None:
640
648
  """
641
649
  Рендерит хаб/раздел коллекций (например `/books` или `/catalog/{parent.slug}`).
@@ -652,6 +660,7 @@ async def render_collection_node(
652
660
  db=db,
653
661
  crud_engine=crud_engine,
654
662
  guest_permissions=guest_permissions,
663
+ query_params=query_params,
655
664
  )
656
665
  return None
657
666
 
@@ -767,6 +776,8 @@ async def render_collection_node(
767
776
  "description": resolved_desc,
768
777
  "current_path": current_path,
769
778
  "extracted_params": extracted_params,
779
+ "query": query_params or {},
780
+ "request": {"query": query_params or {}, "path": current_path},
770
781
  },
771
782
  )
772
783
  try:
@@ -857,6 +868,7 @@ async def render_detail_node(
857
868
  db: Database,
858
869
  crud_engine: CrudEngine,
859
870
  guest_permissions: frozenset[str] | None = None,
871
+ query_params: dict[str, str] | None = None,
860
872
  ) -> SeoPageData | None:
861
873
  """
862
874
  Рендерит детальную страницу записи (книга, товар, статья, публикация).
@@ -994,6 +1006,8 @@ async def render_detail_node(
994
1006
  "description": resolved_desc,
995
1007
  "current_path": current_path,
996
1008
  "extracted_params": extracted_params,
1009
+ "query": query_params or {},
1010
+ "request": {"query": query_params or {}, "path": current_path},
997
1011
  },
998
1012
  )
999
1013
  try:
@@ -1029,6 +1043,7 @@ async def match_and_render_site_tree(
1029
1043
  db: Database,
1030
1044
  crud_engine: CrudEngine,
1031
1045
  guest_permissions: frozenset[str] | None = None,
1046
+ query_params: dict[str, str] | None = None,
1032
1047
  ) -> SeoPageData | None:
1033
1048
  """
1034
1049
  Проверяет, соответствует ли запрошенный ботом путь какому-либо узлу дерева сайта,
@@ -1061,6 +1076,7 @@ async def match_and_render_site_tree(
1061
1076
  db=db,
1062
1077
  crud_engine=crud_engine,
1063
1078
  guest_permissions=guest_permissions,
1079
+ query_params=query_params,
1064
1080
  )
1065
1081
  elif node_type == "collection":
1066
1082
  res = await render_collection_node(
@@ -1072,6 +1088,7 @@ async def match_and_render_site_tree(
1072
1088
  db=db,
1073
1089
  crud_engine=crud_engine,
1074
1090
  guest_permissions=guest_permissions,
1091
+ query_params=query_params,
1075
1092
  )
1076
1093
  elif node_type == "detail":
1077
1094
  res = await render_detail_node(
@@ -1083,11 +1100,14 @@ async def match_and_render_site_tree(
1083
1100
  db=db,
1084
1101
  crud_engine=crud_engine,
1085
1102
  guest_permissions=guest_permissions,
1103
+ query_params=query_params,
1086
1104
  )
1087
1105
  if res is not None:
1088
1106
  return res
1089
1107
  except Exception as exc:
1090
1108
  logger.error("[SEO Tree] Ошибка рендеринга узла %s (%s): %s", node.get("title"), pattern, exc)
1109
+ except Exception as exc:
1110
+ logger.error("[SEO Tree] Ошибка рендеринга узла %s (%s): %s", node.get("title"), pattern, exc)
1091
1111
 
1092
1112
  return None
1093
1113
 
File without changes
File without changes
File without changes
File without changes
File without changes