Please guide.
Creating a new mobile app, not able to signup! Returns some error while tryting to call /web/signup and also while directly calling res.users create as sudo.
Please see the error message
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File
"/odoo/odoo-server/odoo/http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception) File
"/odoo/odoo-server/odoo/http.py", line 316, in _handle_exception raise
exception.with_traceback(None) from
new_causepsycopg2.errors.UndefinedFunction: operator does not exist:
integer = booleanLINE 6: AND (p.company_id=false OR p.company_id ...
Seems this error raised from _get_multi function in ir_property.py
Thanks in advance
I use a custom controller for receiving request from mobile app and tries to call Odoo Core signup (do_signup located in auth_signup/controller/main) function. It reaches up to there and exceution moves to ir_property and returns error as mentioned.
Please see the sample code which try to use
user = {
'name' : user_info['name'],
'phone': user_info['phone'],
'email': 'test#example.com',#user_info['email'] ,
'login': user_info['phone'],
'password': password,
'confirm_password': password,
}
user_info = AuthSignupHome().do_signup(user)
But /web/signup it's a website service type='http'. You need a controller type='json' for call it from your custom mobile app.
I hope this answer can help you.
Related
The first time I touched Telethon, I changed the api_id and api_hash, and then ran the program, but the following error was reported:
Traceback (most recent call last):
File "scraper.py", line 370, in
client.loop.run_until_complete(main())
File "/root/.miniconda3/envs/python38/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "scraper.py", line 41, in main
await init_empty()
File "scraper.py", line 187, in init_empty
async for dialog in client.iter_dialogs():
File "/root/.miniconda3/envs/python38/lib/python3.8/site-packages/telethon/requestiter.py", line 74, in anext
if await self._load_next_chunk():
File "/root/.miniconda3/envs/python38/lib/python3.8/site-packages/telethon/client/dialogs.py", line 53, in _load_next_chunk
r = await self.client(self.request)
File "/root/.miniconda3/envs/python38/lib/python3.8/site-packages/telethon/client/users.py", line 30, in call
return await self._call(self._sender, request, ordered=ordered)
File "/root/.miniconda3/envs/python38/lib/python3.8/site-packages/telethon/client/users.py", line 84, in _call
result = await future
telethon.errors.rpcerrorlist.BotMethodInvalidError: The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot (caused by GetDialogsRequest)
May I ask what modifications I need to make to run this program(https://github.com/edogab33/telegram-groups-crawler)? Do I need a Telegram group file? Can you provide a simple example? Thank you.
I am developing a WSGI application on Windows. I use peewee (which is supposedly unrelated) and:
falcon==2.0.0
waitress==1.4.3
I have the following code in my resources.py:
from models import Board
class BoardResource:
def on_get_collection(self, req, resp):
resp.media = Board.select()
def on_get(self, req, resp):
code = req.get_param('code')
resp.media = Board.get_by_id(code)
I have the following code in my app.py:
import falcon
import models
from resources import BoardResource
def init():
models.init()
api = falcon.API()
api.add_route('/boards', BoardResource, suffix='collection')
api.add_route('/board', BoardResource)
return api
api = init()
I start the app with this command: waitress-serve app:api. When I request /boards from the API, I get this error:
ERROR:waitress:Exception while serving /boards
Traceback (most recent call last):
File "c:\users\pepsiman\.virtualenvs\hsech-api\lib\site-packages\waitress\channel.py", line 349, in service
task.service()
File "c:\users\pepsiman\.virtualenvs\hsech-api\lib\site-packages\waitress\task.py", line 169, in service
self.execute()
File "c:\users\pepsiman\.virtualenvs\hsech-api\lib\site-packages\waitress\task.py", line 439, in execute
app_iter = self.channel.server.application(environ, start_response)
File "c:\users\pepsiman\.virtualenvs\hsech-api\lib\site-packages\falcon\api.py", line 269, in __call__
responder(req, resp, **params)
TypeError: on_get_collection() missing 1 required positional argument: 'resp'
I decided to remove the self argument from the definiton of on_get_collection and the error was gone. I know that self must be there and have no idea why it doesn't work like that. Any ideas how to fix?
I have found the problem myself: when calling api.add_route the responder class must indeed be instantiated, thus the following lines:
api.add_route('/boards', BoardResource, suffix='collection')
api.add_route('/board', BoardResource)
need to be modified like this:
api.add_route('/boards', BoardResource(), suffix='collection')
api.add_route('/board', BoardResource())
Of course it works without removing the self argument from the definitions.
I hope this silly mistake of mine will help someone fix theirs.
I am using the
telepot.Bot(bot_id).sendAudio(chat_id, file_url)
method, is supposed to send the file, but it returns
Traceback (most recent call last):
File "C:\Users\vinu\AppData\Local\Programs\Python\Python37\lib\site-packages\telepot\__init__.py", line 1158, in collector
callback(item)
File "bot.py", line 72, in handle
bot.sendAudio(chat_id, url)
File "C:\Users\vinu\AppData\Local\Programs\Python\Python37\lib\site-packages\telepot\__init__.py", line 556, in sendAudio
return self._api_request_with_file('sendAudio', _rectify(p), 'audio', audio)
File "C:\Users\vinu\AppData\Local\Programs\Python\Python37\lib\site-packages\telepot\__init__.py", line 496, in _api_request_with_file
return self._api_request(method, _rectify(params), **kwargs)
File "C:\Users\vinu\AppData\Local\Programs\Python\Python37\lib\site-packages\telepot\__init__.py", line 491, in _api_request
return api.request((self._token, method, params, files), **kwargs)
File "C:\Users\vinu\AppData\Local\Programs\Python\Python37\lib\site-packages\telepot\api.py", line 155, in request
return _parse(r)
File "C:\Users\vinu\AppData\Local\Programs\Python\Python37\lib\site-packages\telepot\api.py", line 150, in _parse
raise exception.TelegramError(description, error_code, data)
telepot.exception.TelegramError: ('Bad Request: wrong HTTP URL specified', 400, {'ok': False, 'error_code': 400, 'description': 'Bad Request: wrong HTTP URL specified'})
the same happened with sendPhoto, but I used python requests to send photos
response =requests.post('https://api.telegram.org/bot/sendphoto', files=files`)
I either want to know why the sendAudio() and sendPhoto() methods work or the http url to send audio
with telepot bot.SendPhoto and bot.sendVideo and bot.sendAudio work either with files and urls that contains a file.
In your case it seems that you used and url and it was uncorrect, can you share it?
In my experience it can be because the url contains & instead of &
I'm using python-social-auth and when I try to refresh my Google Oauth2 access token I get the following error:
[2017-02-15 14:41:00,089: ERROR/MainProcess] Task tasks.tasks.test_login[169e5810-489d-4134-af8f-db3b80629fd2] raised unexpected: HTTPError(u'400 Client Error: Bad Request for url: https://accounts.google.com/o/oauth2/token',)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
File "/home/paulozullu/dev/workspaces/wopik/wopik/tasks/tasks.py", line 1928, in test_login
social.refresh_token(strategy)
File "/usr/local/lib/python2.7/dist-packages/social/storage/base.py", line 54, in refresh_token
response = backend.refresh_token(token, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/social/backends/oauth.py", line 418, in refresh_token
request = self.request(url, **request_args)
File "/usr/local/lib/python2.7/dist-packages/social/backends/base.py", line 225, in request
response.raise_for_status()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 909, in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 400 Client Error: Bad Request for url: https://accounts.google.com/o/oauth2/token
I use the following code to refresh the access token:
from social.apps.django_app.utils import load_strategy
w_user = WUser.objects.get(auth_user=A('username','xxxx'))
social = UserSocialAuth.objects.get(user_id=w_user.auth_user.id)
strategy = load_strategy()
social.refresh_token(strategy)
Am I doing something wrong?
I had the same problem when calling social.get_access_token(load_strategy()). If you don't want to implement Google sign-in manually, I used this workaround which forces the user to re-authenticate to refresh their tokens.
try:
strategy = load_strategy()
access_token = social.get_access_token(ls)
except HTTPError as e:
return HttpResponseRedirect(reverse('social:begin', kwargs={'backend': "google-oauth2"}))
As yilmazhuseyin pointed above, the issue is related to refresh token not being present. You need to pass access_type='offline' in the parameters in order for Google to return the refresh token. This can be done by adding the following in settings.py for python-social-auth in django:
SOCIAL_AUTH_GOOGLE_OAUTH2_AUTH_EXTRA_ARGUMENTS = {
'access_type': 'offline',
}
More details can be found in Google OAuth 2.0 documentation.
Our application is using pymongo. I'm trying to connect to mongos. The code fails on the following line
pymongo.MongoReplicaSetClient(ec2-aa-bbb-124-22.compute-1.amazonaws.com:27017,
replicaSet=self.class_settings['mongo_rs'])
Exception
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/.../server_tornado.py --config=conf/development.conf --port=9001
Traceback (most recent call last):
File "/Users/..../server_tornado.py", line 319, in
BaseCatalog.db_instance = DBInit(config=settings)
File "/Users/..../lib/sc/singleton.py", line 20, in call
cls._instances[cls] = super(Singleton, cls).call(*args, **kwargs)
File "/Users/..../app/models/db_init.py", line 50, in init
raise Exception("init() => " + str(err))
Exception: init() => No suitable hosts found
Process finished with exit code 1`
Found the solution, if at all anyone faces this issue:
Using MongoClient instead of MongoReplicaClient fixes the issue. This is because Mongos acts like a single instance of mongodb.