Replies: 11 comments 7 replies
-
You can do this by hooking HTTP POST, https://github.com/thomaxxl/safrs/wiki/HTTP-Methods . Hooking relationship post is a bit more complicated. There are also other ways to achieve what you want, using sqlalchemy triggers for example. |
Beta Was this translation helpful? Give feedback.
-
This is one approach (using flask request and response) can you try it please? |
Beta Was this translation helpful? Give feedback.
-
For the record, @classmethod
def _s_post(cls, *args, **kwargs):
print(kwargs)
result = User(*args, **kwargs)
print(result)
return result I will update the documentation. |
Beta Was this translation helpful? Give feedback.
-
Thanks Thomaxxl/Safrs,
At this point (in your code) the new record already committed in DB? I need
call another function from here which will need this record already in DB.
Thanks!
…On Mon, Oct 3, 2022 at 1:28 PM Thomas Pollet ***@***.***> wrote:
For the record, _s_post is a bit more complicated than described in the
wiki as it's a classmethod.
This should work
<https://gist.github.com/thomaxxl/48fbd9c0401e677a588c8048522310bd>
@classmethod
def _s_post(cls, *args, **kwargs):
print(kwargs)
result = User(*args, **kwargs)
print(result)
return result
I will update the documentation.
—
Reply to this email directly, view it on GitHub
<#126 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANENUR6SY4H52M45UMUJ7ATWBMJTLANCNFSM6AAAAAAQYZ42NA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Records are automatically committed when created in |
Beta Was this translation helpful? Give feedback.
-
Hi Thomaxxl/Safrs,
Thanks. Yes it committed and can be queried, but it throw exception and
exit at end:
Error: 'NoneType' object has no attribute '_s_object_id'
I'm on Python 3.9 and latest safrs
…On Tue, Oct 4, 2022, 7:31 AM Thomas Pollet ***@***.***> wrote:
Records are automatically committed when created in SAFRSBase.__init__,
unless SAFRSBase._s_auto_commit is False (default is True for now but
this might change in future versions).
—
Reply to this email directly, view it on GitHub
<#126 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANENUR6HISQRPYELEOUXC6LWBQIQFANCNFSM6AAAAAAQYZ42NA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks Thomas, it is working now.
Can you please show me an example to display description info for a column?
It seems not works for 2.12.3. the table description works. Thanks a lot
for your help.
…On Tue, Oct 11, 2022, 5:29 AM Thomas Pollet ***@***.***> wrote:
I think you forgot to return the created class ( return result)
see https://gist.github.com/thomaxxl/48fbd9c0401e677a588c8048522310bd
—
Reply to this email directly, view it on GitHub
<#126 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANENUR2JLE5TQUVHYFKEBQLWCUXPPANCNFSM6AAAAAAQYZ42NA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Yes. I mean to customize the default service, such as get or post, to add
description such as "use yyy-mm-dd" as format for field created, like that.
Thanks!
…On Thu, Oct 20, 2022, 1:14 PM Thomas Pollet ***@***.***> wrote:
You want to change the description shown in the swagger?
You can modify the spec by providing the custom_swagger argument to
SAFRSAPI:
https://github.com/thomaxxl/safrs/blob/b411752adb9cc7af2828fa4ccefe89fb6cd469b4/examples/mini_examples/ex12_swagger.py#L53
—
Reply to this email directly, view it on GitHub
<#126 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANENUR7LWUXWOZ27J3AL6R3WEF4ZBANCNFSM6AAAAAAQYZ42NA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks, is it possible to send a example of custom_swagger argument for
service level description?
…On Thu, Oct 20, 2022, 1:42 PM Thomas Pollet ***@***.***> wrote:
The only way to do this is by modifying the swagger manually. You can
import and edit the spec with https://editor.swagger.io/ , then host the
spec and swagger ui elsewhere, or merge using the above custom_swagger
argument.
—
Reply to this email directly, view it on GitHub
<#126 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANENUR66CR7VSV2JANY4URDWEGAAJANCNFSM6AAAAAAQYZ42NA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi Thomas,
On another topic, I see your demo_auth.py, run it, the page does not pop up
to ask userid/pw, how do you suggest to let user type in userid & password
in UI? Thanks a lot.
…On Thu, Oct 20, 2022 at 2:22 PM Jonathan Huang ***@***.***> wrote:
Thanks, is it possible to send a example of custom_swagger argument for
service level description?
On Thu, Oct 20, 2022, 1:42 PM Thomas Pollet ***@***.***>
wrote:
> The only way to do this is by modifying the swagger manually. You can
> import and edit the spec with https://editor.swagger.io/ , then host the
> spec and swagger ui elsewhere, or merge using the above custom_swagger
> argument.
>
> —
> Reply to this email directly, view it on GitHub
> <#126 (reply in thread)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ANENUR66CR7VSV2JANY4URDWEGAAJANCNFSM6AAAAAAQYZ42NA>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
-
OK, I will.
Yes I know to add an item into custom_swagger dict, but I don't know the
naming pattern for a service endpoint, is it classname_fieldname? any doc
link on this? Thanks.
…On Sat, Oct 22, 2022 at 8:04 AM Thomas Pollet ***@***.***> wrote:
Hi,
Can you next time open a new discussion thread for new questions please?
API authentication is usually implemented using a token passed in the HTTP
Authorization header
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization>.
You should add this header when you execute HTTP requests in the frontend,
so this depends a bit on which frontend you use.
Regarding the swagger, this will require some work if you want to
customize it. The custom_swagger argument will merge the given items with
the existing swagger. So, you'll have to find out which items you want to
modify, then pass this as a dictionary to custom_swagger.
—
Reply to this email directly, view it on GitHub
<#126 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANENURZYTZFIGER4U7KI2C3WEPJ5RANCNFSM6AAAAAAQYZ42NA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Can anyone please tell me how do I add actions into the generated POST action? Post will create a record into class object table, but I need do more after that. Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions