django: code changes not getting reflected - python-3.x

I am using Django 2.0.
I wanted to use firebase cloud messaging, so i have installed fcm_django.
I have to replace is_authenticated() with is_authenticated (without the brackets) in the rest_framework.py file.
SO i have edited the file
/home/test/venv_btg/lib/python3.6/site-packages/fcm_django/api/rest_framework.py
Then i save the file.
But when i run the url. It shows the following error in the file rest_framework.py
if user is not None and user.is_authenticated():
but i have changed is_authenticated() to is_aunthenticated
Why django is not reflecting the changes?

Related

How to get a YAML file containing api keys to work in django?

I'm new to django and I am trying to make an API call to ebay when a user clicks a button, using ebay python SDK. There is a YAML file inside my project which contains the api keys. In my app, I have a python file that contains a function that makes the api call. When I run the function that python file separately, it works fine and finds the YAML file no problem. But when I try to run that same function from views.py, it gives me an error that says - config file 'ebay.yaml' not found. Can anyone please help me with this as I have no idea what's wrong... Do I have to do anything special when running the API call through django, besides just having a YAML file in the same direcotry?
Your ebay.yaml file should be in the same directory as manage.py in order to work properly.
Here is an example:
folder/
ebay.yaml
manage.py

GitHub Clone from VSCode eg-02-react-implicit-grant error /src/hoc/aux invalid argument

This question is regarding the repo for react implicit grant for docusign using react.
https://github.com/docusign/eg-02-react-implicit-grant
When I tried to clone the repo using VSCode, I received an error
Git: fatal: cannot create directory at 'src/hoc/Aux': Invalid argument
When I looked into the repo, there is a file under src/hoc/aux/aux.js which has the text below.
const aux = (props) => props.children;
export default aux;
Is the file aux.js necessary? Because I was able to extract the zip files after skipping to extract aux.js.
I just tried to clone the https://github.com/docusign/eg-02-react-implicit-grant repo using the GitHub desktop and did not have any problems.
I suggest that you download the repo using git directly or use the download zip option from the repo's page.
Re: aux.js
TL;DR. -- Yes, I believe the aux.js is needed.
Details: Unfortunately I'm not a React expert. (Even though I wrote this example.)
The /hoc directory is used for React Higher Order Components. In this case, I'm using it for a simple component that checks to see if the user has a valid token. I believe that the js file is needed. But you can find out by not including it as seeing what happens.
Also, note that I wrote this React example almost a year ago. You'll want to update it to current React best practices.
Try renaming the aux folder and aux.js file inside it to any random name do it preferably in vscode it will let you know which name is allowed and which isn't, worked for me.

Google Cloud Natural Language Example

I have followed the getting started page closely.
https://cloud.google.com/natural-language/docs/reference/libraries#client-libraries-install-php
The example code has the following: $projectId = 'YOUR_PROJECT_ID';
I fill in my project id taken from the json file and the Google console--e.g. "$projectID = 'myproject-197218'" and I always get a fatal error with "Permission Denied."
I have set the env variable, run composer to install the library. And, I created the Google json file. I am running the example in PHP code.
I am running the code on my local server (xampp).
I figured out my problem. The Google Cloud json file was stored on my drive d:, so in the env variable I referenced it as 'GOOGLE_APPLICATION_CREDENTIALS= d:\xampp\htdocs\googapi\mproj.json', it did not work; when I moved it to the root of the c: drive and referenced it there (GOOGLE_APPLICATION_CREDENTIALS=c:proj.json), it worked fine.
Are you sure that the ID of your project is that one? I'm working in Google Cloud and I cannot see this project ID in our database, but if I type "my-project-197218" with a "-" between "my" and "project" I am able to find one project. please, to make sure that this is your correct project ID, run this command in your Google Cloud Shell to get the default project ID:
gcloud config list --format 'value(core.project)' 2>/dev/null

Python2 connexion framework - controller in directory structure

I am playing around with using the connexion framework to setup a REST API access for my application.
My application is is built on python2, I installed the connexion framework for python2 and played around with the yaml file via the editor (editor.swagger.io). I downloaded the Python Flask server code, converted it to be compatable with Python2 and tested for a single controller.
When the controller is placed in the same directory as the place where the server is run. Everything was fine - all routes were added and working as expected. I then proceeded to split the controller based on some business logic and wanted a tree structure for each controller.
Something like
myapp/api/magic1/magic1_controller.py
myapp/api/magic2/magic2_controller.py
and so on.
This does not work for python2. It seems to work for python3. Any ideas why?
I get the following error from logs
DEBUG:connexion.api:Security Definitions: {}
DEBUG:connexion.api:Validate Responses: False
DEBUG:connexion.api:Creating API blueprint: /api
DEBUG:connexion.api:Adding swagger.json: /api/swagger.json
DEBUG:connexion.api:Adding swagger-ui: /api/ui/
DEBUG:connexion.api:Adding /api/magic1/{name}...
ERROR:connexion.api:Failed to add operation for GET /api/magic1/{name}
In the yaml config file I add the OperationId as api.magic1.func1() and so on.
Following the information you provided here the operationId should be set to api.magic1.magic1_controller.func1 and not api.magic1.magic1.func1().
You are missing to provide more details about your problem. Code snippets would help to guide you in a more detailed solution.

unable to run views written in python in couchdb futon

i started using couchdb with python-couchdb recently. The problem is when i use futon run my views written in python i get the following error message:
Error: os_process_error
{exit_status,4}
even for the default view it crashes.
def fun(doc):
yield None, doc
i set query_server in local.ini to
[query_server] python=C:\Python27\Lib\site-packages\couchpy-0.2dev-py2.7.egg\couchpy
Exit status 4 for Windows means that CouchDB is unable to open or locate file. I suppose you'd mess up couchpy project with couchpy view server. First one is just (afaik) client library, while second one is a part of another client library that ships with view server.
UPD: For Windows Python view server install with next line according your Python path:
[query_servers]
python=C:\Python27\Scripts\couchpy.exe

Resources