Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Federico Caselli
    @CaselIT
    I replaced grep with rg
    I'm waiting for a git clone in rust :D
    Vytautas Liuolia
    @vytas7
    Installing xh now... But damn does it have many deps... almost npm level
    Andrii Marynets
    @amarynets
    I turned off some middlewares, etc., and now it looks like this locally
    % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 15.2M 100 15.2M 100 233 1089k 16 0:00:14 0:00:14 --:--:-- 3829k
    Vytautas Liuolia
    @vytas7
    Building [=====================> ] 251/279: serde, clap, rustls, serde
    Federico Caselli
    @CaselIT
    strange, don't you get the compiled build on linux?
    Vytautas Liuolia
    @vytas7
    I suppose I could @CaselIT, but I just did cargo install xh
    Federico Caselli
    @CaselIT
    oh well, you are asking for it :)
    sudo apt install xh seems to be a thing
    Vytautas Liuolia
    @vytas7
    Still I'm a bit worried Rust is heading in the same direction as npm
    279 deps just for a command-line HTTP client?
    Well if it were npm, it would have been 3000 deps probably, so not there yet.
    Which app server do you use @amarynets? And how much time is spent to render the response?
    (Heh, xh wasn't much faster than httpie, I guess outputting to a graphical terminal emulator is another bottleneck.)
    Vytautas Liuolia
    @vytas7
    Your last "current" speed is a fair bit higher than average, so I guess like 9-10 seconds were spent in the API itself?
    Tiago Martins Peres
    @tiago-peres

    hi everyone!

    clarification question...

    atm to edit a PostgreSQL field named special_attributes of type jsonb, I'm sending a param like

    domain?special_attributes={
      "id": "1a8b8863-a859-4d68-b63a-c466e554fd13",
      "name": "Ada Lovelace",
      "email": "me@adalovelace.com",
      "bio": "First computer programmer.",
      "age": 206,
      "avatar": "http://en.wikipedia.org/wiki/File:Ada_lovelace.jpg"
    }

    Even though it works and the record is updated, I wouldn't like to be using req.param for this purpose...

    What to use in such case?

    Vytautas Liuolia
    @vytas7

    @tiago-peres it is your API, and you can design it according to your liking, so I wouldn't go as harsh as saying "this is wrong (or right)" :slight_smile:
    But typically in RESTful and REST-like HTTP APIs query parameters are used more for filtering, particularly in conjunction with idempotent, read-only requests such as GET.

    In order to modify a resource, it is more common to provide data in the request body. Assuming you have installed a media handler for the media type in question (JSON is supported out of the box), you can access it using req.get_media() (or just req.media, but beware it performs I/O upon first access).

    Tiago Martins Peres
    @tiago-peres
    thank you. I ended up doing something like
    if req.get_media():
        form = req.get_media()     
        for part in form:
            special_attributes = part.text
    Vytautas Liuolia
    @vytas7
    Hm so are you uploading a multipart form? Also note that req.get_media() might raise in the case there is no payload, or the submitted Content-Type has no matching handler.
    If using a multipart form, you can also attach special_attributes as a JSON part, and use part.get_media().
    Tiago Martins Peres
    @tiago-peres
    using a body form-data in Postman OR data param in Python requests
    Jorge B. | Noob In The Net
    @NoobInTheNet_gitlab

    Hello everyone,

    I am new to Falcon and trying to transition from other frameworks such Flask or DJango.

    I'm working on my first Falcon app after reviewing all of the tutorials and documentation I could find. However, as someone who is used to Flask's more object-oriented programming, I was wondering what would be your recommendations on the best method to create a Falcon async instance-based app, such as the one given in the Uvicorn documentation, rather than a function-based project as shown in the Falcon starting guide with the create_app() function.

    Thank you in advance; best regards.

    Vytautas Liuolia
    @vytas7

    Hi @NoobInTheNet_gitlab!
    The create_app() function in that tutorial is merely a convenience wrapper around an "instance-based" app. In the same tutorial's code for create_app() you'll find the familiar app = falcon.App(), etc.

    If you wish, feel free to subclass falcon.App (or falcon.asgi.App since you mentioned async). I often go that way when developing larger projects myself. Normal Python subclassing patterns apply in that case.

    maxking
    @maxking:matrix.python-gsoc.org
    [m]
    @NoobInTheNet_gitlab: https://gitlab.com/mailman/mailman/-/blob/master/src/mailman/rest/wsgiapp.py#L176 this is how we use it in Mailman.
    We only subclass it to wrap all APIs mutations in a transaction.
    You can do the same with falcon.asgi.App and the docs for the class exist https://falcon.readthedocs.io/en/stable/api/app.html#falcon.asgi.App
    Jorge B. | Noob In The Net
    @NoobInTheNet_gitlab

    Hello @maxking:matrix.python-gsoc.org,

    I highly appreciate your response, I deleted my reply to @vytas7 since I got some ideas to test before requesting for a full example, but I belive your example is more than enough to understand it.

    Thank you both! :)

    Vytautas Liuolia
    @vytas7

    You're welcome @NoobInTheNet_gitlab.

    As you can see, even Mailman's example has a convenience factory function in the form of make_application() just below.

    This is at times handy if your __init__() takes parameters and/or you want to customize the app instance after creation, and you need a factory callable without parameters for your ASGI/WSGI server (but you want to reuse/customize the app differently in other contexts, e.g., the test suite, dev server and what not). Otherwise you can just the class directly.

    aescolastico
    @aescolastico
    has anyone had success with combining a swagger-spec generating library with falcon-autocrud? I realize this may be a very, very niche ask.
    my confusion lies in that these libraries(falcon-apispec, spectree) seem to require that the schema generation components be tied to the resource classes for your various endpoints. but falcon-autocrud, abstracts all that way, by design.
    smitasnaik
    @smitasnaik

    I am using the falcon 3.1.0 framework for microservice development in my product. Also I am creating windows executable using pyinstaller 4.10. I can run microservice using gevent and also create windows executable using pyinstaller. While running the executable it failed to import the falcon submodule but for falcon 2.0 it works. It raises the following error. (accregisterenv) C:\MUM_DEV_TEAM\edcservices\accountregistration-ps\dist>run_accountregistration\run_accountregistration.exe
    Traceback (most recent call last):
    File "run_accountregistration.py", line 9, in <module>
    File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
    File "app.py", line 6, in <module>
    File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
    File "falcon__init__.py", line 32, in <module>
    File "falcon\app.py", line 22, in init falcon.app
    ImportError: cannot import name app_helpers
    [5848] Failed to execute script 'run_accountregistration' due to unhandled exception!

    (accregisterenv) C:\MUM_DEV_TEAM\edcservices\accountregistration-ps\dist>

    Vytautas Liuolia
    @vytas7

    Hi @smitasnaik!
    Unfortunately I have no experience with pyinstaller. @CaselIT have you ever used this one?

    Does Falcon 2.0 work with the same project and the same version of pyinstaller, or did it use to work at some point in the past?

    One thing I can think of is that we have changed the build process to PEP 517, however, we still use setuptools. Maybe that, in combination that we also build binary modules with Cython, confuses pyinstaller somehow? Moreover, we started shipping binary wheels for Windows, maybe something is different there? Re PEP 517, could you try Falcon 3.0 for comparison?

    Do you know more about how pyinstaller works? Is it purely in memory, or does it extract files on disk? If you could get a snapshot of such a directory, maybe we could take a look at what's wrong there.

    Federico Caselli
    @CaselIT

    Unfortunately I have no experience with pyinstaller. @CaselIT have you ever used this one?

    no, never used it, sorry

    smitasnaik
    @smitasnaik
    Falcon 2.0 work with the same project and the same version of pyinstaller. How could I send snapshot to you? I didn't see any attachment option here.
    Federico Caselli
    @CaselIT
    it's probably better to open a github discussion
    also it may be something to ask pyinstaller, since I'm sure they can offer more help. falcon is not doing anything strange here
    just as a test, you could try installing the source distribution, using --no-binary in pip install or downloading the source tar from pypi and installing it
    smitasnaik
    @smitasnaik
    @CaselIT Thank you for your quick response. I will install falcon by downloading source tar from pypi.
    Federico Caselli
    @CaselIT
    let us know if that works, so we may add an entry in the faq regarding pyinstaller
    smitasnaik
    @smitasnaik

    I have tried this command raise following error even if install Microsoft Visual Studio 14.0
    pip install falcon==3.1.0 --no-binary :all:
    C:\Users\admin\AppData\Local\Temp\pip-install-k63iwcod\cython_c9412625356b45e1a7ef2581a8b3f9f7\Cython\Compiler\Scanning.c(11002): warning C4244: '=': conversion from 'Py_ssize_t' to 'long', possible loss of data
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\MUM_DEV_TEAM\INSTALLER\PYTHON_39\PY39ENVS\accregenv\libs /LIBPATH:C:\Users\admin\AppData\Local\Programs\Python\Python39\libs /LIBPATH:C:\Users\admin\AppData\Local\Programs\Python\Python39 /LIBPATH:C:\MUM_DEV_TEAM\INSTALLER\PYTHON_39\PY39ENVS\accregenv\PCbuild\amd64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64 /EXPORT:PyInit_Scanning build\temp.win-amd64-3.9\Release\Users\admin\AppData\Local\Temp\pip-install-k63iwcod\cython_c9412625356b45e1a7ef2581a8b3f9f7\Cython\Compiler\Scanning.obj /OUT:build\lib.win-amd64-3.9\Cython\Compiler\Scanning.cp39-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.9\Release\Users\admin\AppData\Local\Temp\pip-install-k63iwcod\cython_c9412625356b45e1a7ef2581a8b3f9f7\Cython\Compiler\Scanning.cp39-win_amd64.lib
    Scanning.obj : warning LNK4197: export 'PyInit_Scanning' specified multiple times; using first specification
    LINK : fatal error LNK1104: cannot open file 'build\temp.win-amd64-3.9\Release\Users\admin\AppData\Local\Temp\pip-install-k63iwcod\cython_c9412625356b45e1a7ef2581a8b3f9f7\Cython\Compiler\Scanning.cp39-win_amd64.lib'
    error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe' failed with exit code 1104
    [end of output]
    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: legacy-install-failure
    Encountered error while trying to install package.
    cython
    note: This is an issue with the package mentioned above, not pip.
    hint: See above for output from the failure.
    [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error

    × pip subprocess to install build dependencies did not run successfully.
    │ exit code: 1
    ╰─> See above for output.

    note: This error originates from a subprocess, and is likely not a problem with pip

    (accregenv) C:\MUM_DEV_TEAM\edcservices\accountregistration-ps>

    Vytautas Liuolia
    @vytas7

    Hmm, that is strange... @CaselIT since you use Windows could you check this?

    I thought that Cython build errors are non-critical, and we just continue to install from source then (?)

    Aha, this is somewhat on your end too @smitasnaik...
    Encountered error while trying to install package.
    cython
    Why couldn't Cython be installed?

    @smitasnaik What do you get if you attempt to

    pip install cython

    ?

    https://pypi.org/project/Cython/#files ... Aha, Cython doesn't seem to ship binary wheels for Windows at all.
    Vytautas Liuolia
    @vytas7
    @smitasnaik just to confirm that PEP 517 is the problem for you, could you try falcon==3.0.1 with pyinstaller?
    smitasnaik
    @smitasnaik

    Downloaded cython wheel from given link and execute following command
    pip install Cython-0.29.30-py2.py3-none-any.whl --force-reinstall

    Raise same error :
    Scanning.obj : warning LNK4197: export 'PyInit_Scanning' specified multiple times; using first specification
    LINK : fatal error LNK1104: cannot open file 'build\temp.win-amd64-3.9\Release\Users\admin\AppData\Local\Temp\pip-install-0l16xk1k\cython_daa866b856604001b70cf3c676f96c47\Cython\Compiler\Scanning.cp39-win_amd64.lib'
    error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe' failed with exit code 1104
    [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: legacy-install-failure
    
      Encountered error while trying to install package.
      cython
      note: This is an issue with the package mentioned above, not pip.
      hint: See above for output from the failure.
      [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error

    × pip subprocess to install build dependencies did not run successfully.
    │ exit code: 1
    ╰─> See above for output.

    note: This error originates from a subprocess, and is likely not a problem with pip.

    smitasnaik
    @smitasnaik
    @vytas7 I have installed falcon==3.0.1 and create executable but its not import falcon submodule
    Vytautas Liuolia
    @vytas7
    Interesting...

    @smitasnaik So could you try to find the file tree that pyinstaller creates for Falcon, pack it as a Zip file, and upload to a new discussion?

    (IIRC GitHub accepts up to 25 MiB .zip files.)