Title
stringlengths
11
150
A_Id
int64
518
72.5M
Users Score
int64
-42
283
Q_Score
int64
0
1.39k
ViewCount
int64
17
1.71M
Database and SQL
int64
0
1
Tags
stringlengths
6
105
Answer
stringlengths
14
4.78k
GUI and Desktop Applications
int64
0
1
System Administration and DevOps
int64
0
1
Networking and APIs
int64
0
1
Other
int64
0
1
CreationDate
stringlengths
23
23
AnswerCount
int64
1
55
Score
float64
-1
1.2
is_accepted
bool
2 classes
Q_Id
int64
469
42.4M
Python Basics and Environment
int64
0
1
Data Science and Machine Learning
int64
0
1
Web Development
int64
1
1
Available Count
int64
1
15
Question
stringlengths
17
21k
How does Flask know to load the views.py in the Visual Studio default Flask Solution?
29,791,283
1
0
251
0
python,visual-studio,flask
In Flask it is usually enough to import the files the routed functions are defined in. You can add your API methods in an other file and import it. Make sure you don't have any circular imports, they are a source of problem in Flask quite often. If things are getting more complex, it's best to use Blueprints to bundle routes together.
0
0
0
0
2015-04-22T07:56:00.000
1
1.2
true
29,791,175
0
0
1
1
I'm using the Python Tools for Visual Studio (PTVS 2.2 Beta) and creating a new Flask Web Project with Visual Studio 2013. (btw I'm new to both Flask and Python...) The views.py contains my routes. How does VS know to load this file? I don't see it in any properties or other files. Is it a default to always have the routes in views.py? My goal is to use Flask to build a RESTful API and I'm tempted to just replace everything in the views.py with my API routes. Or, can I add another .py file for the API routes?
why would a django test fail only when the full test suite is run?
47,938,881
1
31
8,341
0
python,django,unit-testing
Another possibility is that you've disconnected signals in the setUp of a test class and did not re-connect in the tearDown. This explained my issue.
0
0
0
0
2015-04-22T08:56:00.000
6
0.033321
false
29,792,439
0
0
1
1
I have a test in Django 1.5 that passes in these conditions: when run by itself in isolation when the full TestCase is run when all of my app's tests are run But it fails when the full test suite is run with python manage.py test. Why might this be happening? The aberrant test uses django.test.Client to POST some data to an endpoint, and then the test checks that an object was successfully updated. Could some other app be modifying the test client or the data itself? I have tried some print debugging and I see all of the data being sent and received as expected. The specific failure is a does-not-exist exception that is raised when I try to fetch the to-be-updated object from the db. Strangely, in the exception handler itself, I can query for all objects of that type and see that the target object does in fact exist. Edit: My issue was resolved when I found that I was querying for the target object by id and User and not id and UserProfile, but it's still confusing to me that this would work in some cases but fail in others. I also found that the test would fail with python manage.py test auth <myapp>
Is there a service that can use google api to monitor changes in google spreadsheet?
29,799,548
1
0
736
0
javascript,google-apps-script,google-api,google-api-python-client
Here is a way to do it without triggers/onEdit and without polling the spreadsheet api. Beware this is hacky but it has the advantage of not using apps script quotas or spreadsheet api quotas to detect changes1) in the spreadsheet enable email notifications whenever the spreadsheet changes.2) using gmail filters send those notification emails to a label.3) using the gmail api (has larger quotas) look for that email by finding emails with That label.note that this does avoid quota issues with spreadsheets but i really think its much better to just use the regular triggers/onEdit/onChange and just live with the 1minute delay. Quotas will not be exhausted if you simply detect change and call urlfetch.
0
0
0
0
2015-04-22T11:43:00.000
1
0.197375
false
29,796,483
0
0
1
1
I am very new to JavaScript and Google app script. I want to monitor changes in a sheet. And if there is an edit, I want a script function to run. Triggers are not an option here to use because they have small quota limit. So I can not use onEdit or time driven triggers to call my function. I need some service to use Google API to monitor changes in google sheet and then trigger the function. Is it possible? Can someone please help me with this? Thank You :)
Django 1.7 - allow null and blank in the database, but do not allow null or blank in admin form
29,798,581
0
0
41
0
django,python-3.x
We did this just by change the Model field to not allow null/blank and add default value, and also write a script to add default value to the already existed data whose field is null/blank.
0
0
0
0
2015-04-22T13:03:00.000
2
0
false
29,798,471
0
0
1
2
I have a database where I have older entries which contain null/blank values for a specific field. However, from now on, I would like to not allow null/blank values to be added to the database. Is there a way to do this in Django 1.7, python 3.4.
Django 1.7 - allow null and blank in the database, but do not allow null or blank in admin form
29,798,580
1
0
41
0
django,python-3.x
There's really no such thing as blank in the database, or null in the admin. null controls whether the database can contain NULL values (not even empty values, just NULL). blank controls whether the admin and modelforms accept empty values. It seems to me that what you want is simply null=True, blank=False.
0
0
0
0
2015-04-22T13:03:00.000
2
1.2
true
29,798,471
0
0
1
2
I have a database where I have older entries which contain null/blank values for a specific field. However, from now on, I would like to not allow null/blank values to be added to the database. Is there a way to do this in Django 1.7, python 3.4.
Change the order in which Django migrate app during testing
29,814,121
1
7
2,278
0
python,django,testing,migration
Put your your apps before Django apps in INSTALLED_APP in settings.py file
0
0
0
0
2015-04-22T13:18:00.000
2
0.099668
false
29,798,841
0
0
1
1
I am using the custom user model which inherits from the AbstractBaseUser class. When I try to migrate after makemigrations command django.db.utils.ProgrammingError: relation "custom_user_users" does not exist This is happening since Django is trying to migrate other apps first which depends upon the custom user model. Even I tried to changing the order of the app which contains the custom user model in INSTALLED_APP but no luck. I know I can force fully migrate custom_user model first then let Django migrate all other models. This solves the problem but during running test it runs the migration in order which Django decides. How can I alter the order in which apps are migrated during test ? Any other way to solve this dependency problem ? I am using Django 1.8
django filer no module named fields.image error
29,804,634
2
0
809
0
python,django
You most likely have a Python file called filer.py or a Python module (folder containing a __init__.py file) called filer in your current directory (or somewhere in your PYTHON_PATH) which shadows the filer package you installed. You need to remove or rename that file/module in order to be able to use the filer package.
0
0
0
0
2015-04-22T15:42:00.000
1
1.2
true
29,802,546
0
0
1
1
I have this problem. I have installed filer and when I import only filer its fine import filer It is importing but when I do from filer.fields.image import FilerImageField It is not importing and gives error no module named fields.image What is the problem? I have gone through the documentation and it gives the same way of importing.
Will using memcache reduce my instance memory?
29,806,800
3
0
130
1
python-2.7,google-app-engine,memcached
Moving objects to and from Memcache will have no impact on your memory unless you destroy these objects in your Java code or empty collections. A bigger problem is that memcache entities are limited to 1MB, and memcache is not guaranteed. The first of these limitations means that you cannot push very large objects into Memcache. The second limitations means that you cannot easily replace, for example, a HashMap with memcache - it's impossible to tell if getValue() returns null because an object is not present or because it was bumped out of memcache. So you will have to make an extra call each time to a datastore to see if an object is really not present.
0
1
0
0
2015-04-22T18:48:00.000
1
1.2
true
29,806,384
0
0
1
1
I'm currently running into soft memory errors on my Google App Engine app because of high memory usage. A number of large objects are driving memory usage sky high. I thought perhaps if I set and recalled them from memcache maybe that might reduce overall memory usage. Reading through the docs this doesn't seem to be the case, and that the benefit of memcache is to reduce HRD queries. Does memcache impact overall memory positively or negatively? Edit: I know I can upgrade the instance class to F2 but I'm trying to see if I can remain on the least expensive while reducing memory.
Djangos TEMPLATE_DIRS not found
29,813,856
0
4
717
0
python,django,templates
Well it is not a good solution, but try hardcoding the full path.
0
0
0
0
2015-04-23T00:13:00.000
2
0
false
29,811,281
0
0
1
1
I am trying to create a login page in my django application. I created a "templates" folder on the root directory of my application. Then on my settings.py I wrote this code. TEMPLATE_DIRS = (os.path.join(BASE_DIR,'templates'),) And it is giving this feedback: TemplateDoesNotExist at /login/ Template-loader postmortem Django tried loading these templates, in this order: Using loader django.template.loaders.filesystem.Loader: Using loader django.template.loaders.app_directories.Loader: /Users/julianasakae/Desktop/DjangoProject/demo/lib/python3.4/site-packages/django/contrib/admin/templates/login.html (File does not exist) /Users/julianasakae/Desktop/DjangoProject/demo/lib/python3.4/site-packages/django/contrib/auth/templates/login.html (File does not exist) /Users/julianasakae/Desktop/DjangoProject/boardgames/main/templates/login.html (File does not exist) I tryed everything, it does not seems to work. Any suggestions?
Django: thin model to consume XML API?
29,970,413
0
0
65
0
python,xml,django,django-models
Judging by the deafening silence, I gather the answer is: do it differently. We're rebuilding the project to consume a JSON ReSTful interface instead.
0
0
0
0
2015-04-23T03:13:00.000
1
1.2
true
29,812,987
0
0
1
1
A software architecture question: I have the top two/thirds of a Django app: the view and template layers. I'd like to use an external resource for the model. How? I'd like to use as much of the Django model layer as possible, for the ORM. The external resource is a specialized Java package, providing content via a flexible backend XML API. My current strategy is a sort of thin model shim API: Django models without fields, instead a series of @propertys, each a function pulling data from the external resource, as needed. Is this a good idea? How else would you solve this problem?
Recommended way to build cross platform desktop application using linux development machine
29,815,298
1
2
1,133
0
python,linux,windows
What you are looking for is a GUI tool-kit with bindings to python. Tkinter is the de facto standard for python GUI and is cross platform. Qt is also a popular choice but the license is more restrictive then Tkinter but will allow you to transition into C++ programming with Qt easier if that is something you may want to do down the road. The choice up to you.
0
1
0
0
2015-04-23T04:57:00.000
2
0.099668
false
29,814,020
0
0
1
1
I am pretty familiar with building web based apps using python django on my linux machine. But when I decided to try my hand at building desktop applications that can run on windows/linux I didn't know where to begin. I know I can surely build windows desktop application on windows machine. But I am pretty comfortable with linux and don't want to get out of that comfort zone. Can anyone guide me as to what tools can I begin with to develop a simple windows desktop application. I would target windows 7 for starters. Any guidance is hugely appreciated.
how to change the subject for Django error reporting emails?
42,911,596
3
7
1,862
0
python,django
If you need it only for reporting errors the best choice would be to inherit from the django.utils.log.AdminEmailHandler and override the def format_subject(self, subject): method. Note that changing EMAIL_SUBJECT_PREFIX will affect not only error emails but all emails send to admins including system information emails or so.
0
0
0
0
2015-04-24T05:56:00.000
2
0.291313
false
29,839,766
0
0
1
1
i noticed about to change the subject for django error reporting emails, is it possible to change subject? can we modify the subject for Django error reporting emails ?
what metric should I monitor for a spider in scrapy
29,871,881
0
0
161
0
python,scrapy
Your question doesn't compute, because the answer depends solely on your specific use case and the goal of your scraping. The criteria/metric of spiders success is directly derived from your business logic. Just take a step back and ask yourself, what do I want to achieve with this spider? When you answer that, the metric you should monitor will be very clear.
0
0
0
0
2015-04-24T10:40:00.000
1
1.2
true
29,845,345
0
0
1
1
To make sure everything is working properly, what metric should I monitor for a general spider? Currently, I'll monitor the number of item returned. E.g. the percentage change should be less than 1% the number of error in log file. E.g. the error number should be zero is it enough for a general spider?
App engine Datastore cache or memcache
29,846,381
1
0
290
0
python,google-app-engine
The 'Datastore caching' you refer to is implemented using memcache under the hood anyway, so you won't gain from additional explicit caching of these entities. Python's ndb API and Java's Objectify both provide memcache-based automated caching for exactly this scenario. Of course, you can still use memcache independently for additional application caching.
0
1
0
0
2015-04-24T10:56:00.000
1
1.2
true
29,845,685
0
0
1
1
I have read that the datastore read request in the App engine get cached and subsequent reads performed on the same entity are fast. So if i read an entity from datastore, are there any tangible benefits of storing the entity in the memcache explicitly for later fetches? Or would the datastore caching serve with sufficient efficiency?
GAE: how to get current server IP?
29,846,170
0
0
157
0
python,google-app-engine
I'm not entirely clear on what you're looking for, but you can retrieve that type of information from the WSGI environmental variables. The method of retrieving them varies with WSGI servers, and the number of variables made available to your application depends on the web server configuration. That being said, getting client IP address is a common task and there is likely a method on the request object of the web framework you are using. What framework are you using?
0
1
0
0
2015-04-24T11:08:00.000
1
0
false
29,845,940
0
0
1
1
I'm hosting my app on Google App Engine. Is there any posibility to get server IP of my app for current request? More info: GAE has a specific IP addressing. All http requests go to my 3-level domain, and IP of this domain isn't fixed, it changes rather frequently and can be different on different computers at the same moment. Can I somehow find out, what IP address client is requesting now? Thank you!
Django way for multiple translations for one language or parametrize translations
29,846,744
-1
3
521
0
python,django,internationalization,translation
I assume that you are using Django to create an API, and you consume the API with javascript. You can check the user-agent string from the header and make the appropriate redirect according to the request.
0
0
0
0
2015-04-24T11:41:00.000
3
-0.066568
false
29,846,606
0
0
1
1
I have django app which is backend for javascript application intended for multiple TV devices. Each device has different frontend but I don't think that creating multiple .po files is good idea for this goal, because most of translations are repetitive for these devices. Is this possible to add additional parameters for translations, for example in my case some function with parameter "device" would be very useful? If not, how to do in Django way?
Nginx/Uwsgi log showing duplicate requests
29,899,664
0
1
602
0
python,flask,uwsgi
Sorry false alarm. This was my Devops incorrectly pinging my actual application route for heartbeat. Sorry for the confusion.
0
1
0
0
2015-04-24T14:49:00.000
1
1.2
true
29,850,613
0
0
1
1
I'm running a flask application using nginx and uwsgi and I noticed when I tail the logs for uwsgi it looks like its just constantly polling my app when I'm doing nothing. It also seems like it's cycling through the cores on my machine with each request so I see this in the logs. [pid: 27182|app: 0|req: 557/784] {26 vars in 254 bytes} [09:33:38 2015] GET / => generated 1337 bytes in 11 msecs ( 200) 3 headers in 238 bytes (1 switches on core 0) [pid: 27182|app: 0|req: 558/785]{26 vars in 254 bytes} [09:33:42 2015] GET / => generated 1337 bytes in 11 msecs ( 200) 3 headers in 238 bytes (1 switches on core 1) [pid: 27182|app: 0|req: 559/786] {26 vars in 254 bytes} [09:33:43 2015] GET / => generated 1337 bytes in 11 msecs ( 200) 3 headers in 238 bytes (1 switches on core 2) [pid: 27182|app: 0|req: 560/787] {26 vars in 254 bytes} [09:33:47 2015] GET / => generated 1337 bytes in 11 msecs ( 200) 3 headers in 238 bytes (1 switches on core 3) Nginx shows something similar. It's just constantly issuing a request to my app. It's only doing this when nginx is on. If I stop nginx the polling stops. My app is up and working but I don't know why this is happening. Is this normal behavior for nginx/uwsgi when using the uwsgi protocol? EDIT Im also using uwsgi in emperor mode
Model.objects.get returns nothing
29,882,375
0
0
57
1
python,django,object,get,models
I solved it by using transaction.commit() before my second query.
0
0
0
0
2015-04-24T18:00:00.000
1
1.2
true
29,854,433
0
0
1
1
I'm having this weird problem when using Model.objects.get(op1=1,op2=2) it raises the does not exist error although it exists. Did that ever happen with anyone? I even checked in my logs to make sure that the log happened when the id already existed in the database. [2015-04-24 20:18:21,106] ERROR: Couldn't find the model entry: Traceback (most recent call last): DoesNotExist: NpBilling matching query does not exist. and in the database, the last modified date for this row specifically is 20:18:19. How could that possible ever happen?! The weird thing is that sometimes it works and sometimes it throws this error. I tried to use get_or_create but I end up with 2 entries in the database. one of them is what was already created. Thanks in advance for your help. I would appreciate fast responses and suggestions.
Webapp2 Redirect Method
29,866,631
2
1
177
0
python,google-app-engine,webapp2
Use a 307 redirect. A 307 will not change the method of the redirect. Wikipedia: 307 temporary redirect (provides a new URL for the browser to resubmit a GET or POST request)
0
1
0
0
2015-04-25T14:09:00.000
1
1.2
true
29,866,234
0
0
1
1
I am trying to redirect a POST request from an Google App Engine Python Handler to another URL. The Problem is that it seems the method is changed to GET. Is there any way to set the POST method when redirecting?
Unable to create a file on Ubuntu server using Flask and Python
29,876,936
0
0
170
0
python,apache,flask
Solved it by giving absolute path. I was trying all combinations of paths and also gave absolute path /var/www/arxiv/static/data/name.json and it worked.
0
0
0
0
2015-04-26T10:10:00.000
1
0
false
29,876,315
1
0
1
1
I am using f = open('name.json','w+') to create a new file and write to it. But i am unable to create the file. Apache server logs show "No such file exists."
Is it possible to maintain a reusable django *project* across apps?
31,610,217
0
0
98
0
python,django,git
A possibility, as suggested, is templating the project which could suffice. However, templating projects would result in a different starting point for every project. Since templates evolve over time there's not one project that starts the same. Having a baseline throughout all your projects seems only worth pursuing if your big enough as a (development) company and are building enough different projects. A baseline in this case can be a custom python egg or additional django app added to your Django project. Such an app can enforce deployment strategies or help maintain infrastructural dependancies. For instance, propagating/configuring server information about your infrastructure or other services. Think of db, storage, auth services and other backends. When moving to a different inhouse storage backend or it's new API version, your app can smoothen the transition. If you don't already have added (re-usable) apps to your project specifically to hook up your project to the storage service. So, in short, I think the answer to my own question is: Yes, create reusable apps for this as far as possible but always make sure the solution is not bigger then the problem.
0
0
0
0
2015-04-26T11:11:00.000
1
1.2
true
29,876,874
0
0
1
1
I'm trying to decide whether underneath 'reusable apps' it is doable to maintain a reusable bare project setup as well. On a side note: I can destroy any of my servers and rebuild it in barely hours as long as I have a (data) backup and a blueprint (in my case saltstack, but it might just as well be puppet, chef or what not). With a flexible infra, these deployment steps are next: Create a virtualenv for the django application Check out my project (always named project) My project has a setup.py included. This sets the surroundings: render settings files based on yaml data and templates Possibly loads fixtures when needed When in production, it renders apache config etc After that, as git submodules, you can plug your reusable apps to end up with a running webapplication. With quite a lot of intelligency built in the bare project base structure I ended up with my original question. I'm wondering if the project baseline is maintainable as a cross (Web)Application seperate git repo. Or does the project structure itself have to much specific moving parts related to the (Web)Application as a whole? E.g: pluggable apps go in INSTALLED_APPS, etc and always ending up with to much related/changing data. Hope it's clear. Looking forward to you comments
How to export a schedule to Google Calendar?
29,885,432
1
0
186
0
python,django,google-calendar-api
You can export it as CSV, much easier, and Google calendar supports it as Import format
0
0
0
0
2015-04-27T00:42:00.000
1
1.2
true
29,885,414
0
0
1
1
I'm writing an app in Django, I would like to be able to allow users to export an event schedule to Google Calendar. I was thinking about exporting the schedule to an iCal file, but I would have to use some unpopular third party libraries, which sounds like a lot of trouble. Does Django have a functionality like that?
Yes/No message box in Odoo
42,901,463
0
0
3,798
0
python,messagebox,odoo
You can do one thing. Call a form view using button (type="action"). In form view footer, keep your button. On clicking on the button do your desired operation. NB: Your form view model should be different. Should not be same as current view.
0
0
0
0
2015-04-27T06:48:00.000
2
0
false
29,888,975
0
0
1
1
I would like to show a message box with 'text', 'Yes' and 'No' button. If users click 'Yes', to continue the method work. How could I add this alert message box in my Odoo by Python? If you have any idea, please share me. Thanks.
ODOO, calendar.event : bool have no attribute replace
29,891,572
0
0
823
0
python-2.7,calendar,odoo,odoo-8
Is your field used for 'display_start' on your view has a default value on your model ? I think it's because it returns False for this field you have this error. If it returns today, I think it will be ok.
0
0
0
0
2015-04-27T07:59:00.000
1
1.2
true
29,890,204
0
0
1
1
I extends class calendar_event for add status with statusbar. It's work perfectly when i update an event BUT when i tried to create i've a problem : Traceback (most recent call last): File "/home/x/workspace/Odoo8/openerp/http.py", line 530, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/x/workspace/Odoo8/openerp/http.py", line 567, in dispatch result = self._call_function(**self.params) File "/home/x/workspace/Odoo8/openerp/http.py", line 303, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/x/workspace/Odoo8/openerp/service/model.py", line 113, in wrapper return f(dbname, *args, **kwargs) File "/home/x/workspace/Odoo8/openerp/http.py", line 300, in checked_call return self.endpoint(*a, **kw) File "/home/x/workspace/Odoo8/openerp/http.py", line 796, in __call__ return self.method(*args, **kw) File "/home/x/workspace/Odoo8/openerp/http.py", line 396, in response_wrap response = f(*args, **kw) File "/home/x/workspace/alpbureautique_openerp/openerp/addons/web/controllers/main.py", line 949, in call_kw return self._call_kw(model, method, args, kwargs) File "/home/x/workspace/alpbureautique_openerp/openerp/addons/web/controllers/main.py", line 941, in _call_kw return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) File "/home/x/workspace/Odoo8/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/x/workspace/alpbureautique_openerp/openerp/cap_addons/cap_CRM/models/calendar_event.py", line 66, in create res = super(calendar_event, self).create(cr, uid, vals, context=context) File "/home/x/workspace/Odoo8/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/x/workspace/alpbureautique_openerp/openerp/addons/crm/calendar_event.py", line 36, in create res = super(calendar_event, self).create(cr, uid, vals, context=context) File "/home/x/workspace/Odoo8/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/x/workspace/alpbureautique_openerp/openerp/addons/calendar/calendar.py", line 1646, in create res = super(calendar_event, self).create(cr, uid, vals, context=context) File "/home/x/workspace/Odoo8/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/x/workspace/alpbureautique_openerp/openerp/addons/mail/mail_thread.py", line 377, in create thread_id = super(mail_thread, self).create(cr, uid, values, context=context) File "/home/x/workspace/Odoo8/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/x/workspace/Odoo8/openerp/api.py", line 336, in old_api result = method(recs, *args, **kwargs) File "/home/x/workspace/Odoo8/openerp/models.py", line 4042, in create record = self.browse(self._create(old_vals)) File "/home/x/workspace/Odoo8/openerp/api.py", line 239, in wrapper return new_api(self, *args, **kwargs) File "/home/x/workspace/Odoo8/openerp/api.py", line 462, in new_api result = method(self._model, cr, uid, *args, **kwargs) File "/home/x/workspace/Odoo8/openerp/models.py", line 4214, in _create recs.modified(self._fields) File "/home/x/workspace/Odoo8/openerp/api.py", line 239, in wrapper return new_api(self, *args, **kwargs) File "/home/x/workspace/Odoo8/openerp/models.py", line 5608, in modified spec += self._fields[fname].modified(self) File "/home/x/workspace/Odoo8/openerp/fields.py", line 1414, in modified spec = super(_Relational, self).modified(records) File "/home/x/workspace/Odoo8/openerp/fields.py", line 908, in modified target = env[field.model_name].search([(path, 'in', records.ids)]) File "/home/x/workspace/Odoo8/openerp/api.py", line 239, in wrapper return new_api(self, *args, **kwargs) File "/home/x/workspace/Odoo8/openerp/api.py", line 462, in new_api result = method(self._model, cr, uid, *args, **kwargs) File "/home/x/workspace/alpbureautique_openerp/openerp/addons/calendar/calendar.py", line 1511, in search res = self.get_recurrent_ids(cr, uid, res, args, order=order, context=context) File "/home/x/workspace/Odoo8/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/x/workspace/alpbureautique_openerp/openerp/addons/calendar/calendar.py", line 1187, in get_recurrent_ids result_data.append(self.get_search_fields(ev, order_fields)) File "/home/x/workspace/alpbureautique_openerp/openerp/addons/calendar/calendar.py", line 1155, in get_search_fields sort_fields['sort_start'] = browse_event['display_start'].replace(' ', '').replace('-', '') AttributeError: 'bool' object has no attribute 'replace' This error is raise when i call create() by super() and it's link with field "participant_without_owner" My code : class calendar_event(osv.Model): _inherit = 'calendar.event' _columns = { 'cap_state':fields.selection( [('open', 'Confirmed'), ('cancel', 'Cancelled'), ('pending', 'Pending'), ('done', 'Held') ], string='Status', track_visibility='onchange', help='The status is set to Confirmed, when a case is created.\n' 'When the call is over, the status is set to Held.\n' 'If the callis not applicable anymore, the status can be set to Cancelled.'), 'participant_without_owner':fields.char(compute="_compute_participant",store=True), } _default = { 'cap_state':'open' } @api.depends('partner_ids', 'user_id') def _compute_participant(self): for record in self: if record.user_id.partner_id in record.partner_ids: participants = record.partner_ids - record.user_id.partner_id chaine = str("") for p in participants: chaine = chaine + p.name + ", " record.participant_without_owner = chaine def done_event_in_tree(self, cr, uid, ids, context=None): res = self.write(cr, uid, ids, {'cap_state': 'done'}, context) return res def create(self,cr, uid, vals, context=None): import datetime as dt if context is None: context = {} date_appel = datetime.strptime(vals['start_datetime'], '%Y-%m-%d %H:%M:%S') print type(date_appel) print type(dt.datetime.today()) if date_appel > dt.datetime.today(): vals['cap_state'] = 'open' else: vals['cap_state'] = 'done' vals['participant_without_owner'] = "" print vals res = super(calendar_event, self).create(cr, uid, vals, context=context) return res In odoo v8
How to manage django and flask application sharing one database model?
29,890,773
2
6
3,757
1
python,django,flask,sqlalchemy
Firstly, don't do this; you're in for a world of pain. Use an API to pass data between apps. But if you are resigned to doing it, there isn't actually any problem with migrations. Write all of them in one app only, either Django or Alembic and run them there. Since they're sharing a database table, that's all there is to it.
0
0
0
0
2015-04-27T08:25:00.000
2
0.197375
false
29,890,684
0
0
1
1
I have two repository written in flask and django. These projects sharing the database model which is written in SQLAlchemy in flask and written in Django ORM. When I write migration script in flask as alembic, How can django project migrates with that script? I also think about Django with SQLAlchemy. But I can't find out Django projects using SQLAlchemy. Is that bad idea? Thanks.
Django: How to automatically change a field's value at the time mentioned in the same object?
29,903,655
-1
18
13,168
0
python,django,django-models,celery,django-celery
Is there any reason you wouldn't just calculate the boolean field in your business logic? i.e. when you receive a request related to that race, simply check the times and assess whether or not the race is active (for display, analysis), etc. I'm assuming you won't have high load (one reason for pre-processing) like this.
0
0
0
0
2015-04-27T18:18:00.000
5
-0.039979
false
29,903,134
0
0
1
1
I am working on a django project for racing event in which a table in the database has three fields. 1)Boolean field to know whether race is active or not 2)Race start time 3)Race end time While creating an object of it,the start_time and end_time are specified. How to change the value of boolean field to True when the race starts and to False when it ends? How to schedule these activities?
Webapp architecture: Putting python in a MEAN stack app
36,828,297
1
1
1,124
0
python,angularjs,mongodb,frameworks,mean-stack
To answer my own question about a year later, what I would do now is just run my python script in tiny web server that lived on the same server as my MEAN app. It wouldn't have any external ports exposed and the MEAN app would just ping it for information and get JSON back. Just in case anyone is looking at this question down the road... I find this way easier than trying to integrate the python script into the application itself.
0
0
0
0
2015-04-27T18:31:00.000
1
0.197375
false
29,903,381
0
0
1
1
I currently have a small webapp on AWS based on the MEAN (Mongo, Express, Angular, Node) but have a python script I would like to execute on the front end. Is there a way to incorporate this? Basically, I have some data objects on my AngularJS frontend from a mongoDB that I would like to manipulate with python and don't know how to get them into a python scope, do something to them, and send them to a view. Is this possible? If so, how could it be done? Or is this totally against framework conventions and should never be done? from
Cannot upload to an app ID though I have the correct permissions
29,906,509
0
0
30
0
python,google-app-engine,console,cloud
Most likely, you are logged into Gmail under a different account. Go to Gmail, and click Sign Out. Then go to the developer console. It should ask you to log in or select from several accounts.
0
1
0
0
2015-04-27T19:01:00.000
1
0
false
29,903,889
0
0
1
1
(I've been using appengine since 2009 and haven't needed support until now.) I've been added to a new project from the cloud console. When I try to upload the app, AppEngine launcher says "This application does not exist". Furthermore, in Cloud console, nothing appears under the appengine heading. At the same time, however, the old appengine.appspot.com DOES have the application listed. Any help?
Running node, PHP and Python on the same vps
29,909,359
1
0
789
0
php,python,node.js,ubuntu,nginx
The kind of setup you're describing is straightforward and not complicated. Nginx works fine as a reverse proxy and web server that handles serving static assets. For PHP, you just need to proxy to php-fpm (running on a TCP port or unix socket). For Python, you need a wsgi server (something like uwsgi or gunicorn, again using a TCP port or unix socket) to server the Python app and have Ngix proxy to requests to it. For your Node.js app, just run the node server on a port like 8000 and have Nginx proxy requests to it. If you have a bunch of websites, each should have a server block matching a unique server name (i.e. mapped to a virtual host). The setup is as reliable as your backend services (like php-fpm, wsgi, and Node.js server). As long as those services are up and running (as daemon services) nginx should have no problem proxying to them. I have used all 3 setups on one server and have never experienced problems with any of the above.
0
0
0
1
2015-04-27T22:10:00.000
1
0.197375
false
29,906,888
0
0
1
1
Is there a rational way to serve multiple websites via PHP:Nginx, Python:??? & node.js on the same vps? And would it be reliable? The sites are expected to be low in traffic. I currently have PHP running on Nginx, Ubuntu via Digital Ocean and I would like to stick to Nginx for PHP and any major webserver for Python.
Cannot import Beautiful Soup
57,754,599
0
18
46,868
0
python,beautifulsoup
The best way to resolve is, while creating your interpreter select your global python path on your system(/usr/local/bin/python3.7). Make sure that in pycharm shell, python --version appears as 3.7. It shouldn't show 2.7
0
0
1
0
2015-04-27T22:57:00.000
15
0
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
54,489,766
1
18
46,868
0
python,beautifulsoup
One of the possible reason: If you have more than one python versions installed and let's say you installed beautifulsoup4 using pip3, it will only be available for import when you run it in python3 shell.
0
0
1
0
2015-04-27T22:57:00.000
15
0.013333
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
53,284,293
3
18
46,868
0
python,beautifulsoup
Copy bs4 and beautifulsoup4-4.6.0.dist-info from C:\python\Lib\site-packages to your local project directory. It worked for me. Here, python actually looks for the library in local directory rather than the place where the library was installed!
0
0
1
0
2015-04-27T22:57:00.000
15
0.039979
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
52,847,210
3
18
46,868
0
python,beautifulsoup
I experienced a variation of this problem and am posting for others' benefit. I named my Python example script bs4.py Inside this script, whenever trying to import bs4 using the command: from bs4 import BeautifulSoup, an ImportError was thrown, but confusingly (for me) the import worked perfectly from an interactive shell within the same venv environment. After renaming the Python script, imports work as expected. The error was caused as Python tries to import itself from the local directory rather than using the system copy of bs4
0
0
1
0
2015-04-27T22:57:00.000
15
0.039979
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
72,153,534
0
18
46,868
0
python,beautifulsoup
For me it was a permissions issue. Directory "/usr/local/lib/python#.#/site-packages/bs4" was only 'rwx' by root and no other groups/users. Please check permissions on that directory.
0
0
1
0
2015-04-27T22:57:00.000
15
0
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
59,960,168
5
18
46,868
0
python,beautifulsoup
Make sure the directory from which you are running your script does not contain a filename called bs4.py.
0
0
1
0
2015-04-27T22:57:00.000
15
0.066568
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
69,835,809
0
18
46,868
0
python,beautifulsoup
I had the same problem. The error was that the file in which I was importing beautifulsoup from bs4 was in another folder. Just replaced the file out of the internal folder and it worked.
0
0
1
0
2015-04-27T22:57:00.000
15
0
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
61,982,622
0
18
46,868
0
python,beautifulsoup
There is no problem with package just need to Copy bs4 and beautifulsoup4-4.6.0.dist-info into your project directory
0
0
1
0
2015-04-27T22:57:00.000
15
0
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
51,398,896
0
18
46,868
0
python,beautifulsoup
I was also facing this type error in the beginning even after install all the modules which were required including pip install bs4 (if you have installed this then no need to install beautifusoup4 | BeautifulSoup4 through pip or anywhere else it comes with bs4 itself) Solution : Just go to your python file where it is installed C:\python\Lib\site-packages and then copy bs4 and beautifulsoup4-4.6.0.dist-info folders and paste it to your project folder where you have saved your working project.
0
0
1
0
2015-04-27T22:57:00.000
15
0
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
70,643,924
0
18
46,868
0
python,beautifulsoup
For anyone else that might have the same issue as me. I tried all the above, but still didn't work. issue was 1 was using a virtual environment so needed to do pip install in the pycharm terminal instead of a command prompt to install it there. Secondly I had typed import Beautifulsoup with the S not capitalized. changed to BeautifulSoup and it worked.
0
0
1
0
2015-04-27T22:57:00.000
15
0
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
29,924,863
17
18
46,868
0
python,beautifulsoup
The issue was I named the file HTMLParser.py , and that name is already used somewhere in the bs4 module. Thanks to everyone that helped!
0
0
1
0
2015-04-27T22:57:00.000
15
1.2
true
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Cannot import Beautiful Soup
60,569,945
6
18
46,868
0
python,beautifulsoup
I found out after numerous attempts to solve the ImportError: cannot import name 'BeautifulSoup4' that the package is actually called BeautifulSoup so the import should be: from bs4 import BeautifulSoup
0
0
1
0
2015-04-27T22:57:00.000
15
1
false
29,907,405
0
0
1
12
I am trying to use BeautifulSoup, and despite using the import statement: from bs4 import BeautifulSoup I am getting the error: ImportError: cannot import name BeautifulSoup import bs4 does not give any errors. I have also tried import bs4.BeautifulSoup and just importing bs4 and creating a BeautifulSoup object with: bs4.BeautifulSoup() Any guidance would be appreciated.
Avoid duplicate entries in Datastore
29,918,649
2
1
456
0
python-2.7,google-app-engine,google-cloud-datastore,webapp2
Hash the entities and use the hash value as the key for your Entity.
0
1
0
0
2015-04-28T09:34:00.000
1
0.379949
false
29,915,632
0
0
1
1
I am trying to send the data to google app engine in python using Webapp2, But when I check the entries in the data in console I found duplicate entries which means except Id everything is same.I want to avoid those duplicate entries.Please suggest me if there is anyway to find the duplicate values to avoid.Thanks in advance.
Socket communication with Django
29,916,039
1
0
409
0
python,django
You can use with django any python packages as with any "normal" python program. If you have a module, that communicate with your server, you can use this, if not, you have to write one on your own possibly with socket programming.
0
0
1
0
2015-04-28T09:45:00.000
1
1.2
true
29,915,865
0
0
1
1
Is it possible to use Django for communication with some kind of server process? For example on my Django website I want to have form where I input connection details (host and port) and after connection I want to send some request or events to other server process (some simple action like slider moving or clicking a button). Can I use python socket programming for this or is there some easier way?
Display progress of a long running Python task in Django
29,927,235
1
2
1,205
0
python,django,celery,django-celery
My first suggestion is to psychologically separate celery from django when you start to think of the two. They can run in the same environment, but celery is to asynchronous processes what django is to http requests. Also remember that celery is unlike diango in that it requires other services to function; a message broker. So by using celery you will increase your architectural requirements. To address you specific use case, you'll need a system to publish messages from each celery task to a message broker and your web client will need to subscribe to those messages. There's a lot involved here, but the short version is that you can use Redis as your celery message broker as well as your pub/sub service to get messages back to the browser. You can then use e.g diango-redis-websockets to subscribe the browser to the task state messages in redis
0
0
0
0
2015-04-28T18:13:00.000
1
0.197375
false
29,926,911
0
0
1
1
I currently have a typical Django structure set up for a project and one web application. The web application is set up so that a user inputs some information, and this information is taken as the input to run a Python program. This python program sometimes can take quite a while to finish (grabbing things from the web and doing some text mining scoring) - sometimes it can take multiple minutes to load. On the command line, this program would periodically display where it was in the process (it'd first say how many things it found to score against, then it'd say where in the number of things found it is in the scoring process), which was very useful. However, when I moved this over to a Django set up, I no longer have this capability (at least, not in the same way since now this is sent to log files). The way I set it up is that there is an input view, and then a results view. The results view takes the input and runs the Python program. It won't display the results until the entire program is run. So on the user side, the browser just sits there for sometimes minutes before the results are displayed. Obviously, this is not ideal. Does anyone know of the best way to bring status information on a task to Django? I've looked into Celery a little bit, but I think since I'm still a beginner in Django that I'm confusing myself with some of the documentation. For instance: even if the task is sent off asynchronously to a worker, how does the browser grab the current state of the program?? Also, consistent documentation seems to be lacking for celery on Django (I've seen people set up celery many different ways on their Django projects). I would appreciate any input here, I've been stuck on this for a while now.
GAE module: "Request attempted to contact a stopped backend."
29,928,760
0
2
607
0
python,google-app-engine
Fixed by shutting down all instances (on all modules/versions just to be safe).
0
1
0
0
2015-04-28T19:42:00.000
1
1.2
true
29,928,477
0
0
1
1
I am currently experiencing an issue in my GAE app with sending requests to non-default modules. Every request throws an error in the logs saying: Request attempted to contact a stopped backend. When I try to access the module directly through the browser, I get: The requested URL / was not found on this server. I attempted to stop and start the "backend" modules a few times to no avail. I also tried changing the default version for the module to a previous working version, but the requests from my front-end are still hitting the "new", non-default version. When I try to access a previous version of the module through the browser, it does work however. One final symptom: I am able to upload my non-default modules fine, but cannot upload my default front-end module. The process continually says "Checking if deployment succeeded...Will check again in 60 seconds.", even after rolling back the update. I Googled the error from the logs and found almost literally nothing. Anyone have any idea what's going on here, or how to fix it?
Displaying pyqtgraph and pyqt widgets on web
29,947,088
0
4
1,640
0
python,django,pyqt,saas,pyqtgraph
Here is what I have sort of put together by pulling several threads online: Ruby On Rails seems to be more popular than python at this moment. If you go python, Flask and Django are good templates. bokeh seems to be a good way of plotting to a browser. AFAIK, there is no way to take an existing PyQt or pyqtgraph application and have it run on the web. I am not sure how Twisted (Tornado, Node.js and Friends) fits in to the web SaaS, but I see it referred to occasionally since it is asynchronous event-driven. People often suggest using Rest, but that seems slow to me. Not sure why...
1
0
0
0
2015-04-28T19:43:00.000
2
1.2
true
29,928,485
0
0
1
2
Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done. Any hints links examples welcome.
Displaying pyqtgraph and pyqt widgets on web
29,987,875
0
4
1,640
0
python,django,pyqt,saas,pyqtgraph
If all you need are static plots, then it should be straightforward to draw and export to an SVG file, then display the SVG in a webpage (or export to image, as svg rendering is not reliable in all browsers). If you need interactivity, then you're going to need a different solution and probably pyqtgraph is not the tool for this job. VisPy does have some early browser support but this has only been demonstrated with ipython notebook.
1
0
0
0
2015-04-28T19:43:00.000
2
0
false
29,928,485
0
0
1
2
Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done. Any hints links examples welcome.
Django rest framework: correctly handle incoming array of model ids
29,935,296
2
1
116
0
python,django,rest,django-rest-framework
Consider the upvote button to the left. When you click it, a request may be sent to stackoverflow.com/question/12345/upvote. It creates an "action resource" on the db, so later you can go to your user profile and check out the list of actions you took. You can consider doing the same thing for your application. It may be a better user experience to have immediate action taken like SO, or a "batch" request like with gmail's check boxes.
0
0
0
0
2015-04-29T05:38:00.000
1
0.379949
false
29,935,200
0
0
1
1
I have a question about REST design in general and specifically what the best way to implement a solution is in Django Rest Framework. Here it the situation: Say I have an app for keeping track of albums that the user likes. In the browser, the user sees a list of albums and each one has a check box next to it. Checking the box means you like the album. At the bottom of the page is a submit button. I want the submit button to initiate an AJAX request that sends tp my API endpoint a list of the ids (as in, the Djano model ids) of the albums that are liked by the user. My question is, is this a standard approach for doing this sort of thing (I am new to web stuff and REST in particular). In other words, is there a better way to handle the transmission of these data than to send an array of ids like this? As a corollary, if this is an alright approach, how does one implement this in Django Rest Framework in a way which is consistent with its intended methodology. I am keeping this question a little vague (not presenting any code for the album serializer, for example) intentionally because I am looking to learn some fundamentals, not to debug a particular piece of code. Thanks a lot in advance!
Remove # from the URL in Python Simple HTTP Server
29,939,768
0
0
1,156
0
python,angularjs,http,simplehttpserver
Well i had a similar problem but the difference is that i had Spring on the Server Side. You can capture page not found exception at your server side implementation, and redirect to the default page [route] in your app. In Spring, we do have handlers for page not found exceptions, i guess they are available in python too.
0
0
0
0
2015-04-29T09:08:00.000
3
0
false
29,939,110
0
0
1
1
I have an angularjs app that uses Angular UI Router and the URL that are created have a # in them.. Eg. http://localhost:8081/#/login. I am using Python Simple HTTP server to run the app while developing. I need to remove the # from the URL. I know how to remove it by enabling HTML5 mode in angular. But that method has its problems and i want to remove the # from the server side. How can i do this using Python Simple HTTP Server?
How does Heroku handle Django dependencies?
29,954,119
2
0
86
0
python,django,heroku
Heroku only uses the libraries in your requirements.txt file. Whatever version of Django is specified there is what it will install.
0
0
0
0
2015-04-29T18:47:00.000
4
0.099668
false
29,952,053
0
0
1
1
I'm starting to work on my first-ever Django/Heroku project – I'm working on a friend's web app that's already partially coded. It's built in Django 1.6. There's no virtualenv, and when I clone it and try to run it in Django 1.8 it crashes and burns. The app itself is currently online and functional, and when I run the app locally in Django 1.6, no issues. How is Heroku handling dependencies like this? Does it install dependencies on its server by reading the requirements.txt?
How to use a model from a Django project in another Python script
29,953,247
0
0
1,229
0
python,django
You can use sql alchemy You can add the mainscript as part of the django project You can serve content using Django Rest Framework, the database connection happens when you access through manage.py, the table is available to anyone with permissions. tl:dr; You need a connection to said database
0
0
0
0
2015-04-29T19:45:00.000
3
0
false
29,953,112
0
0
1
1
I have a directory which contains a Django project with a models.py in which I have defined some models. I have another directory somewhere else and which has a Python script. In this script I would like to import one of the models "Foo" from models.py. With the table "Foo", I want to create entries, update, get, etc... How do I go about doing this?
How to track anonymous users with Flask
30,008,742
4
7
2,806
0
python,flask,flask-login,anonymous-users
You can use a AnonymousUserMixin subclass if you like, but you need to add some logic to it so that you can associate each anonymous user with a cart stored in your database. This is what you can do: When a new user connects to your application you assign a randomly generated unique id. You can write this random id to the user session (if you want the cart to be dropped when the user closes the browser window) or to a long-lived cookie (if you want the cart to be remembered even after closing the browser). You can use Flask-Login for managing the session/cookie actually, you don't have to treat unknown users as anonymous, as soon as you assign an id to them you can treat them as logged in users. How do you know if an anonymous user is known or new? When the user connects you check if the session or cookie exist, and look for the id there. If an id is found, then you can locate the cart for the user. If you use a subclass of AnonymousUserMixin, then you can add the id as a member variable, so that you can do current_user.id even for anonymous users. You can have this logic in the Flask-Login user loader callback. When the user is ready to pay you convert the anonymous user to a registered user, preserving the id. If you have a cron job that routinely cleans up old/abandoned anonymous carts from the database, you may find that an old anonymous user connects and provides a user id that does not have a cart in the database (because the cart was deemed stale and deleted). You can handle this by creating a brand new cart for the same id, and you can even notify the user that the contents of the cart expired and were removed. Hope this helps!
0
0
0
0
2015-04-30T07:44:00.000
2
0.379949
false
29,961,898
0
0
1
2
My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented? The main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMixin object that is assigned to current_user. The assumption is that current_user will not change throughout the session. However, I noticed that a new AnonymousUserMixin object is assigned to current_user, for example, upon every browser page refresh. Notice that this does not happen if a user is authenticated. Any suggestions on how to circumvent this?
How to track anonymous users with Flask
29,962,315
9
7
2,806
0
python,flask,flask-login,anonymous-users
There is no need for a custom AnonymousUserMixin, you can keep the shopping cart data in session: anonymous user adds something to hist cart -> update his session with the cart data the user wants to check out -> redirect him to login page logged in user is back at the check out -> take his cart data out of the session and do whatever you would do if he was logged in the whole time
0
0
0
0
2015-04-30T07:44:00.000
2
1
false
29,961,898
0
0
1
2
My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented? The main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMixin object that is assigned to current_user. The assumption is that current_user will not change throughout the session. However, I noticed that a new AnonymousUserMixin object is assigned to current_user, for example, upon every browser page refresh. Notice that this does not happen if a user is authenticated. Any suggestions on how to circumvent this?
WebSockets best practice for connecting an external application to push data
29,967,827
0
2
704
0
python,websocket
It depends on your software design, if you decide the logic from WebSocketServer.px and CoreApplication.py belongs together, merge it. If not, you need some kind of inter process communication (ipc). You can use websockets for this ipc, but i would suggest, you use something simpler. For example, you can you json-rpc over tcp or unix domain to send control messages from CoreApplication.py to WebSocketServer.py
0
0
1
0
2015-04-30T12:19:00.000
1
0
false
29,967,612
0
0
1
1
I am trying to understand how to use websockets correctly and seem to be missing some fundamental part of the puzzle. Say I have a website with 3 different pages: newsfeed1.html newsfeed2.html newsfeed3.html When a user goes to one of those pages they get a feed specific to the page, ie newsfeed1.html = sport, newsfeed2.html = world news etc. There is a CoreApplication.py that does all the handling of getting data and parsing etc. Then there is a WebSocketServer.py, using say Autobahn. All the examples I have looked at, and that is alot, only seem to react to a message from the client (browser) within the WebSocketServer.py, think chat echo examples. So a client browser sends a chat message and it is echoed back or broadcast to all connected client browsers. What I am trying to figure out is given the following two components: CoreApplication.py WebSocketServer.py How to best make CoreApplication.py communicate with WebSocketServer.py for the purpose of sending messages to connected users. Normally should CoreApplication.py simply send command messages to the WebSocketServer.py as a client. For example like this: CoreApplication.py -> Connects to WebServerSocket.py as a normal client -> sends a Json command message (like broadcast message X to all users || send message Y to specific remote client) -> WebSocketServer.py determines how to process the incoming message dependant on which client is connected to which feed and sends to according remote client browsers. OR, should CoreApplication.py connect programatically with WebSocketServer.py? As I cannot seem to find any examples of being able to do this for example with Autobahn or other simple web sockets as once the WebSocketServer is instantiated it seems to run in a loop and does not accept external sendMessage requests? So to sum up the question: What is the best practice? To simply make CoreApplication.py interact with WebSocketServer.py as a client (with special command data) or for CoreApplication.py to use an already running instance of WebSocketServer.py (both of which are on the same machine) through some more direct method to directly sendMessages without having to make a full websocket connection first to the WebSocketServer.py server?
Running Python script in Django from submit
68,890,513
-1
8
37,522
0
python,django,django-forms
python manage.py <your_script_name> Here script name is ur python file .No need to mention .py extenstion.
0
0
0
0
2015-04-30T20:46:00.000
6
-0.033321
false
29,977,495
0
0
1
1
Perhaps there is a different way of going about this problem, but I am fairly new to using Django. I have written a custom Python script and would like to run a function or .py file when a user presses a "submit" button on the webpage. How can I get a parameter to be passed into a Python function from a submit button using Django?
Django syncdb on first deployment
29,980,168
0
1
300
0
python,django,deployment,django-models
syncdb has been changed to migrate since django 1.7 Migrations New in Django 1.7. Migrations are Django’s way of propagating changes you make to your models (adding a field, deleting a model, etc.) into your database schema. They’re designed to be mostly automatic, but you’ll need to know when to make migrations, when to run them, and the common problems you might run into. Prior to version 1.7, Django only supported adding new models to the database; it was not possible to alter or remove existing models via the syncdb command (the predecessor to migrate). The difference betwen migrate and makemigrations is nicely stated by doru.
0
0
0
0
2015-04-30T22:26:00.000
2
0
false
29,978,859
0
0
1
1
So I've managed to create a site with django 1.8 and I'm ready to deploy. I have several new models and I'm using django-allauth which has it's own models. I've also managed to make changes to settings with a config file to use different databases for production and development as well as turning off debug when it's production, etc. I've uploaded my project folder to the production server and getting ready to add new lines in http.conf for Apache but I can't wrap my head around the database. Do I run syncdb or makemigrations on the production server? How does django know to use the production db and not the development db. My settings look for hostname from socket to decide if it's production or development. What should I do next?
Generating new SQLite database django
66,293,699
3
7
5,560
1
python,django,web
When you have no database in your project, a simple python manage.py migrate will create a new db.sqlite3 file.
0
0
0
0
2015-05-01T17:30:00.000
2
0.291313
false
29,991,871
0
0
1
1
I had a duplicate sqlite database. I tried deleting the duplicate but instead deleted both. Is there a way I can generate a new database? The data was not especially important.
PyCharm integrated debugger slows down application
30,017,850
3
5
2,048
0
python,performance,debugging,pycharm
The way to get fast debugging sessions in PyCharm (Professional edition) is to use remote debugging, similar to pdb.set_trace(). In the Run/Debug Configurations dialogue, create a Remote Debug configuration. The dialogue contains the instructions, which I will repeat here completeness sake: Add pycharm-debug.egg from the PyCharm installation to the Python path. Add the following import statement: import pydev Add the following command to connect to the debug server: pydevd.settrace('localhost', port=$SERVER_PORT, stdoutToServer=True, stderrToServer=True) These strings can be copied from the dialogue and pasted into the source. When you choose the host and server port in the dialogue, the pasteable strings will update themselves. Of course, they can also be concatenated to a oneliner using ;. After the settrace() method has been run, the breakpoints you have set in PyCharm will become active. So, where's the file pycharm-debug.egg? Somewhere in the near vicinity of the PyCharm binary. In OS X, you will find the file within the Contents/debug-eggs directory within PyCharm.app. I assume other PyCharm distributions have a similar directory. If you're running the application using a virtualenv, install the egg using easy_install. If you prefer to run your application within PyCharm (stdout in the PyCharm console is useful), then add the path to the egg file to the Project Interpreter's file paths.
0
0
0
0
2015-05-02T18:04:00.000
1
0.53705
false
30,005,704
1
0
1
1
I am using PyCharm to debug a moderately complex Pyramid web application with a lot of dependencies. When I run the application inside PyCharm using PyCharm's Debug run, the application start up slows down significantly. This kills the normal web application workflow of edit, save, refresh. The slowdown is significant, making the application restart to take tens of seconds instead of fractions of seconds. Is there a way to speed up PyCharm debug runs any way? The similar slowdown would not occur if one is using hardcoded import pdb ; pdb.set_trace() style breakpoints and normal Run mode.
Python script fallback to second server
30,035,305
1
1
104
0
python,pushbullet
Could you shutdown the script on your VPS, copy the cache files over the the Pi and run the script there? Then do the reverse when you want to move it back to the VPS. You could possibly run the script on both systems, but then you'd need to synchronize between them which sounds like a lot of unnecessary work. For instance you could run a third server that you can check with to see if you've sent something yet, but you would need to be able to lock items on there so you don't have a race condition between your two scripts.
0
1
0
1
2015-05-03T02:24:00.000
1
0.197375
false
30,009,595
0
0
1
1
I have a Python script that manages Pushbullet channels for Nexus Android device factory images. It runs on my VPS (cron job that runs every 10 minutes), but my provider has warned that there may be intermittent downtime over the next several days. The VPS is running Ubuntu Server 15.04. I have a Raspberry Pi that's always on, and I can easily modify the script so that it works independently on both the VPS and the Pi. I would like the primary functionality to exist on the VPS, but I want to fall back to the Pi if the VPS goes down. What would be the best way to facilitate this handoff between the two systems (in both directions)? The Pi is running Raspbian Wheezy. Additionally, the script uses urlwatch to actually watch the requisite page for updates. It keeps a cache file on the local system for each URL. If the Pi takes over and determines a change is made, it will notify the Pushbullet channel(s) as it should. When the VPS comes back up and takes over, it will have the old cache files and will notify the channel(s) again, which I want to avoid. So: How can I properly run the script on whichever system happens to be up at the moment (preferring the VPS), and how can I manage the urlwatch caches between the two systems?
Why are my imports no longer working?
30,010,724
5
5
299
0
python,google-app-engine,pycharm,wtforms
Try deleting the libraries from your project if they are in libraries, then re-importing those libraries. Also, I assume you've done this, but make sure the libraries are actually installed and present in a reachable location that is properly mapped.
0
0
0
0
2015-05-03T05:40:00.000
2
0.462117
false
30,010,620
1
0
1
2
I refactored my webapp and now my IDE pycharm marks some imports red. Why? from wtforms import Form, TextField, validators, SelectField My IDE marks the Form, TextField and the SelectField red as they cannot be imported. ("Unresolved reference"). What should I do if I need those classes in my project?
Why are my imports no longer working?
30,010,736
3
5
299
0
python,google-app-engine,pycharm,wtforms
You need to install it in in your environment(according to the comments you didn't), please try the following: Settings -> Project: MyProjectName -> Project Interpreter Then click on the green plus and choose your packages
0
0
0
0
2015-05-03T05:40:00.000
2
1.2
true
30,010,620
1
0
1
2
I refactored my webapp and now my IDE pycharm marks some imports red. Why? from wtforms import Form, TextField, validators, SelectField My IDE marks the Form, TextField and the SelectField red as they cannot be imported. ("Unresolved reference"). What should I do if I need those classes in my project?
Django/apache handle incomplete/cancelled http requests
30,021,032
7
4
5,582
0
python,django,apache,http
When reading request content, if the required length of content had not been read, then the WSGI layer would when wsgi.input.read() was called raise an IOError exception. This may be passed on as is in Django, or in more recent versions be changed to a different derived IOError exception type called UnreadablePostError. When your application code isn't specifically checking for broken request content and handling that exception type, then it propagates back up and is dealt with by Django as an unhanded exception. Django will at that point attempt to write a 500 error response. When that is written by the WSGI layer, it will fail as the connection had been closed, something that can only be detected by actually attempting to write the response. So Django should not be giving you incomplete POST data and there should be an exception being raised instead. As to whether there is a better way of handling it, the answer is no. With the WSGI specification being based around a blocking model, detection and handling of a dropped connections in a clean way isn't really possible. One would need to switch to an ASYNC web server and framework to be able to better handle it and that means not being able to use WSGI or Django. FWIW, there has been past discussions on the issue of dropped connections on the mod_wsgi mailing list. You might therefore go to Google Groups and search through the archives for the list using search terms like 'dropped connection' or 'failed connection' or 'closed connection' and see what you can find.
0
0
0
0
2015-05-03T22:42:00.000
1
1.2
true
30,020,226
0
0
1
1
When django is deployed on apache with mod_wsgi. It seems to handle incomplete or cancelled requests in a very odd way. If the client cancels the request, the cancelled request is not cancelled on django, for example, if you are uploading a big file, obviously the body of the request will be actually streamed, so while django is reading the body, and the client cancels the request, it is still processed (just incomplete) and the actual request cancel action is never noticed. This is one log example from apache, when a request is cancelled. [Fri May 01 22:05:51.055968 2015] [:error] [pid 31609] (70008)Partial results are valid but processing is incomplete: [client 172.31.43.91:3645] mod_wsgi (pid=31609): Unable to get bucket brigade for request. Then on django code, the actual POST dictionary is never built (because the request is incomplete, yet it arrives to django and is processed as if it had data), and so django will then fail when trying to get data (and return missing XX field errors, or what ever the logic does to handle them) Finally, when django tries to write back the response, it will obviously fail as well as the client already closed the connection. This scenario, happens very often on a request that is used as a REST service endpoint for a mobile app. The mobile app uploads large files and so the request is cancelled on app suspend/close, yet the server always seems to get the partial request. The complete log when this happens would look something like this: [Fri May 01 22:05:51.055968 2015] [:error] [pid 31609] (70008)Partial results are valid but processing is incomplete: [client 172.31.43.91:3645] mod_wsgi (pid=31609): Unable to get bucket brigade for request. [Fri May 01 22:05:51.062690 2015] [:error] [pid 10580] some error message related to missing data here [Fri May 01 22:05:51.068790 2015] [:error] [pid 10580] [remote 172.31.43.91:0] mod_wsgi (pid=10580): Exception occurred processing WSGI script 'some-path/wsgi.py'. [Fri May 01 22:05:51.068827 2015] [:error] [pid 10580] [remote 172.31.43.91:0] IOError: failed to write data Now the final question is, is there a way to detect this kind of incomplete request and handle it accordingly, rather than just failing later with missing required data?
Clickable links in terminal output
40,915,552
1
4
3,643
0
python,python-3.x,hyperlink,pycharm
As outlined above, you need to use a terminal that supports clicking of URL's. On linux, most terminals do this. Ex Gnome-terminal, terminator etc.. On Mac, try iterm2.
0
0
1
0
2015-05-04T09:35:00.000
1
0.197375
false
30,026,870
0
0
1
1
My python program outputs a set of url links. When I run this on pycharm, I can directly click on the links and that will open them up in the browser. However, when I run the python file by double clicking on the .py file, the links are not clickable. I want the links to be clickable so it takes me to the browser directly. Please support solutions with explanations as I am still learning. Thanks!
How to handle session and token based authentication simultaneously using middle ware in django?
30,053,316
3
2
755
0
python,django,django-rest-framework,django-authentication,http-token-authentication
In my case I have written custom middle-ware to handle the situation. 1. When I am login using API and api path is **/api/accounts/login**. So when request comes on this url then I am removing sessionid and csrftoken both. When HTTP_AUTHORIZATION is available in request, I remove the session and csrftoken. Using above two removal situation can be handled in my case. Thanks to everyone for helping.!!
0
0
0
0
2015-05-05T08:55:00.000
2
1.2
true
30,048,364
0
0
1
1
I want to use both token and session based authentication in my application with the priority of token. I have created two portal with the same URL one is using session and other is using token. So when session is available in cookie then token based request goes failed with "CSRF Token is missing" error message. One solution I have in my mind using middle-ware where I can make priority to token. If both are available in request then custom middle-ware will remove session related stuffs and keep only token related information and proceed. If anyone has solution available for this problem then please post in answer? Thanks in advance.
What is better: projectcontrib.pluginname or project-pluginname as a python project naming convention for small project?
30,057,386
0
1
43
0
python,pep8
At the end of the day, whats more important is consistency within your own code. Its important that your convention be constant. Or if you are coding with a group that your convention be consistent across your project. With that said, each language will have its own Style Guides. Style Guides offer consistency across the different projects, and help the community use an agreed upon convention. Python Style Guides will be different than Node.js style guides. So I would recommend following PEP when you are using Python.
0
0
0
0
2015-05-05T15:34:00.000
1
1.2
true
30,057,321
1
0
1
1
I created a small project on Python. Main app use some plugins. I would like to know which naming convention for namespaces is better? PEP-0423 recommends to use "project" namespace for main program and "projectcontrib.pluginname" for plugins. But django or node.js often use "project-pluginname" convention. What are pro and cons for both conventions?
Django Rest Framework and Angular
30,067,648
0
1
292
0
javascript,python,django,angularjs,django-rest-framework
I think the second one is better. In a restful-style project, front-end code is completely decouple with the back-end code. Besides, separate them into two projects is good for deployment. If you want to upgrade the front-end code, just upload them and restart nginx, front-end code totally is static.
0
0
0
0
2015-05-06T03:46:00.000
1
0
false
30,067,124
0
0
1
1
I am very new to Django Rest Framework (DRF) and AngularJs. What I wandering here is the best way to work with these two. DRF and AngularJs together (Most of tutorials showed me this) in one project DRF as backend and AngularJs in frontend as 2 different projects I am very confused, though I feel the 2nd approach is better. But still not sure. Can please anyone help me in this with pros and cons of both the approaches.
Python: Selenium send_key can't type numbers like 5 or 6
66,779,985
0
6
4,525
0
python,selenium
As dear @Epiwin mentioned ,it is a horrible bug in TightVNC or combination of chrome driver and it, I've removed it completely and install TigerVNC instead and eventually it worked. BTW, I don't know why! but the speed of the remote connection increased after migrate to TigerVNC, and it was another good point for mine.
0
0
1
0
2015-05-06T10:07:00.000
7
0
false
30,073,603
0
0
1
1
So I see this issue on google selenium site but it has not been resolved yet. when you element.send_key('12345') it will return '123'. The 5 is parsed as backspace.... is there a work around for this? Using latest selenium, chrome, chromedriver, python 2.7, ubuntu 12.04
Organising common code in django/python
30,156,768
1
1
214
0
python,django
There is no problem with having helpers, but I think you chose wrong naming strategy. The name of the module or package should tell you what function it performs. In your case you should name your helpers after the job they help you do. For example, StringHelpers or UrlUtils.
0
0
0
0
2015-05-06T12:05:00.000
1
0.197375
false
30,076,216
0
0
1
1
Sometimes we need in auxiliary functions, classes etc. Sometimes we put such entities into modules or packages. Currently I have three variants: Use helpers package or module. Use utils package or module (like in Java). Don't use something like it because it is anti pattern. If you have helpers then you have a application design problem. What do you prefer?
View error Can't find field 'blocked' in the following view parts composing the view of object model
52,777,087
0
0
410
0
python,postgresql,openerp,openerp-7
If you have frontend or backend instances. Make sure that: All code match in both instances Update your module check if column exist in your table
0
0
0
0
2015-05-06T14:36:00.000
1
0
false
30,079,853
0
0
1
1
I have migrated my OpenERP 7.0 DB from dev to production and now everytime I try to create a new customder, I get this error: View error Can't find field 'blocked' in the following view parts composing the view of object model 'res.partner': res.partner.followup.form.inherit Either you wrongly customized this view, or some modules bringing those views are not compatible* Any idea of why I see this error? I am a magento guy so have no clue whatsoever.
Deploying websites in django virtual machine
30,089,080
0
0
460
0
python,django,postgresql,deployment,web-deployment
From my point of view, database always should be created before deployment. And the information of the database must be posted to the settings.py for the application it self, I think virtualenv can be very helpful in these cases with requirements.txt You run the application in your virtual environment and then export your dependencies using pip freeze > requirements.txt Then in the new server you create the database, and insert the configuration in your settings, then install dependences pip install -r /path/to/requirements.txt Run migrations, and you are done.
0
0
0
0
2015-05-06T22:30:00.000
2
0
false
30,088,815
0
0
1
1
Sorry I'm new to this specific topic. I have a website implemented in django and AskBot it also has a DB (postgreSQL). I want to create a deployment package which can be distributed to any customer; such that this customer can have their own server. Taking into consideration that the deployment package should be platform independent; so it should work on all operating systems. Can you tell me what are the available tools to achieve this?
Summary or toc for autoflask Sphinx
30,135,026
2
3
539
0
python,flask,python-sphinx,tableofcontents
Turns out there is an html file which gets generated in the build folder called http-routingtable.html which does what I'm asking above. Given the purpose of sphinx (documentation) you would think this would be... documented... clearly. Hopefully others experiencing the problem run across this post in the future.
0
0
0
0
2015-05-07T08:10:00.000
2
1.2
true
30,095,337
0
0
1
1
We use Sphinx to document our Flask API. It does a pretty good job, but we are having a problem navigating the documentation it generates. We document each blueprint separately. Our blueprints are pretty big. Each is about 1000 lines long, and our docstrings are extremely detailed. The result is a Sphinx page which lists endpoints, but with so much intervening documentation between the endpoints that it is very difficult to understand the page. The normal thing to create here would be a table of contents at the top. I believe sphinx autosummary might also be called for here, though I don't know for sure as I have never used it. Unfortunately autosummary doesn't work, because it doesn't seem to be built to handle the same sort of input as autoflask(sphinxcontrib.autohttp.flask). Does anyone know a way to tell sphinx to create a table of contents which creates within-page links to all the members on the page which is compatible with autoflask?
Indicate a specific .mo file for Babel to load
30,123,126
0
2
116
0
python,flask,webapp2,python-babel
Solved by just using the flask app and the way I wanted to avoid - on every request, there is a callback to the app instance and to the localeselector decorator, language is set previously in an attribute in flask.g. Basically, by the books I guess.
0
0
0
0
2015-05-07T12:08:00.000
1
0
false
30,100,641
0
0
1
1
The setup of the problem is simple enough: an user selects a language preference (this preference can be read from the user’s session); based on this choice, load the appropriate .mo from the available translations; (no separate domains are set up, if it makes any difference) Problem: since this return has to be done outside the scope of the flask app, it cannot be instantiated and to use @babel.localeselector. Instead, I use a simple function based on webapp2 i18n’ extension which, using Babel’s support function, loads a given translation and returns a translation instance (Translations: "PROJECT VERSION"). (inb4 ‘why not use webapp2 already?’ too many libs already). From this point on, it is not clear to me what to do with this instance. How can I get Babel to use this specific instance? (at the moment, it always uses the default one, no 'best_match' involved).
Python/Django IDE for Solaris
30,108,350
1
0
535
0
python,django,ide,solaris
I'd suggest use www.pythonanywhere.com You can build and host your Django app there for free, it supports Python 2.7 and 3.4, most recent Django versions ( 1.4 to 1.8) and has virtualenv support so you can change whatever you like. It even comes preloaded with many useful libraries. It doesn't support text completion in the editor but I don't think that's a deal breaker considering how Python is as it is a lot more concise than most other languages. Having it on pythonanywhere lets you test it and debug it pretty fast. Also being a cloud solution it's 100% portable and you can develop it on any device that lets you access the internet.
0
0
0
0
2015-05-07T17:38:00.000
2
0.099668
false
30,108,107
0
0
1
1
Could anyone tell me a well-round Python & Django IDE fully compatible with Solaris?. I'm only aware of Netbeans but as far as I know It does not have support for Django and it lacks also of important features for Python like code completion. Thank you very much
Detecting incorrect nesting of XML tags in Python
30,114,393
1
0
79
0
python,xml,nested
Make an empty stack. Iterating through the list: if you find a start tag, push it onto the stack. if you find an end tag, compare it to the entry on top of the stack. if the stack is empty or the top doesn't match, fail. if it matches, pop the stack and continue. At the end of the iteration: if the stack is empty, declare success. otherwise fail.
0
0
1
0
2015-05-08T00:54:00.000
2
1.2
true
30,114,069
0
0
1
1
A question about testing proper nesting of XML tags: I got a list of tags, extracted from top to bottom from an xml file: Closing tags are clearly indicated by forward slash /to and /lastname tags are incorrectly nested. They should be switched. /lastname should be within to, /to parent tags. tag_list = ['note', 'to', 'firstname', '/firstname', 'lastname', '/to', '/lastname', '/note'] What would be the code or direction to spot that /lastname tag is outside of its parent which is to, /to pair? Cheers.
Scaling a decoupled realtime server alongside a standard webserver
30,188,812
1
2
559
0
python,websocket,real-time,scalability
If the scenario is a) The main web server raises a message upon an action (let's say a record is inserted) b ) He notifies the appropriate real-time server you could decouple these two steps by using an intermediate pub/sub architecture that forwards the messages to the indended recipient. An implementation would be 1) You have a redis pub-sub channel where upon a client connecting to a real-time socket, you start listening in that channel 2) When the main app wants to notify a user via the real-time server, it pushes to the channel a message, the real-time server get's it and forwards it to the intended user. This way, you decouple the realtime notification from the main app and you don't have to keep track of where the user is.
0
0
1
0
2015-05-08T01:26:00.000
4
1.2
true
30,114,325
0
0
1
2
Say I have a typical web server that serves standard HTML pages to clients, and a websocket server running alongside it used for realtime updates (chat, notifications, etc.). My general workflow is when something occurs on the main server that triggers the need for a realtime message, the main server sends that message to the realtime server (via a message queue) and the realtime server distributes it to any related connection. My concern is, if I want to scale things up a bit, and add another realtime server, it seems my only options are: Have the main server keep track of which realtime server the client is connected to. When that client receives a notification/chat message, the main server forwards that message along to only the realtime server the client is connected to. The downside here is code complexity, as the main server has to do some extra book keeping. Or instead have the main server simply pass that message along to every realtime server; only the server the client is connected to would actually do anything with it. This would result in a number of wasted messages being passed around. Am I missing another option here? I'm just trying to make sure I don't go too far down one of these paths and realize I'm doing things totally wrong.
Scaling a decoupled realtime server alongside a standard webserver
30,170,295
0
2
559
0
python,websocket,real-time,scalability
Changed the answer because a reply indicated that the "main" and "realtime" servers are alraady load-balanced clusters and not individual hosts. The central scalability question seems to be: My general workflow is when something occurs on the main server that triggers the need for a realtime message, the main server sends that message to the realtime server (via a message queue) and the realtime server distributes it to any related connection. Emphasis on the word "related". Assume you have 10 "main" servers and 50 "realtime" servers, and an event occurs on main server #5: which of the websockets would be considered related to this event? Worst case is that any event on any "main" server would need to propagate to all websockets. That's a O(N^2) complexity, which counts as a severe scalability impairment. This O(N^2) complexity can only be prevented if you can group the related connections in groups that don't grow with the cluster size or total nr. of connections. Grouping requires state memory to store to which group(s) does a connection belong. Remember that there's 3 ways to store state: global memory (memcached / redis / DB, ...) sticky routing (load balancer configuration) client memory (cookies, browser local storage, link/redirect URLs) Where option 3 counts as the most scalable one because it omits a central state storage. For passing the messages from "main" to the "realtime" servers, that traffic should by definition be much smaller than the traffic towards the clients. There's also efficient frameworks to push pub/sub traffic.
0
0
1
0
2015-05-08T01:26:00.000
4
0
false
30,114,325
0
0
1
2
Say I have a typical web server that serves standard HTML pages to clients, and a websocket server running alongside it used for realtime updates (chat, notifications, etc.). My general workflow is when something occurs on the main server that triggers the need for a realtime message, the main server sends that message to the realtime server (via a message queue) and the realtime server distributes it to any related connection. My concern is, if I want to scale things up a bit, and add another realtime server, it seems my only options are: Have the main server keep track of which realtime server the client is connected to. When that client receives a notification/chat message, the main server forwards that message along to only the realtime server the client is connected to. The downside here is code complexity, as the main server has to do some extra book keeping. Or instead have the main server simply pass that message along to every realtime server; only the server the client is connected to would actually do anything with it. This would result in a number of wasted messages being passed around. Am I missing another option here? I'm just trying to make sure I don't go too far down one of these paths and realize I'm doing things totally wrong.
Flask-Admin vs Flask-AppBuilder
30,292,629
32
13
8,504
0
python,flask,flask-admin
I am the developer of Flask-AppBuilder, so maybe a strong bias here. I will try to give you my most honest view. I do not know Flask-Admin that much, so i will probably make some mistakes. Flask-Admin and Flask-AppBuilder: Will both give you an admin interface for Flask with bootstrap. Will both make their best to get out of your way. Will both help you develop Flask more Object Oriented style. Will both let you override almost everything on the admin templates. Will both support Babel. Both inspired on Django-Admin. Pros for Flask-AppBuilder: Has a nicer look and feel (bias? maybe...). Security has been taken care of for you, and supports out of the box, database, LDAP, OpenID, Web server integrated (REMOTE_USER), and in the near future OAuth too. Will let you extend the user model and security views. Granular permissions, creates one permission for each web exposed method and action (you have to try it). You can easily render Google graphs. Smaller project, it's easier to request new features, and get your pull requests merged. MasterDetail views and multiple views can be setup easily. Backends: supports SQLAlchemy, MongoEngine, GenericInterface (you can integrate with your own builtin data still a bit beta). Pros for Flask-Admin: You have to assemble your own security (models, views, auth etc), it's ready though to integrate nicely with flask-security. This can be a pro or a con depending on what you want. Builtin File Admin. Bigger project with bigger community. Backends: supports SQLAlchemy, GeoAlchemy, MongoEngine, Pewee and PyMongo. Better support for MongoEngine (EmbeddedDocument, ListFields etc..). On the overall i think Flask-Admin makes no assumptions at all like Flask, you have to code more, but this will let you be more free. Flask-AppBuilder makes some assumptions (on security), you will have to code much less, but some things can get on your way if your building very specific security models. Hope this helps you and others, i tried my best to keep the bias out.
0
0
0
0
2015-05-08T14:44:00.000
2
1.2
true
30,126,607
0
0
1
1
I am new to Flask and have noticed that there are two plugins that enable CRUD views and authorized login, Flask-Admin and Flask-AppBuilder. These two features interest me along with nice Master-Detail views for my model, where I can see both the rows of the master table and the relevant details on the same screen. Any idea which one to prefer? I see that Flask-AppBuilder has far more commits in Github, while Flask-Admin many more stars. How to tell the difference, without spending too much time with the wrong choice?
Unable to import python module 'web'?
53,768,539
0
1
83
0
python,python-2.7,module,web.py
Sometimes the problem is in the PYTHONPATH, and the IDE modify the environment variables so when you run it from there you don't have a problem.
0
0
1
0
2015-05-10T18:54:00.000
1
0
false
30,155,400
1
0
1
1
I am trying to import the web module of python to create a simple Hello World program on my browser using web.py. When I run it from the command line I am getting errors about the web.py package. If I run it from IDLE, it works fine.
I don't need django tables by default
30,164,129
3
2
1,066
0
python,django,django-models
Just don't include (or comment out) the middleware or apps that you don't need. While the MIDDLEWARE_CLASSES setting is required to be present...it doesn't need to contain the authentication middleware. In other words, keep MIDDLEWARE_CLASSES and INSTALLED_APPS in your settings.py, but remove the middleware classes and apps that you don't need.
0
0
0
0
2015-05-11T09:29:00.000
3
0.197375
false
30,164,030
0
0
1
1
Here is my question, I have to do a new django project but I don't need the database tables that django offers by default, auth_user, table... etc. Is there any way for start a project synchronizing the database but without all this stuff? I have tried to comment the INSTALLED_APPS by default and MIDDLEWARE_CLASSES but it retrieves me errors or issues.
Apache2 doesn't work after installing mod-wsgi
30,165,117
1
0
256
0
python,django,apache2,debian,mod-wsgi
>>> a2dismod python did the trick. Mod-wsgi 4.0+ doesn't work with mod-python.
0
0
0
1
2015-05-11T09:52:00.000
1
1.2
true
30,164,528
0
0
1
1
I have installed libapache2-mod-wsgi on a Debian 8 64 bit server. Whenever I loaded the domain before this install, the default page for apache2 loaded. But after the install it shows The webpage is not available error, the same error occurs when there is no internet connection on my PC. I have tried a2dismod wsgi to disable it. And then it works again. Can anyone suggest me a workaround?
In Django, is it better to add admin features to the command line or the admin interface?
30,180,570
0
1
48
0
python,django,django-admin,email
I sugest You to stick to the web interface if it will be used by a human. CLI is good when You want to control Your application by another app or some sort of script. Many people could have a problem using CLI. Remember that potential client will almost always be 'less technical' person than You, so the UI should be user friendly for him.
0
0
0
0
2015-05-12T01:52:00.000
1
0
false
30,180,448
0
0
1
1
In my specific case, I'm building a relatively straightforward email-sending webapp. I'll need to add the ability for a human to generate email templates from the last day's worth of updated objects, view the day's last sent emails, etc. Django provides the Django manage.py CLI, and also the Django Admin Web UI. Both are augmentable. Are there any best-practices or rules of thumb to follow in terms of adding my email admin functionality to one or the other? Edit: To be more clear, my big concern is around speed of implementation operations on models and such.
Returning cursor isn't retrieving data from DB
30,181,819
0
0
24
1
python-2.7,postgresql-9.3
If you close the connection, you cannot iterate a cursor anymore. There is no connection to the database.
0
0
0
0
2015-05-12T03:52:00.000
1
0
false
30,181,471
0
0
1
1
cursor.execute(sql_statement) conn.close() return cursor the above are the closing lines of my program. I've 3 html pages (users, workflows, home), returning curosor is triggering data for workflows and home page, but not for users page Where as, if i do return cursor.fetchall(), then it's working for all 3 pages. The reason why i want to return cursor is, the client might want to iterate or do other processing on the cursor. I'm not sure what am doing different with Users page.
how to upload the existing app in to web2py environment
30,356,551
0
2
724
0
python,web2py
Just use the file system. GUI: Copy your application folder to your new instance of web2py (/web2py/applications). Command line: scp -r /home/username/oldarea/web2py/application/myApp /home/username/newarea/web2py/applications
0
1
0
0
2015-05-13T07:31:00.000
1
0
false
30,208,421
0
0
1
1
I am new to web2py I have web2py application in my local system i want to upload this application into web2py environment throught admin interface option present in web2py Upload & install packed application and do some modifications and run the application but i am unable to uploded the app please give the suggesations how to do this Thanks in advance
Send a XML file with authorization to a django app
30,215,688
0
0
238
0
python,xml,django,curl
request.body should contain the XML as string. I tried using curl, but the data I get on the Django side becomes a dictionary Can you please share the code blocks to receive/print the data?
0
0
1
0
2015-05-13T13:00:00.000
1
1.2
true
30,215,568
0
0
1
1
How can I send an xml file to a Django app server from a command line interface? I tried using curl, but the data I get on the Django side becomes a dictionary and doesn't look like xml. In addition to that I need some basic authorization mechanism. I tried curl examples, but to no avail. Maybe I am expecting the wrong thing. Can someone guide me to the right tutorial or examples.
Server architecture depending on the capacity
30,222,997
0
0
117
0
python,websocket,server,capacity
One of solutions could be Pyramid, sockjs, gunicorn, and gevent. Nginx probably better suits to be a frontend than Apache, but of course if you do not have any lengthy processing on the backend, any decent asynchronous Python server with websocket and sockjs support (not sure about socket.io as an alternative) will work for you out of the box. Lenghty processing should be offloaded to some queue workers anyway, so asynchronous server will fit the bill. Just check whether all used datastore/database adapters are compatible with your server solution be it asynchronous or multi-threading.
0
0
1
0
2015-05-13T17:39:00.000
2
0
false
30,221,772
0
0
1
1
I am new at Server side, but I have gotten a chance to design and implement a server that will cover around 2000~3000 client. And I am thinking that I will use Python and Websocket, though I don't know this choice is appropriate. In this point, I am curious on how to design the server. I think there must be some architecture normally in use depending on capacity that server handles. Otherwise, Could I use a Websocket server offered by some python package like Tornado or Django? I hope that I can get any information on this. Any advice?
Django createsuperuser cannot enter password
71,642,770
0
1
3,933
0
python,django,superuser
The password is usually hidden in your IDE so it is not showing up when you're typing it out. Just type the password press enter and re-enter the same thing. Hope this solves the problem.
0
0
0
0
2015-05-15T01:19:00.000
3
0
false
30,250,032
0
0
1
2
I am learning django, and I have a mysite folder. When I synced the database it prompted me to create a superuser. I typed yes, and got halfway through the forms but I couldn't enter any characters when it wanted a password. I searched google and found: python manage.py createsuperuser The same thing happened, I could not enter a password. I am using django 1.5 and python 2.7 in case you need to know.
Django createsuperuser cannot enter password
70,849,579
-1
1
3,933
0
python,django,superuser
Operations to perform: Apply all migrations: admin, admin_interface, auth, contenttypes, myapp, sessions Running migrations: Applying myapp.0002_alter_student_id...
0
0
0
0
2015-05-15T01:19:00.000
3
-0.066568
false
30,250,032
0
0
1
2
I am learning django, and I have a mysite folder. When I synced the database it prompted me to create a superuser. I typed yes, and got halfway through the forms but I couldn't enter any characters when it wanted a password. I searched google and found: python manage.py createsuperuser The same thing happened, I could not enter a password. I am using django 1.5 and python 2.7 in case you need to know.
pisa.CreatePDF hangs with huge html file
30,345,810
1
2
1,230
0
python,django,pdf,pisa
I did few changes in html which results pisa.createPDF works fast for me. I am using html of almost 2 MB, contains single table with almost more than 10,000 rows. So I break them into multiple tables and tried again. Its surprised me, initially with single table it took almost 40 minutes (2590 seconds) to generate PDF and with multiple tables it has taken only 80 Seconds.
0
0
0
0
2015-05-15T06:14:00.000
2
0.099668
false
30,252,726
0
0
1
1
I am generating pdf using html template with python pisa.CreatePDF API, It works well with small html, but in case of huge html it takes lot of time. Is there any alternative ?
Run multiple Celery chains at the same time
30,300,802
1
0
678
0
python,django,celery
If you want to run chains at once you will need to run more than one worker.
0
1
0
0
2015-05-15T19:21:00.000
1
1.2
true
30,267,236
0
0
1
1
I have Celery tasks chain that I call with apply_async. Each task in chain depends on the result from previous task. Basically the worklof looks like this: Fetch data from DB. For each fetched row run chain with tasks. Behaviour that I want to achieve is to run multiple chains at one time. But it seems like it runs them in a row, not simultaneously. How to fix this issue?
Distributed Task Queue Based on Sets as a Data Structure instead of Lists
30,282,486
1
8
656
0
python,redis,rabbitmq,celery,message-queue
Can your tasks in stage 2 check whether the work has already been done and, if it has, then not do the work again? That way, even though your task list will grow, the amount of work you need to do won't. I haven't come across a solution re the sets / lists, and I'd think there were lots of other ways of getting around this issue.
0
1
0
0
2015-05-16T16:26:00.000
3
0.066568
false
30,278,054
0
0
1
1
I'm wondering if there's a way to set up RabbitMQ or Redis to work with Celery so that when I send a task to the queue, it doesn't go into a list of tasks, but rather into a Set of tasks keyed based on the payload of my task, in order to avoid duplicates. Here's my setup for more context: Python + Celery. I've tried RabbitMQ as a backend, now I'm using Redis as a backend because I don't need the 100% reliability, easier to use, small memory footprint, etc. I have roughly 1000 ids that need work done repeatedly. Stage 1 of my data pipeline is triggered by a scheduler and it outputs tasks for stage 2. The tasks contain just the id for which work needs to be done and the actual data is stored in the database. I can run any combination or sequence of stage 1 and stage 2 tasks without harm. If stage 2 doesn't have enough processing power to deal with the volume of tasks output by stage 1, my task queue grows and grows. This wouldn't have to be the case if the task queue used sets as the underlying data structure instead of lists. Is there an off-the-shelf solution for switching from lists to sets as distributed task queues? Is Celery capable of this? I recently saw that Redis has just released an alpha version of a queue system, so that's not ready for production use just yet. Should I architect my pipeline differently?
Is there a way to run a Google App engine cron task without hitting an endpoint but rather pointing cron.yaml at a python script?
30,280,609
2
0
622
0
python,google-app-engine,google-cloud-storage
A cron job in GAE has to hit a URL, there's no other way to do it. That's just how the system is designed. But since you have control over app.yaml anyway, you can easily assign your script to a URL there.
0
1
0
1
2015-05-16T20:32:00.000
2
0.197375
false
30,280,460
0
0
1
1
my end goal is to update Google cloud storage with some json data and I would rather it run a script rather than hitting a url endpoint. What would be the proper configuration of cron.yaml if, let's say the script were to sit right next to app.yaml?
Equivalent of javadoc's tags in pydoc
30,287,331
1
0
1,176
0
python,pydoc
I ended up just switching to epydoc, which is much more featureful than pydoc. Sphinx is another alternative.
0
0
0
0
2015-05-17T12:43:00.000
2
1.2
true
30,286,986
0
0
1
1
In javadoc, you can have tags like @author, @return, @deprecated which are handled specially when making java documentation. Is there an equivalent functionality in pydoc or am I limited to just a verbatim copy of the method's docstring?
Where to save messages in Django app?
30,289,765
0
0
435
0
python,django,django-messages
It depends. You could save your messages in the database if you need the classical approach to messages. This would best work for messages sent in e-mail or bulletin board "style". If however you need real-time behavior and lots of messages, having a database inbetween might slow things down a bit. You could use node.js for a real-time chat. If you are intending to use Django-Messages as a means to communicate between users, it wasn't meant for this. It is simply used for displaying flash notifications for users when they navigate through pages in your app. They are normally stored in the session and used only for the following page, afterwards being deleted. I cannot give more details because your question is quite vague. Firstly you need to find which are your plans, how do you intend to use the "chatting between users".
0
0
0
0
2015-05-17T16:45:00.000
1
1.2
true
30,289,423
0
0
1
1
I want to make my own on Django-app. The app must have an messages-application not only for notification but for chatting between users. So, for example I've write a model for messages, so where I have to save the messages? In the database, or maybe it is not a good style of coding and bad for work speed?
Weasyprint HTML to PDF huge gap in right margin
30,314,963
0
0
1,861
0
python,css,django,pdf,weasyprint
Found the solution. It was a CSS problem. The class used to style the body was not at the beginning of the css file and that caused erratic behavior with other styles declared before it.
0
0
0
0
2015-05-17T22:03:00.000
1
1.2
true
30,292,625
0
0
1
1
I'm using Weasyprint to print an HTML template to PDF, and I keep getting a gap of 10cm on the right side. I'm using @page:(size:letter;) as only page attribute. I've tried setting the page size manually, but I still keep getting a huge space to the right of all the pages. Any thoughts on what could be the problem?
how to give some unique id to each anonymous user in django
30,298,038
7
8
4,523
1
python,django,authentication
I think you should use cookies. When a user that is not authenticated makes a request, look for a cookie named whatever ("nonuserid" in this case). If the cookie is not present it means it's a new user so you should set the cookie with a random id. If it's present you can use the id in it to identificate the anonymous user.
0
0
0
0
2015-05-18T07:52:00.000
2
1.2
true
30,297,785
0
0
1
1
I want to create a table(postgres) that stores data about what items were viewed by what user. authenticated users are no problem but how can I tell one anonymous user from another anonymous user? This is needed for analysis purposes. maybe store their IP address as unique ID? How can I do this?
Find out Python version from source code (or Heroku)
30,321,377
0
1
1,237
0
python,django,heroku,version
If you didn't have access to source code, from headers I can see that server is using Gunicorn 0.17.2, which is compatible with Python 2.x >= 2.6, which rules out i.e. Python 3.
0
0
0
0
2015-05-19T08:20:00.000
4
0
false
30,320,265
1
0
1
1
We run a site called inteokej.nu and I need to find out which version of Python it runs on. I have pulled all the files to my computer but I don't know if and how I can find out the version number from them? The site is hosted on Heroku and maybe there's a way to find out the version with some kind of Heroku command? As for now I don't have any possibilities to change any code (e.g. add a code snippet to get the version). Thanks in advance!
Django - Cannot find Directory 'mysite'
30,326,360
0
0
1,391
0
python,django,windows-7-x64
To Summarize the comments: This is because you're in c:\Windows\system32. By default when you open command prompt is in that system32 directory. you need to change it first. To change directory use cd <what path you want>. Once you're in the correct directory, you can start the project with django-admin startproject command. For example: cd c:\ to change directory to your root directory. then type C:\Python34\Scripts\django-admin startproject mysite. It will then create the directory under C:\mysite Last but not least, you can also put C:\Python34\Scripts in your system environment variable PATH, so that you don't have to type the full address of django-admin. Instead you can then use the django-admin startproject mysite.
0
0
0
0
2015-05-19T11:47:00.000
1
1.2
true
30,324,761
0
0
1
1
I am currently learning how to use Python/Django. I have successfully installed and setup Django. I am experiencing problems creating a project using the django-admin startproject mysite command. I have executed the command from command prompt using the path: C:\Python34\Scripts\django-admin startproject mysite I tried searching for it in the current directory but could not find the folder. I tried executing the command again and found out that the directory exists in: 'C:\Windows\system32\mysite' I tried searching for it in this directory, but could not find it. How can I make this directory visible and set it under the Python directory? Here is the exact error I am getting in Command Prompt: CommandError: 'C:\Windows\system32\mysite' already exists I am currently running Windows 7 - 64 Bit
GoogleScraper keeps searches in database
30,433,834
0
0
192
1
python,bash,web-scraping
I solved the issue which keeps searches in GoogleScraper database,we first have to run following command GoogleScraper --clean This command cleans all cache and we can search again with new results. Regards!
0
0
1
0
2015-05-20T10:54:00.000
1
1.2
true
30,347,571
0
0
1
1
I am using GoogleScraper for some automated searches in python. GoogleScraper keeps search results for search queries in its database named google_scraper.db.e.g. if i have searched site:*.us engineering books and due to internet issue while making json file by GoogleScraper.If the result is missed and json file is not like that what it must be then when i again search that command using GoogleScraper it gives same result while internet is working fine,i mean to say GoogleScraper maintains its database for a query which it has searched and does not search again it, when i search that command whose result is stored in database,it does not give new result but give results from database stored previously
Breakpoints not working for Django Project with python environment 2.7 in Visual Studio with PTVS
30,482,731
0
0
627
0
python,django,python-2.7,debugging,ptvs
Managed to fix the error myself. What I had done was create a project "From Existing Python code". Instead I created a new Django Web Project in Visual Studio and then deleted all files that Visual Studio automatically added. Then I included my old Django-files in the project and the breakpoints started working. Don't forget to set Django Settings Module location (settings.py) by right clicking the project, select the Django tab and edit the row "Settings Module".
0
0
0
0
2015-05-21T07:26:00.000
1
1.2
true
30,367,194
0
0
1
1
I get the following errors when I try to set a breakpoint for html files in a Django project: "A breakpoint could not be inserted at this location" "This is not a valid location for a breakpoint" In .py files I can set breakpoints but they will not get hit. If I make a new Djnago project the breakpoints can be set in both html and .py files and they do get hit and therefore I do not think there is anything wrong with my Visual Stuido installation. I have tried removing the projects .suo file but it does not make any difference and I have tried setting breakpoints with both the mouse pointer and F9 key. I'm using Visual Studio 2013 with update 4 and PTVS 2.1 (Python Tools for visual studio).
Python / Django | How to store sent emails?
30,369,384
2
3
559
0
python,django
Another way to look at it: send the mail to your backup email account ex: [email protected]. So you can store the email, check if the email is sent or not. Other than that, having an extra model for logged emails is a way to go.
0
0
0
1
2015-05-21T08:22:00.000
3
0.132549
false
30,368,271
0
0
1
2
I was wondering how can I store sent emails I have a send_email() function in a pre_save() and now I want to store the emails that have been sent so that I can check when an email was sent and if it was sent at all.