Entry Points
Main
Main export entry points and RDMO provider classes for MaRDMO.
Provides:
- :class:
BaseMaRDMOExportProvider— abstract base carrying the MaRDI Portal OAuth2 credentials and callback wiring shared by all providers that need to post to the portal. - :class:
MaRDMOExportProvider— "Export to MaRDI Portal" button; handles preview and authenticated upload for the model, algorithm, and workflow documentation catalogs. - :class:
MaRDMOQueryProvider— "Query MaRDI Portal" button; handles the search-catalog preview and result rendering without requiring OAuth2.
BaseMaRDMOExportProvider
Bases: OauthProviderMixin, Export, ABC
Base export provider wiring MaRDMO to the MaRDI Portal OAuth2 flow.
Provides the concrete MaRDI Portal URLs and credentials needed by
:class:~MaRDMO.oauth2.OauthProviderMixin. Subclasses implement
the catalog-specific :meth:render and :meth:submit_* methods.
Source code in MaRDMO/main.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
authorize_url
property
MaRDI Portal OAuth2 authorization endpoint URL.
oauth2_client_id
property
OAuth2 client ID read from settings.MARDMO_PROVIDER["mardi"].
oauth2_client_secret
property
OAuth2 client secret read from settings.MARDMO_PROVIDER["mardi"].
redirect_path
property
Callback path registered with the MaRDI Portal OAuth2 application.
token_url
property
MaRDI Portal OAuth2 token exchange endpoint URL.
get_authorize_params(request, state)
Return OAuth2 authorization query parameters for the MaRDI Portal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request (unused — client ID is from settings). |
required | |
state
|
CSRF state token generated by the OAuth2 flow. |
required |
Returns:
| Type | Description |
|---|---|
|
Dict with |
Source code in MaRDMO/main.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
get_callback_data(request)
Return POST body fields for the MaRDI Portal token exchange request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request supplying the |
required |
Returns:
| Type | Description |
|---|---|
|
Dict with |
|
|
|
Source code in MaRDMO/main.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
MaRDMOExportProvider
Bases: BaseMaRDMOExportProvider
Export provider for the "Export to MaRDI Portal" button.
Handles preview and authenticated Wikibase upload for the model, algorithm,
and workflow documentation catalogs. Search is handled separately by
:class:MaRDMOQueryProvider.
Attributes:
| Name | Type | Description |
|---|---|---|
request |
HttpRequest
|
The Django HttpRequest associated with the provider. |
Source code in MaRDMO/main.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
ExportForm
Bases: Form
Empty form class required by the RDMO Export provider interface.
Source code in MaRDMO/main.py
134 135 | |
get_post_data(mode='submit')
Collect and pre-process user answers for the documentation catalogs.
Reads all RDMO project values, applies catalog-specific processing (relation resolution, publication retrieval, etc.), and returns the structured answers dict alongside the global options dict.
Supports the model, algorithm, and workflow documentation catalogs.
The search catalog is handled by :class:MaRDMOQueryProvider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
|
'submit'
|
Returns:
| Type | Description |
|---|---|
|
Tuple |
|
|
organised by entity type (e.g. |
|
|
and options maps RDMO option URIs to their string values. |
Source code in MaRDMO/main.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
render()
Render the catalog-appropriate documentation preview page.
Dispatches to the correct template based on the active catalog (model, algorithm, or workflow).
Returns:
| Type | Description |
|---|---|
|
HTTP response rendering the preview page, or an error page for |
|
|
unsupported catalogs. |
Source code in MaRDMO/main.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
submit()
Dispatch the form submission to the catalog-appropriate export handler.
Handles the cancel action, checks OAuth2 credentials, then routes to
:meth:_submit_catalog based on the active project catalog.
Returns:
| Type | Description |
|---|---|
|
HTTP redirect or rendered response from the selected submit method. |
Source code in MaRDMO/main.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
MaRDMOQueryProvider
Bases: Export
Export provider for the "Query MaRDI Portal" button.
Handles the search-catalog preview (showing a form to configure the query) and the submit action (executing the search and rendering matching results). Does not require OAuth2 — no portal writes are performed.
Attributes:
| Name | Type | Description |
|---|---|---|
request |
HttpRequest
|
The Django HttpRequest associated with the provider. |
Source code in MaRDMO/main.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
ExportForm
Bases: Form
Empty form class required by the RDMO Export provider interface.
Source code in MaRDMO/main.py
344 345 | |
get_post_data()
Load and execute the search query for the search catalog.
Reads the search configuration from RDMO project values and dispatches
to the :func:~MaRDMO.search.worker.search function to retrieve
matching items from the MaRDI Portal, MathModDB KG, or MathAlgoDB KG.
Returns:
| Type | Description |
|---|---|
|
Tuple |
|
|
results and options maps RDMO option URIs to their string values. |
Source code in MaRDMO/main.py
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
render()
Render the search configuration preview page.
Returns:
| Type | Description |
|---|---|
|
HTTP response rendering |
|
|
page if the active catalog is not the search catalog. |
Source code in MaRDMO/main.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
submit()
Execute the MaRDI Portal query and render the results page.
Handles the cancel action (redirects to the project page), then calls
:meth:submit_mardmo_search for the search catalog.
Returns:
| Type | Description |
|---|---|
|
HTTP redirect or rendered results response. |
Source code in MaRDMO/main.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
submit_mardmo_search()
Execute a MaRDI Portal search and render the matching results.
Reads the search type from the answers dict to set the result datatype label.
Returns:
| Type | Description |
|---|---|
|
Rendered |
|
|
matching portal items. |
Source code in MaRDMO/main.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
OAuth2
OAuth2-based export provider with live progress tracking for MaRDMO.
Provides :class:OauthProviderMixin, the abstract base class that handles:
- OAuth2 authorisation flow against the MaRDI Portal (
/authorize→/callback→ token exchange). - Background export job execution with progress reported via
:mod:
~MaRDMO.storeand streamed to the browser. - Wikibase REST API posting: :meth:
~OauthProviderMixin._post_dataretries failed requests, handles duplicate-item policy violations, and substitutes temporaryItem<n>placeholders with the real Wikibase QIDs.
Subclasses must implement :meth:~OauthProviderMixin.get_authorize_params
and :meth:~OauthProviderMixin.post_success to supply catalog-specific
export logic.
OauthProviderMixin
Mixin providing a full OAuth2 authorization-code flow with async Wikibase posting.
Subclasses must implement :meth:get_authorize_params, :meth:get_callback_auth,
:meth:get_callback_headers, :meth:get_callback_params,
:meth:get_callback_data, and :meth:post_success. The mixin handles
state validation, token exchange, background upload, and progress tracking.
Source code in MaRDMO/oauth2.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | |
authorize(request)
Redirect the user to the OAuth authorization endpoint.
Generates a random CSRF state token, stores it in the session, and
builds the redirect URL from :meth:get_authorize_params.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required |
Returns:
| Type | Description |
|---|---|
|
class: |
Source code in MaRDMO/oauth2.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
callback(request)
Handle the OAuth callback, exchange the code for a token, and start posting.
Validates the state parameter, exchanges the authorization code for an
access token, then launches :meth:_background_post in a daemon thread
and redirects to the live-progress page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request (must contain |
required |
Returns:
| Type | Description |
|---|---|
|
Redirect to the progress page on success, or an error page on |
|
|
state-mismatch or token-exchange failure. |
Source code in MaRDMO/oauth2.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
get_authorization_headers(access_token)
Build the Authorization: Bearer … header dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token
|
OAuth2 access token string. |
required |
Returns:
| Type | Description |
|---|---|
|
Dict |
Source code in MaRDMO/oauth2.py
556 557 558 559 560 561 562 563 564 565 | |
get_authorize_params(request, state)
Return query parameters for the OAuth authorization redirect URL.
Must be overridden by subclasses to supply provider-specific parameters
such as client_id, redirect_uri, response_type, and scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required | |
state
|
CSRF state token generated by :meth: |
required |
Returns:
| Type | Description |
|---|---|
|
Dict of query-string parameters. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always — subclasses must implement this method. |
Source code in MaRDMO/oauth2.py
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
get_callback_auth(request)
Return the HTTP Basic-Auth credentials for the token-exchange request.
Default implementation returns None (no Basic-Auth). Subclasses
may override to supply (client_id, client_secret).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required |
Returns:
| Type | Description |
|---|---|
|
|
Source code in MaRDMO/oauth2.py
585 586 587 588 589 590 591 592 593 594 595 596 597 | |
get_callback_data(request)
Return the POST body data for the token-exchange request.
Default implementation returns an empty dict. Subclasses may override
to supply code, redirect_uri, or other required fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required |
Returns:
| Type | Description |
|---|---|
|
Dict of form-body fields. |
Source code in MaRDMO/oauth2.py
628 629 630 631 632 633 634 635 636 637 638 639 640 | |
get_callback_headers(request)
Return HTTP headers for the token-exchange POST request.
Default implementation returns Accept: application/json and a
User-Agent identifying the MaRDMO plugin. Subclasses may override.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required |
Returns:
| Type | Description |
|---|---|
|
Dict of HTTP header name → value pairs. |
Source code in MaRDMO/oauth2.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |
get_callback_params(request)
Return URL query parameters appended to the token-exchange endpoint.
Default implementation returns an empty dict. Subclasses may override
to pass provider-specific parameters (e.g. grant_type).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required |
Returns:
| Type | Description |
|---|---|
|
Dict of query-string parameters. |
Source code in MaRDMO/oauth2.py
614 615 616 617 618 619 620 621 622 623 624 625 626 | |
get_from_session(request, key)
Read (without removing) a value from the Django session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required | |
key
|
Logical key name passed through :meth: |
required |
Returns:
| Type | Description |
|---|---|
|
The stored value, or |
Source code in MaRDMO/oauth2.py
543 544 545 546 547 548 549 550 551 552 553 554 | |
get_session_key(key)
Return the namespaced session key "<class_name>.<key>".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Logical key name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
|
String combining :attr: |
Source code in MaRDMO/oauth2.py
510 511 512 513 514 515 516 517 518 519 | |
pop_from_session(request, key)
Remove and return a value from the Django session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required | |
key
|
Logical key name passed through :meth: |
required |
Returns:
| Type | Description |
|---|---|
|
The stored value, or |
Source code in MaRDMO/oauth2.py
531 532 533 534 535 536 537 538 539 540 541 | |
post(request, jsons=None, dependency=None)
Persist posting arguments in the session and start the OAuth flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required | |
jsons
|
Payload dict to upload (serialisable). |
None
|
|
dependency
|
Ordered iterable of item keys to post before relations. |
None
|
Returns:
| Type | Description |
|---|---|
|
Redirect to the OAuth authorization endpoint. |
Source code in MaRDMO/oauth2.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
post_success(request, init, final)
Handle a completed upload and render the success page.
Called after all items and relations have been posted. Must be overridden by subclasses to display provider-specific results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required | |
init
|
Deep copy of the original payload dict (before posting). |
required | |
final
|
Updated payload dict containing assigned Wikibase IDs. |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always — subclasses must implement this method. |
Source code in MaRDMO/oauth2.py
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | |
render_error(request, title, message)
Render the core/error.html template with title and message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request. |
required | |
title
|
Short error heading (translated string). |
required | |
message
|
Detailed error description (translated string or exception). |
required |
Returns:
| Type | Description |
|---|---|
|
class: |
Source code in MaRDMO/oauth2.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | |
store_in_session(request, key, data)
Write data under the namespaced key into the Django session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request whose session is updated. |
required | |
key
|
Logical key name passed through :meth: |
required | |
data
|
Serialisable value to store. |
required |
Source code in MaRDMO/oauth2.py
521 522 523 524 525 526 527 528 529 | |
Providers
General RDMO optionset providers shared across all MaRDMO catalogs.
Provides:
- :class:
Software— searches MaRDI Portal and Wikidata for software items; refreshes questionnaire fields upon selection. - :class:
RelatedSoftwareWithCreation— like :class:Softwarebut also surfaces user-created software entries from the current project and offers a "create new" option when the search term is not found.
These providers are catalog-agnostic and are referenced from the model, algorithm, or workflow catalog configurations.
RelatedSoftwareWithCreation
Bases: Provider
Software Provider (MaRDI Portal / Wikidata / MathAlgoDB), User Creation, No Refresh Upon Selection
Source code in MaRDMO/providers.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/providers.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
Software
Bases: Provider
Software Provider (MaRDI Portal / Wikidata), No User Creation, Refresh Upon Selection
Source code in MaRDMO/providers.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
get_options(project, search=None, user=None, site=None)
Query external knowledge-graph source(s) and return matching options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance (used for user-entry lookups when applicable). |
required | |
search
|
Search string entered by the user; returns empty list when fewer than 3 characters. |
None
|
|
user
|
Requesting user (unused). |
None
|
|
site
|
Current site (unused). |
None
|
Returns:
| Type | Description |
|---|---|
|
List of |
Source code in MaRDMO/providers.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
Handlers
General cross-catalog relation handler for MaRDMO.
Provides :class:Information, whose :meth:~Information.relation method is
called whenever a relation value is saved to any MaRDMO questionnaire. It
dispatches to the appropriate sub-handler (:mod:~MaRDMO.model.handlers,
:mod:~MaRDMO.algorithm.handlers, or :mod:~MaRDMO.workflow.handlers)
based on the active project catalog, then registers and hydrates the related
entity in the questionnaire section.
Information
Class containing functions, querying external sources for specific entities and integrating the related metadata into the questionnaire.
Source code in MaRDMO/handlers.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
relation(instance)
Handle a saved relation value by registering and hydrating the entity.
Dispatches on the project's catalog to the appropriate sub-handler, then:
- Adds the related entity to the correct questionnaire section.
- Hydrates the entity via
fill_entityon the appropriate :class:~MaRDMO.handler_base.BaseInformationsubclass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
RDMO Value instance carrying |
required |
Source code in MaRDMO/handlers.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
Handler Base
Shared base class for MaRDMO entity handlers.
Provides the four methods that are identical between the Model and Algorithm Information classes: - _entry - _collect_existing_ids - _hydrate_relatants - _fill
Both handlers pass catalog through every call. The algorithm handler simply uses the default catalog='' everywhere.
BaseInformation
Shared infrastructure for Model and Algorithm handlers.
Subclasses must set self.questions and self.base in init, and declare _ENTITY_KEYS as a tuple of question-group keys whose ID URIs are collected by _collect_existing_ids.
Source code in MaRDMO/handler_base.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | |
fill_entity(project, text, external_id, question_id, item_type, batch_fill_method, catalog)
Look up the set_index for external_id and hydrate the entity via :meth:_fill.
Called from the top-level handlers dispatcher when a relation value is saved to the questionnaire.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
RDMO project instance. |
required | |
text
|
Display text for the entity (label + description + source). |
required | |
external_id
|
External ID string (e.g. |
required | |
question_id
|
Full RDMO attribute URI used to locate the entity's set_index in the questionnaire. |
required | |
item_type
|
Questionnaire item type string (e.g. |
required | |
batch_fill_method
|
Bound |
required | |
catalog
|
Current project catalog string. |
required |
Source code in MaRDMO/handler_base.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | |
Router
Django signal router that dispatches RDMO value saves and deletes to MaRDMO handlers.
On every value_created or value_updated signal the post-save router checks
whether the project's catalog is a MaRDMO catalog and, if so, looks up the
saved attribute URI in HANDLER_MAP to call the matching handler method.
On every Django post_delete signal on Value the post-delete router does the
same lookup in DELETE_HANDLER_MAP. Using post_delete (rather than RDMO's
custom value_deleted) ensures the handler fires for both individual REST
deletions and set deletions via RDMO's delete_set, which calls
value.delete() directly.
Both maps are assembled once at startup via :func:~MaRDMO.builders.build_handler_map
and :func:~MaRDMO.builders.build_delete_handler_map.
Provides:
HANDLER_MAP—{catalog: {uri: handler}}dispatch dict for savesDELETE_HANDLER_MAP—{catalog: {uri: handler}}dispatch dict for deletesmardmo_router_post_save— receiver wired tovalue_createdandvalue_updatedmardmo_router_post_delete— receiver wired to Django'spost_deleteonValue
mardmo_router_post_delete(sender, instance, **kwargs)
Post-delete router: dispatch Value deletions to the correct MaRDMO handler.
Connected to Django's post_delete signal on Value. This covers both
individual REST deletions (via perform_destroy) and set deletions (via
RDMO's delete_set, which calls value.delete() directly without sending
value_deleted).
Looks up the project catalog and attribute URI in DELETE_HANDLER_MAP and
calls the matching handler, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
Signal sender class ( |
required | |
instance
|
The deleted :class: |
required | |
**kwargs
|
Additional signal keyword arguments (unused). |
{}
|
Source code in MaRDMO/router.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
mardmo_router_post_save(sender, instance, update_fields=None, **kwargs)
Post-save router: dispatch Value saves to the correct MaRDMO handler.
Connected to both value_created and value_updated signals.
Looks up the project catalog and attribute URI in HANDLER_MAP and
calls the matching handler, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
Signal sender class ( |
required | |
instance
|
The saved :class: |
required | |
update_fields
|
Fields that were updated (unused; present for signal compatibility). |
None
|
|
**kwargs
|
Additional signal keyword arguments (unused). |
{}
|
Source code in MaRDMO/router.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
Views
Django views for the MaRDMO plugin.
Provides the three AJAX endpoints used by the questionnaire frontend to
communicate with background workers, plus the render_preview helper
used by export providers to build HTML previews.
Provides:
get_progress— JSON endpoint that returns current task progress for pollingshow_progress— HTML view that renders a live progress page for a running taskshow_success— HTML view that renders the completed-task result pagerender_preview— helper that renders a Jinja2 template with questionnaire answers
Success page (show_success)
After a successful portal export the success page presents two views of the exported data, switchable via tab buttons:
List view — every newly created MaRDI Portal item, grouped by class, with
all its statements shown as property → value lines. Values that are
external identifiers (DOI, ORCID, swMath ID, …) or URLs are rendered as
clickable links. Qualifier statements are shown indented beneath their parent.
Mathematical expressions (math datatype) are typeset via
MathJax <https://www.mathjax.org/>_ (Apache 2.0).
Graph view — an interactive network graph built with
Cytoscape.js <https://js.cytoscape.org/>_ (MIT) showing items as labelled
circles and literal values as rectangles, connected by directed, labelled
edges. Features include zoom/pan controls, click-to-open portal links on
nodes, a qualifier tooltip on edge click, and a filter panel that lets the user
toggle individual node classes, literal/existing-item layers, and individual
edge properties.
get_progress(request, job_id)
Return the current progress data for job_id as a JSON response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request; the user must own the job (checked via
the session). Raises :exc: |
required | |
job_id
|
Unique job identifier string. |
required |
Returns:
| Type | Description |
|---|---|
|
class: |
|
|
and |
|
|
when no data is found. |
Source code in MaRDMO/views.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
render_preview(self, template, answers, option, submit_label)
Render the documentation preview page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
self
|
Export provider instance with |
required | |
template
|
Template name (relative path) to include in the preview. |
required | |
answers
|
Prepared answers dict passed to the template context. |
required | |
option
|
Option string controlling template behaviour (passed to context). |
required |
Returns:
| Type | Description |
|---|---|
|
HTTP 200 response rendering |
Source code in MaRDMO/views.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
show_progress(request, job_id)
Render the progress-bar page for the given job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request; the user must own the job (checked via
the session). Raises :exc: |
required | |
job_id
|
Unique job identifier string passed to the template. |
required |
Returns:
| Type | Description |
|---|---|
|
Rendered |
Source code in MaRDMO/views.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
show_success(request, job_id)
Render the export-success page and clean up the job's progress entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Django HTTP request; the user must own the job (checked via
the session). Raises :exc: |
required | |
job_id
|
Unique job identifier string; the associated progress data is cleared from the cache after being read. |
required |
Returns:
| Type | Description |
|---|---|
|
Rendered |
|
|
or an error page if the job data is missing. |
Source code in MaRDMO/views.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |