Skip to content

Commit

Permalink
Providing a minor change to where the from_http and to_binary methods…
Browse files Browse the repository at this point in the history
…/functions come from. (#28)

fix: use CloudEvent appropriately 

Without this you will see messages like the following:

```
deprecation.DeprecatedWarning: to_binary is deprecated as of 1.6.0. Use cloudevents.conversion.to_binary function instead
caught to_binary is deprecated as of 1.6.0. Use cloudevents.conversion.to_binary function instead
Function raised to_binary is deprecated as of 1.6.0. Use cloudevents.conversion.to_binary function instead
```
  • Loading branch information
sferich888 authored Feb 21, 2024
1 parent 86b84d8 commit 24a2d9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions parliament/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import logging

from flask import Flask, request
from cloudevents.http import CloudEvent, from_http, to_binary
from cloudevents.http import CloudEvent
from cloudevents.conversion import from_http, to_binary
from .invocation import Context


Expand All @@ -29,10 +30,11 @@ def create(func):
def handle_post():
context = Context(request)
try:
context.cloud_event = from_http(request.headers,
context.cloud_event = from_http(CloudEvent, request.headers,
request.get_data())
except Exception:
except Exception as e:
app.logger.warning('No CloudEvent available')
app.logger.exception(e)
app.logger.exception(traceback.print_exc())
return invoke(func, context)

Expand Down
3 changes: 2 additions & 1 deletion tests/event/event_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from cloudevents.http import CloudEvent, to_binary
from cloudevents.http import CloudEvent
from cloudevents.conversion import to_binary


def test_post_cloud_event(client):
Expand Down

0 comments on commit 24a2d9c

Please sign in to comment.