-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathservices.py
26 lines (22 loc) · 937 Bytes
/
services.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from django_nameko_standalone import DjangoModels
from nameko.events import event_handler
from nameko.rpc import rpc
class NamekoService:
name = "nameko_service"
models = DjangoModels()
@rpc
def search(self, search_text):
from polls.models import Question
question = Question.objects.filter(question_text=search_text).first()
if not question:
return f"Question {search_text} is not found"
else:
return f"Question {question.question_text} is found. Date: {question.pub_date}"
@event_handler('ipms', 'import')
def imps_import(self, search_text):
from polls.models import Question
question = Question.objects.filter(question_text=search_text).first()
if not question:
print(f"Question {search_text} is not found")
else:
print(f"Question {question.question_text} is found. Date: {question.pub_date}")