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
Create_user() in custom manager or save() method in Django custom user model for processing field before creating new record?
20,015,389
2
1
878
0
python,django,django-models,django-users,django-managers
The point of save() and create_user() method is to save the object to the database. The difference is that the save() method need you to instantiate the object first, while create_user() automatically create the object and save into the database. There is no the absolute right way. You can use both of the as you want. Both method results are the same, add object to database.
0
0
0
0
2013-11-15T00:04:00.000
1
0.379949
false
19,990,997
0
0
1
1
I have a Django custom user model with a save() method that tests for self.pk is None and does some extra processing to a field before creating a new user record. Is this the right place to put that or is it supposed to go into the create_user() method of the custom user manager? Does it make a difference?
Python Web Server - mod_wsgi
19,992,498
1
0
203
0
python,apache2,mod-wsgi
Python is different from PHP in that PHP executes your entire program separately for each hit to your website, whereas Python runs "worker processes" that stay resident in memory. You need some sort of web framework to do this work for you (you could write your own, but using someone else's framework makes it much easier). Flask is an example of a light one; Django is an example of a very heavy one. Pick one and follow that framework's instructions, or look for tutorials for that framework. Since the frameworks differ, most practical documentation on handling web services with Python are focused around a framework instead of just around the language itself. Nearly any python web framework will have a development server that you can run locally, so you don't need to worry about deploying yet. When you are ready to deploy, Apache will work, although it's usually easier and better to use Gunicorn or another python-specific webserver, and then if you need more webserver functionality, set up nginx or Apache as a reverse proxy. Apache is a very heavy application to use for nothing but wsgi functionality. You also have the option of deploying to a PaaS service like Heroku (free for development work, costs money for production applications) which will handle a lot of sysadmin work for you. As an aside, if you're not using virtualenv to set up your Python environment, you should look into it. It will make it much easier to keep track of what you have installed, to install new packages, and to isolate an environment so you can work on multiple projects on the same computer.
0
0
0
1
2013-11-15T02:13:00.000
1
1.2
true
19,992,294
0
0
1
1
I have been looking at setting up a web server to use Python and I have installed Apache 2.2.22 on Debian 7 Wheezy with mod_wsgi. I have gotten the initial page up and going and the Apache will display the contents of the wsgi file that I have in my directory. However, I have been researching on how to deploy a Python application and I have to admin, I find some of it a little confusing. I am coming from a background in PHP where it is literally install what you need and you are up and running and PHP is processing the way it should be. Is this the same with Python? I can't seem to get anything to process outside of the wsgi file that I have setup. I can't import anything from other files without the server throwing a "500" error. I have looked on Google and Bing to try to find an answer to this, but I can't seem to find anything, or don't know that what I have been looking at is the answer. I really appreciate any help that you guys can offer. Thanks in advance! (If I need to post any coding, I can do that, I just don't know what you guys would need, if anything, as far as coding examples for this...)
HTML in Spotfire and IronPython
62,234,196
0
0
3,779
0
html,ironpython,spotfire
What you can do is add a new text area. Then, add a drop down list in this text area. You can create a new Document.Properties linked to this drop down list. You can create many options in your drop down list, and your Document.Properties will have the selected value of your drop down list. Text Area could be designed in HTML/CC so you can customize as you want. Once you have your Document.Properties with the drop down list value, you can go on your chart properties and add a custom expression with your Document.Properties like [MyCol]==$(docproperties) I hope it will help you !
0
0
0
0
2013-11-15T04:03:00.000
3
0
false
19,993,323
0
0
1
1
I want to make a drop down list in spotfire using html. So based on choice selected I want to show custom divs. How to implement that ?? Can anyone help with the ironpython script
Django REST Framework, pre_save() and serializer.is_valid(), how do they work?
22,542,900
2
11
9,143
0
python,django,rest,django-rest-framework
It turned out the problem was that I was using ListAPIView as the base class for my view class and it doesn't have the pre_save method defined. When I added some of the mixins which had it defined everything started working. Seems weird that something used in a lot of the basic tutorials doesn't support such a basic feature, but live and learn.
0
0
0
0
2013-11-15T05:08:00.000
5
1.2
true
19,993,951
0
0
1
1
I need to attach a user to a request, this seems like a fairly common thing to need to do, but it's turning out to be damn near impossible. The docs for the Django REST Framework suggest using the pre_save method of the serializer class, which I did, but it doesn't get called when serializer.is_valid() is called, which makes it kind of worthless since without the user field the serializer fails validation. I've seen a few suggestions but they seem like crazy hacks and/or don't work. Plus, I feel like this is way too common of a task to really need all the stuff I see people suggesting. I can't be the only person to need to attach a user to a object created in a REST request.
Can one source code be deployed to Openshift, Heroku and Google App Engine at once?
20,003,022
3
1
244
0
python,google-app-engine,heroku,openshift
I work on Openshift and at this time I'm not aware of anything that will deploy your code to GAE and Openshift at the same time. You might be able to write your own script for it.
0
1
0
0
2013-11-15T10:31:00.000
2
1.2
true
19,998,958
0
0
1
2
As subject, is is possible with just one source code, we can deploy our code to Openshift or Google App Engine? Heroku is not necessarily in my case. My application is using Python Flask + PostgreSQL 9.1. I love the easiness in Openshift when I configure my technology stack, but is the case will be same with GAE? Thanks!
Can one source code be deployed to Openshift, Heroku and Google App Engine at once?
20,003,075
1
1
244
0
python,google-app-engine,heroku,openshift
PostgreSQL is not available on GAE, so this code will definitely not run there.
0
1
0
0
2013-11-15T10:31:00.000
2
0.099668
false
19,998,958
0
0
1
2
As subject, is is possible with just one source code, we can deploy our code to Openshift or Google App Engine? Heroku is not necessarily in my case. My application is using Python Flask + PostgreSQL 9.1. I love the easiness in Openshift when I configure my technology stack, but is the case will be same with GAE? Thanks!
How to print django-nose exception below log
20,023,533
3
0
401
0
python,django,nose
Nose keeps track of standard output (stdout) and logging (python logging module) in separate containers. You can control the capturing process of the output during the test run for both buffers. So if you want to disable capturing of the recorded log with --nocapture and --nologcapture your tests will end with stack trace. This way step (3) will be eliminated. To reorder sequence as you describe it, you may want to make a custom plugin.
0
0
0
0
2013-11-15T11:40:00.000
1
1.2
true
20,000,286
0
0
1
1
Django-nose prints the exception and stack trace somewhere hidden in the middle of two logs in the following format: Live Log (as it is being executed) The exception and stack trace The recorded log This is really unhelpful if the logs are very long (hundreds of lines) as one has to find the "in between" stack trace to know what actually went wrong, rather than just scrolling to the bottom and being able to see the error. Is there any way of formatting this differently so that the stack trace and exception are printed last (aka 1. Live log, 2. recorded log, 3. exception and stack trace)?! From what I can tell there are no options to do so.
Django, Detecting if variable is a number
20,003,855
7
7
8,638
0
python,django,string,integer
What about: if isinstance(data, int):
0
0
0
0
2013-11-15T14:26:00.000
3
1
false
20,003,295
1
0
1
1
In a function in Django, the user can send me a number or a string, and I want to know if I received a number or a String (Tip: The number will always be an integer between 1-6) I want to know if it's possible to detect this and how (with an example), as the number or string I'm getting will tell me what to do next.
Finding the cause of of 403 forbidden error in django admin
36,814,048
1
2
6,383
0
python,django
If you're using Firefox (or any browser) with Web Developer Toolbar, make sure you have cookies enabled. I temporarily had cookies turned off and forgot to turn it back on. Cookies => Disable Cookies => Disable All Cookies Solved my problem in Django 1.9.
0
0
0
0
2013-11-15T20:36:00.000
2
0.099668
false
20,010,125
0
0
1
1
I have multiple users in django auth setup and a few simple models. For superusers I can view my model objects. For non superusers that have is_staff checked I get a 403 Permission denied when trying to view my models. I have tried adding all permissions to those users to find out if that was the cause but still receive the forbidden message. Other than making them superusers I can't assign any more permissions. On the command line where I'm running the development server I see messages like "GET /admin/bcp/buildingsensor/24/ HTTP/1.1" 403 190614 Does anyone know how to get a more useful traceback for this so I know where to start looking. ? Thanks
uWSGI with Django gives Broken pipe
20,015,756
0
0
338
0
python,django,pipe,uwsgi
check the timeout of your frontend server, generally if there is no activity, the connection is closed. For example nginx has 60 seconds timeout
0
0
0
0
2013-11-16T06:53:00.000
1
0
false
20,015,701
0
0
1
1
I am using uWsgi + Django to write web services for an android application to submit survey data which is normally not very large set of data but, the application sends multiple calls to the server. If the surveyor has done 50 surveys, he'll tap one button on his mobile and all the surveys will be sent to the server one by one in one go. Sometimes I get the BROKEN PIPE error. Data is saved on the server but response is not sent back to the mobile due to which those surveys are not removed from the mobile and next time all those surveys are again sent to the surveys along with the new ones and it is causing a lot of duplication. PLEASE HELP....
Difference between Socket Programming and Django Form submission
20,038,319
1
1
684
0
python,django,sockets,django-forms
Sockets are just one method of communicating between client and server, but not the method Django is using when processing a form submission. It is most likely sending a HTTP POST request with parameters that the server listens for.
0
0
0
0
2013-11-18T00:48:00.000
3
0.066568
false
20,038,238
0
0
1
1
i am learning socket programming and Django web developing. As what i know socket is used for the communication between client and server. Dose this mean that when using and submitting Form in Django, there will be a socket created and submitted to the server?
Remote control of an embedded system from Website
20,039,992
0
0
469
0
python,django,sockets,web,remote-server
You basically have one major thing to decide: Is your embedded machine going to open up a port that allows any thing that knows it's IP and port details to control it and your web page write to that IP/Port OR Is your embedded device going to poll the web app to find out which state it should be in. The first option will normally respond faster but your embedded machine will be more vulnerable to outside interference, you will need to be able to run active code on your web server, which a lot of servers do not allow, etc. The second will only respond to state changes at an average of half the polling rate but will probably be simpler to program and manage. Plus your server is not also acting as a client.
0
0
1
0
2013-11-18T03:36:00.000
1
1.2
true
20,039,657
0
0
1
1
I am now using Django frame work to build a website which has the ability to control a remote embedded system (simply with functions like "Turn ON/OFF"). What i can image now is to use Socket Programming with Python (because Django is pure Python). As i have learnt, i only know how to send and receive messages with sockets between the client machine and server. Can any one tell me 1. What else is needed to learn for this remote control function? 2. Or is there any better ways (better frameworks) to implement this? 3. Dose Django have built in methods for Socket Programming? (If not, is it possible to implement it with self-defined app)?
@auth.requires_permission not working
20,102,474
0
0
174
0
python,web2py
When entering a record in the db.auth_permission table, there is a table field in addition to the name field (note, table doesn't have to refer to a database table -- it can be any name representing any type of object). When a permission is checked, both the name and the table must match. If you insert a permission record via the appadmin interface or using auth.add_permission(1, 'search'), then the table field will be set to an empty string (i.e., ''). This will work, because when you do @auth.requires_permission('search'), that is equivalent to @auth.requires_permission('search', ''), which matches the empty string in the permission record. However, if you insert via db.auth_permission.insert(group_id=1, name='search'), then the table field will be set to None, which will not match the empty string when you check the permission.
0
0
0
0
2013-11-18T07:33:00.000
1
1.2
true
20,042,386
0
0
1
1
I have an application where I am using web2py's access control system. I have various users in auth_user table. To be more specific I have [email protected] user whose id is 4. There is a group admin with group id 1 in auth_group table. In auth_membership table I have user_id 4 related to group_id 1. It means that [email protected] is a member of admin group. Finally in auth_permission table I have a record which relates group_id 1 with permission named search. It means that admin group has search permission. I have a controller in which I have index method with decorator as @auth.requires_permission('search'). I am logging in with [email protected] and getting to this controller method. But this condition evaluates to false and control doesn't go inside method. However if I replace this decorator with one @auth.requires_login() it works. But I want only users with search permission to get access to this method. Please help me to achieve this.
Nginx(Django) ImportError: cannot import name celeryd
20,312,840
1
0
700
0
python,django,nginx,celery,celerybeat
It turned out I used different version of Django in my remote server. In Celery 3.1, there is no command named celeryd.
0
1
0
0
2013-11-18T19:45:00.000
1
1.2
true
20,056,399
0
0
1
1
I tested my project in my local machine, and it worked fine. But after uploading to a remote server(CentOS), I cannot execute celerybeat. Here is my command. python manage.py celeryd --events --loglevel=INFO -c 5 --settings=[settings-directory].production This command works in the local machine(with --settings=[settings-directory].local), but in the remote server, ImportError: cannot import name celeryd occured. Setting about celery is in base.py. local.py and production.py import the file. In production.py, there are just DEBUG, static, database settings. I can import djcelery and celery in shell of the remote machine. How could I solve this? -- I think this is a version problem.. I'm reading about celery3.1
Google App Engine. How to create constant in application scope?
20,065,052
2
1
154
0
python,google-app-engine
You can define the dict with in a module, then import it where ever you wish to refer to it, or you could load it from the datastore, and set the value in the module. You would do this during a warmup request. Defining it in a module, means to alter the contents will require de-deploying the app. Defining it in the datastore, means instances will reload any new definition on startup. You could also set up a handler which could trigger a refresh if reading from the datastore. Defining directly in the datastore means its pickled state needs to be less than 1MB (compressed) if you use a BlobProperty with compressed=True and your using ndb. Other variations similiar to module definition would be to load it from a yaml file etc.. You could define the dict in the app.yaml as an environment variable. There are many options, without knowing the specifics of your use cases it's hard to recommend a particular strategy.
0
1
0
0
2013-11-19T06:43:00.000
1
0.379949
false
20,064,915
1
0
1
1
I want to create global scope constant dict, that would be accessed by multiple views. For now I see scenario after deploy: Fetching big file, creating a dict, holding this dict in memory. This process can be re-executed by administrator.
Best way to show a user random data from an SQL database?
20,081,554
1
1
512
1
python,sql,flask,flask-sqlalchemy
The easiest way is to do the random number generation in javascript at the client end... Tell the client what the highest number row is, then the client page keeps track of which ids it has requested (just a simple js array). Then when the "request next random page" button is clicked, it generates a new random number less than the highest valid row id, and providing that the number isn't in its list of previously viewed items, it will send a request for that item. This way, you (on the server) only have to have 2 database accessing views: main page (which gives the js, and the highest valid row id) display an item (by id) You don't have any complex session tracking, and the user's browser is only having to keep track of a simple list of numbers, which even if they personally view several thousand different items is still only going to be a meg or two of memory. For performance reasons, you can even pre-fetch the next item as soon as the current item loads, so that it displays instantly and loads the next one in the background while they're looking at it. (jQuery .load() is your friend :-) ) If you expect a large number of items to be removed from the database (so that the highest number is not helpful), then you can instead generate a list of random ids, send that, and then request them one at a time. Pre-generate the random list, as it were. Hope this helps! :-)
0
0
0
0
2013-11-19T13:03:00.000
2
0.099668
false
20,072,309
0
0
1
1
I'm working on a web app in Python (Flask) that, essentially, shows the user information from a PostgreSQL database (via Flask-SQLAlchemy) in a random order, with each set of information being shown on one page. Hitting a Next button will direct the user to the next set of data by replacing all data on the page with new data, and so on. My conundrum comes with making the presentation truly random - not showing the user the same information twice by remembering what they've seen and not showing them those already seen sets of data again. The site has no user system, and the "already seen" sets of data should be forgotten when they close the tab/window or navigate away. I should also add that I'm a total newbie to SQL in general. What is the best way to do this?
PyDev Eclipse Plugin fails to update in Eclipse Update Manager
41,791,350
1
3
1,251
0
python,eclipse,pydev
It seems that the best resolution for this is to update from Eclipse 3.7 to 4.3+.
0
1
0
0
2013-11-19T18:06:00.000
1
1.2
true
20,078,776
0
0
1
1
I'm trying to update some software in Eclipse, and mostly haven't had problems, but when I try to update PyDev (Python plugin) I get this error: An error occurred while collecting items to be installed session context was:(profile=epp.package.java, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=). Problems downloading artifact: osgi.bundle,com.python.pydev,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile2219600778088128210.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile2219600778088128210.jar Problems downloading artifact: osgi.bundle,com.python.pydev.analysis,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile6795154829597372736.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile6795154829597372736.jar Problems downloading artifact: osgi.bundle,com.python.pydev.codecompletion,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile855072635271316145.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile855072635271316145.jar Problems downloading artifact: osgi.bundle,com.python.pydev.debug,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile4688521627100670190.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile4688521627100670190.jar Problems downloading artifact: osgi.bundle,com.python.pydev.fastparser,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile1084399815407097736.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile1084399815407097736.jar Problems downloading artifact: osgi.bundle,com.python.pydev.refactoring,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile4184776883512095240.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile4184776883512095240.jar Problems downloading artifact: osgi.bundle,org.python.pydev,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile4524222642627962811.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile4524222642627962811.jar Problems downloading artifact: osgi.bundle,org.python.pydev.ast,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile3249163288841740294.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile3249163288841740294.jar Problems downloading artifact: osgi.bundle,org.python.pydev.core,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile1814921458326062966.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile1814921458326062966.jar Problems downloading artifact: osgi.bundle,org.python.pydev.customizations,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile4652077908204425024.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile4652077908204425024.jar Problems downloading artifact: osgi.bundle,org.python.pydev.debug,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile5865734778550017815.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile5865734778550017815.jar Problems downloading artifact: osgi.bundle,org.python.pydev.django,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile1400608644382694448.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile1400608644382694448.jar Problems downloading artifact: osgi.bundle,org.python.pydev.help,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile5475958427511010644.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile5475958427511010644.jar Problems downloading artifact: osgi.bundle,org.python.pydev.jython,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile269530960804801404.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile269530960804801404.jar Problems downloading artifact: osgi.bundle,org.python.pydev.parser,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile6988087748918334886.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile6988087748918334886.jar Problems downloading artifact: osgi.bundle,org.python.pydev.refactoring,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile1524645906700502816.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile1524645906700502816.jar Problems downloading artifact: osgi.bundle,org.python.pydev.shared_core,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile7684330420892093099.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile7684330420892093099.jar Problems downloading artifact: osgi.bundle,org.python.pydev.shared_interactive_console,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile6948600865186203811.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile6948600865186203811.jar Problems downloading artifact: osgi.bundle,org.python.pydev.shared_ui,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile2509877364480980768.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile2509877364480980768.jar Problems downloading artifact: org.eclipse.update.feature,org.python.pydev.feature,3.0.0.201311051910. Error reading signed content:C:\Users\Blake\AppData\Local\Temp\signatureFile7424055901779492006.jar An error occurred while processing the signatures for the file: C:\Users\Blake\AppData\Local\Temp\signatureFile7424055901779492006.jar I run Eclipse as an administrator and I don't understand what could cause this issue. Regards,
RabbitMQ: Preventing jobs to run simultaneously on two different workers
20,095,672
1
2
155
0
python,django,rabbitmq,pika
You will have to use some locking mechanism, perhaps based on database. When a worker is working on a django object, it marks the work in database. a MySQL example: worker_id | object_id | task_type 22 44 3 // entry inserted to mark the work When another worker picks up a django object, it checks that it is not marked as in #1, and proceeds to pick next item. When a worker has finished working on an object, the database lock row is deleted or marked as FINISHED.
0
0
0
0
2013-11-20T12:02:00.000
1
0.197375
false
20,095,451
0
0
1
1
I have a Python Django project with two RabbitMQ workers, using the pika lib, which receives jobs to perform actions on a certain Django object which is specified in the request. The thing is, I don't want the workers, A and B, to perform their actions on the same Django object, x, at the same time as that might cause problems. It doesn't matter which workers goes first but if A is working on x and B receives a job to work on x, I want this job to wait until A is done. So the problems boils down to being able to know what the other worker is working on and being able to pause a job until a certain time. Note that in my actual project I have more than 2 workers which this must be applied to, I choose two In my example to make it easier to dissect. Thanks for the help, Mattias
TastyPie authentication for pure javascript site
20,102,341
2
1
57
0
python,django,tastypie
will see basic read only info from the Django API. It sounds like you probably just want to make those bits of the API publicly available for read-only access, and then not use any authentication method. As you say attempting to hide a key isn't a sensible way to go, and if there's no kind of user login then you can't really authenticate in any secure way.
0
0
0
0
2013-11-20T17:03:00.000
1
1.2
true
20,102,228
0
0
1
1
I'm using Django TastyPie for my API. I have a completely separate HTML application that my user views and will see basic read only info from the Django API. My question is what authentication method should I use in this situation. The HTML application is technically me not the user and they don't login. The app is not Django but pure javascript, hiding a key or anything else is pointless.
Google Cloud Storage Client Library 400 error on devserver as of update 1.8.8
20,105,749
1
1
164
0
python,google-app-engine,google-cloud-storage,client-library
have you updated gcs client to 1.8.8 version from the downloads list, or to SVN head? Thanks.
0
1
0
0
2013-11-20T19:29:00.000
1
1.2
true
20,105,156
0
0
1
1
I haven't changed any code, but when I try to upload an image file using the GCS Client library on app engine's dev server, I am now getting this fatal error: Expect status [201] from Google Storage. But got status 400. This was working until I made the update from Google to 1.8.8 as of 11/19/13. Anybody else seeing this? It doesn't give any other indications as to why the 400 error.
twisted web for production server service
20,114,092
0
2
805
0
python,web,twisted
I have found several good references for launching daemon processes with python. See daemoncmd from pypi. Im still coming up a little short on the monitoring/alert solutions (in python).
0
1
0
0
2013-11-21T02:21:00.000
1
0
false
20,111,254
0
0
1
1
I would like to deploy several WSGI web applications with Twisted on a debian server, and need some direction for a solid production setup. These applications will be running 24/7. I need to run several configurations, each binding to different ports/interfaces/privileges. I want to do as much of this in python as possible. I do not want to package my applications with a program like 'tap2deb'. What is the best way to implement each application as a system service? Do I need some /etc/init.d shell scripts, or can I manage this with python? (I don't want anything quite as heavy as Daemontools) If I use twistd to manage most of the configuration/process management, what kind of wrappers/supervisors do I need to put in place? I would like centralized management, but restricting control to the parent user account is not a problem. The main problem I want to avoid, is having to SSH into my server once a day to restart a blocking/crashed application
Django authentication via external provider
21,763,143
1
1
743
0
python,django,authentication
This sounds quite reasonable. There are several ways to achieve this: use a third party library like django-social-auth which handles using third party applications to authenticate users via the Django user model. The other way to do this is to write your own custom backend that uses OAuth2 protocol to authenticate users via a third party application (e.g. Twitter) and saves/authorizes them as a Django user for your application. This might sound difficult but it's quite easy. I wrote an example Django application to demonstrate this functionality as well as provide a tutorial for custom backend authentication. This app/tutorial uses Django 1.5: djangoauth.thecloutenproject.com/
0
0
0
0
2013-11-21T02:42:00.000
2
0.099668
false
20,111,456
0
0
1
1
I am just learning python and django and I put up a pretty decent website to manage a database and also a search page. The new requirement that I am a bit confused now is that the authentication should be done through an external provider (unknown yet, but probably LDAP or Kerberos Tickets). My idea was to authenticate the users through this service and if successful add the user to my django created database with syncdb (where I have permissions and groups) and then bypass this user as authenticated to enable them to perform actions in the site. Does that sound reasonable? Is there an 'accepted' approach to this kind of authentication? I am not sure if I will have to write my own authentication view. Thanks.
How Apache Solr works with Django 1.5?
20,115,328
1
1
103
0
python,django,apache,solr,django-haystack
Django and Apache Solr have no relation with each other. You can use django like you would use normally, and use pysolr or sunburnt python module to fetch/write data to SOLR. I would recommend pysolr for its simplicity.
0
0
0
0
2013-11-21T07:48:00.000
1
0.197375
false
20,115,202
0
0
1
1
I am new on Django framework. So please help me work with solr and Django. I am trying with some tutorial available on different site but all worked with older versions of Django and Apache Solr those are not compatible with new versions.
Django Admin: Register extra staff Admin
20,132,972
0
0
114
0
python,django
You only have to set the is_staff flag on your user to True. Superusers bypass user perrmissions (all is permited).
0
0
0
0
2013-11-21T21:45:00.000
1
0
false
20,132,603
0
0
1
1
Is there a way to register extra staff Admins such as a log in or sign up? or is the only way to add them in the Superuser Admin?
Calling exe in Windows from Linux
20,140,905
0
0
252
0
python,linux,django,windows,apache
I can think of some ways to do this: Use web services with real REST protocol and cross-site scripting protection Use WINE (As OneOfOnes suggested in his comment) But this is very risky for real production and might not work at all (or just when the load will become heavier) Write some code in the windows machine and call this code using something like Zero-MQ (ZMQ) or similar product Depending on the way your are using this library, One solution can fit better than the others. For most cases, I would suggest to go with ZMQ This way you can use much more complex models of communication (subscription-subscribers, send-response, and more) Also, using ZMQ would let you to scale in a very easy way if the need will come (you will be able to put few windows machines to process the requests) Edit: To support file transfer between machines, you have few options as well. Use ZMQ. File can be just a stream of data. No problem to support such a stream with ZMQ Use file server with some Enq. procedure Enq. can be done via ZMQ msg to inform the other side that the file is ready You can use folder share instead of a file server, but sharing files on the windows machine will not be a scale-able solution Windows program can send the file via FTP or SSH to the Linux server. Once again, signaling (file ready, file name,...) can be done with ZMQ
0
1
0
0
2013-11-22T08:09:00.000
1
0
false
20,139,979
0
0
1
1
Background knowledge: Website in Django run under apache. Briefly speaking, I need to call an .exe program in a windows machine from a Linux machine. The reason for this is our website runs on Linux, but one module relies on Windows DLL. So we plan to put it on a separate windows server, and use some methods to call the exe program, and get the result back. My idea is: setup a web service on that windows machine, post some data to it, let itself deals with the exe program, and return some data as response. Notice that request data and response data will both contains files. I wonder if there is any neater way for this? EDIT: Thanks for @fhs, I found I didn't make my main problem clearly enough. Yes, the webservice could work. But the main disadvantages for this is: basically, I need to post several files to windows; windows receive files, save them, call the program using these files as parameters, and then package the result files into a zip and return it. In linux, receive the file, unpack it to local file system. It's kind of troublesome. So, is there any way to let both machines access the other one's files as easily as in local file system?
mykey.get() method doesn't work in google app engine project
20,156,917
3
0
99
0
google-app-engine,python-2.7,app-engine-ndb
A few things are wrong here. Firstly Subcategory.get_by_id(subcategoryId) probably won't work as you example key has an ancestor defined. You need to include the ancestor(s) in get_by_id Given you are using a mySubcategorykey.get() and you don't retrieve an entity then it means the key is incorrect. a get by key won't experience eventual consistancy so the key is just wrong, or you didn't put() the original entity. I suggest you examine the key after you put() the entity and see if it actually matches what you are using. Also there are problems with your example key, ndb.Key(Category, 'Foods', Subcategory, subcategoryId) Category and Subcategory need to be strings, or variables with a string value of "Category" and "SubCategory" - which would be a bit odd to write this way. Also you don't create query objects from keys , query is a method of ndb.Model, or you instantiate a query object from ndb.Query . So you are mixing up some terminolgy and/or concepts.
0
1
0
0
2013-11-23T00:00:00.000
1
1.2
true
20,156,694
0
0
1
1
I am passing one of my projects to the google app engine, just for the sake of learning. However I have some problems with the ndb datastore. My root entity would be Categories and these have Subcategories as child entities. So let's say I have Category Foods which has Subcategory Main Dishes. So the key for this Entity would be ndb.Key(Category, 'Foods', Subcategory, subcategoryId). When I am creating a query object from this key I can fetch the correct subcategory, but from the documentation I would like to do other two methods as well which are not working, I don't know for what reason. mySubcategorykey.get() => it returns None using the aforementioned key. Subcategory.get_by_id(subcategoryId) => Also returns None. Also when I am generating a safeUrl from the key, I cannot return the object with ndb.Key(urlSafe=myUrlSafeString).get(), however printing the ndb.Key(urlSafe) gives me the correct key, as it states in the DataStore Viewer. Anyone can help me please telling what I am doing wrong? Thank you.
AppEngine Push to Deploy and Modules
20,196,135
4
3
347
0
python,git,google-app-engine
Lack of support for App Engine modules is a known issue for the push-to-deploy feature, and is something we're actively working on addressing at this time.
0
1
0
0
2013-11-23T06:08:00.000
1
1.2
true
20,159,232
0
0
1
1
Can I use AppEngines "Push to Deploy" (deploying by pushing a GIT repository) to update a multiple module Python application? Where do I get the repo url for the non default modules?
Multiple DB tables with django models possible?
20,162,808
1
0
196
0
python,django
Django seems to do one DB table per model Actually you'd better think about it the other way round : a Django "Model" is the representation of one DB table. But I think that means all of the registrations for every race (via a foreign key) will be in it...one table for all of them. Maybe it's not that many, but it seems messy and unclean to have all registrations for all of the races in one table. Why ??? Races on average have about 500 people, some can be a couple thousand. SQL Databases are designed to work on much bigger datasets - think millions of rows and more. With 2000 registrations per race and a few races per year you shouldn't have to worry too much. Now if you have peoples registering for more than one race, you'd be better with three tables: race(race_id, name, date, ....) person(person_id, firstname, lastname, ...) registration(race_id, person_id, ....) with a unique constraint on (registration.race_id, registratio.person_id). From your question I assume you have very few knowledge - if any - or relational databases, so I strongly suggest you take some times learning about proper relational databases modeling.
0
0
0
0
2013-11-23T12:57:00.000
1
1.2
true
20,162,566
0
0
1
1
I am slowly learning Django trying to write an app to replace the complicated PHP mess we have now. In the end what we need is pretty simple, but I am trying to wrap my head around what the best way (or "django way") is to do things. Here's what we do: We manage races (what I'll call events) and do online registrations and payment for them. That basically means the user goes to a URL, fills out some personal info in a form and then they are in the database and sent to PayPal for payment. So, with the current system some software creates a "race" form with the form fields I want and then behind the scenes a DB table is created with the name of the race. That table holds all of the registrations (obviously has a column for each form field plus some extras for behind-the-scenes processing). Currently I just recreate the form each year of the race, but I'm thinking with Django I am going to be cleaner and save the duplicate work and use the same "form" or "model" in Django land and just have some way to archive that data to another DB. Anyway, here's where I need some advice: Django seems to do one DB table per model? So what I was thinking was I'd have a "Race" model with some general info about the race including some questions that will decide what form fields show up in my other model (for example, if the race has requires payment, we'll have some extra fields and logic for PayPal). All of the races will be in one DB table, but that's probably fine here...there's not going to be that many. However, I then am thinking there'd be a "registrations" model that actually has all of those form fields in it and will be behind the actual registration form that people fill out. But I think that means all of the registrations for every race (via a foreign key) will be in it...one table for all of them. Maybe it's not that many, but it seems messy and unclean to have all registrations for all of the races in one table. Races on average have about 500 people, some can be a couple thousand. Do I just live with it or is there a better way to design this? I'm also trying to think of flexability...where sometimes in the past I've had to manually load some data into the table for a specific form or mass change registrations for a particular race. Yes, I could be more specific with my queries, but it felt safer knowing I could only affect the registrations for one race because they were separate tables. Do I just create database views as some type of alternative? In the end, I just want to make sure that this is a good design that will not slow down or be too inefficient, for example, when I will need to do sorting occasionally and also exports for each race (so that would end up needing to be queries for a specific race ID and getting everyone who registered just for that race). Sorry for being so longwinded, I am doing the django tutorial now and I just want to be sure as I am thinking in my head how this will go, that I am going to have a decent design to grow with. Thanks so much!
App can't be tested because of conflit with django.contrib.messages
20,166,747
0
0
38
0
python,django,django-testing
You need to make sure your application appears in your settings.py INSTALLED_APPS before django.contrib.messages does.
0
0
0
0
2013-11-23T19:12:00.000
1
1.2
true
20,166,638
0
0
1
1
In my django project, I'm having trouble testing my homemade app named "messages". If I write a single test in messages/tests.py and try to run it with python manage.py test messages, it will perform 74 tests from, I guess, the django.contrib.messages library. How can I run my local app tests instead of the library one without renaming it? All other tests for my apps with other names run fine.
Using Soundcloud Python library in Google App Engine - what files do I need to move?
20,177,193
0
0
241
0
python,google-app-engine,pip,soundcloud
Ok, I think I figured out. What I needed to do what copy the soundcloud folder, along with the fudge, simplejson and requests folders into the root folder of my webapp. Thank you VooDooNOFX -- although you didn't directly answer the precise question, you sparked the thinking that helped me figure it out.
0
1
0
0
2013-11-23T19:19:00.000
2
0
false
20,166,720
0
0
1
1
I want to use the soundcloud python library in a web app I am developing in Google App Engine. However, I can't find any file called "soundcloud.py" in the soundcloud library files I downloaded. When using pip install it works fine on my local computer. What files exactly do I need to move - or what exact steps do I need to take - in order to be able to "import soundcloud" within Google App Engine. I already tried moving all the *.py files into my main app directory, but still got this error: import soundcloud ImportError: No module named soundcloud
Best way to implement long running subprocess in Django?
20,231,324
5
4
1,377
0
python,django,python-2.7,subprocess,celery
If you don't want something as complex as Celery, then you can use subprocess + nohup to start long running tasks off, dump the PID to a file (check the subprocess documentation for how to do that) and then check if the PID contained in the file is still running (using ps). And if you wanted, you could write a very small 'wrapper' script which would run the task you tell it to, and if it crashes, write a 'crashed.txt' file. One thing to note is that you should probably run commands including the close_fds=True value to the call. (so check_call(['/usr/bin/nohup', '/tasks/do_long_job.sh'], close_fds=True) ). Why? By default, all subprocesses are given access to the parent's open file descriptors, INCLUDING ports. This means that if you need to restart your web server process, while the long process is running, that the running process will keep the port open, and you won't be able to load the server up again. You can guess how I found this out. :-)
0
1
0
0
2013-11-23T21:37:00.000
2
0.462117
false
20,168,198
1
0
1
1
I know there are many questions similar to this one, but as far as my research has taken me, none of them answers my specific question. I hope you will take your time to help me out, as I have been struggling with this for days without finding a proper answer. I am trying to find the best way to implement a subprocess into a Django application. To be more specific: The process will be run from one view (asynchronously) and handled from another. The process can run up to several hours. Multiple instances of the same process/program should be able to run at the same time. Other than knowing when the process is completed (or if it crashed, so it can be re-run), no communication with it is needed. Does anyone know which way would be the best to implement this? Would any of the Python modules (such as subprocess, threads, multiprocessing, spawn) be able to achieve this or would I have to implement an external task queue such as Celery?
UnicodeEncodeError with django: inconsistent behavior
20,192,605
0
0
372
0
python,django,apache
This error comes because of filename or file contents cotains garbage collection or in another language (except english).. So you can add unicode() for this. or check NLTK library of handling this situation.
0
0
0
0
2013-11-25T09:30:00.000
3
0
false
20,188,586
0
0
1
1
I deployed a project on webfaction with djanog. All went fine until recently, when all of a sudden I started to get this error: UnicodeEncodeError: 'ascii' codec can't encode characters in position 64-68: ordinal not in range(128) The url is with Russian characters. But the matter is, when I restart Apache, there is no error any more. So it is kind of difficult for me to pin the error.
Multiple external packages with same name
20,195,470
0
1
78
0
python,django
If those different sites use the same controller (file.py) then the packages must have different name.
0
0
0
0
2013-11-25T14:13:00.000
2
0
false
20,195,265
0
0
1
1
I have a problem, where I have two packages that I use quite often, in different sites, with the same name. Namely, they are django-simple-captcha and django-recaptcha. They are both just called captcha. In addition, these are shared between several people who may work on them, so I can't just have them as different names without it messing up between people. Is there some way to solve this?
What is uWSGI master mode?
20,199,153
5
11
4,022
0
python,uwsgi
upstart is only a process manager, the uWSGI master has access to lot of memory areas of workers (well it is the opposite indeed) so it can make truly monitoring of the behaviour of workers, in addition to this it allows graceful reloading, exports statistics and dozens of other things. Running without it is not a good idea from various point of views.
0
1
0
1
2013-11-25T15:49:00.000
1
1.2
true
20,197,259
0
0
1
1
What are the benefits of running uWSGI in master mode if I'm only running a single app? Does master mode offer process management benefits that make it more reliable than, say, running via Upstart?
Making android app work with a python web server
20,198,995
0
0
682
0
android,python,eclipse
You don't seem to have a clue about how the android app and the web app are supposed to work together... You can (theoretically) use just any language and techno you find appropriate for the web app since the communication between the android app and the web app will be http requests / responses. Also, you can use whatever code editor you want to write Python code, as long as it (the code editor) supports Python.
0
0
0
0
2013-11-25T17:00:00.000
2
0
false
20,198,826
0
0
1
1
I have a small android application made in eclipse. Now i need to build a web server with python so they could work together. Should i make a new python projekt then in some way link it to my application? Or Should i use jython and rebuild the app in a jython project? I have used Visual studio before, and eclipse is not my hometown, så i would really appreciate clear answers.
Running python from a mounted filesystem
62,098,699
0
0
417
0
python,django,virtualbox,vagrant
One solution I found was to mount my shared folder with cifs into the VM. That seems to work flawlessly. I did not found a solution for the vboxsf.
0
0
0
0
2013-11-25T18:33:00.000
3
0
false
20,200,556
1
0
1
1
I have a django-based application that I'm running from a virtualbox-shared folder. When starting using 'runserver' I get an error indicating that a module could not be found. After copying the same exact code to a directory on the local filesystem, it starts and runs as expected. Anyone seen anything like this when working with virtualbox and python? It appears that module resolution is working differently when python is run from the mounted shared folder vs. the local folder, but I can't find a smoking gun that indicates whether or not it's caused by how that folder is mounted or python. Thanks!
How do I stream an openCV video to an HTML webpage?
35,518,047
2
22
32,863
0
c++,python,html,opencv
Under lab conditions you send full images You seem to be under lab conditions, so there is a simplistic, yet usable solution, just stream PNG's in Base64 using Websockets. On the client side (web browser) you just receive the base64 images and directly load them into the src of an <img>. It works for lab scenarios very well, albeit slow.
0
0
0
1
2013-11-25T23:08:00.000
4
0.099668
false
20,205,358
0
0
1
1
I am making a robot that will have a webcam on it to provide some simple object detection. For right now, I would like to simply stream the video to a webpage hosted on the robot and be able to view it from another device. I have written a simple test script in Python ( I will eventually move to C++, my language of choice) which can get a stream from my webcam, and then do whatever I need with it from there. The problem then, is that I can't write the video to a file while the app is running, it only writes the file after I quit the script. I already have a webserver running, and I can write the basic code in HTML to host a video from a file as well, and all of that works. To summarize: Is openCV2 in Python and/or C++ capable of livestreaming video using only openCV? If not, what library would you recommend that I try to take a CV capture object or Mat object and write it to a stream that I can then put on a webpage? In HTML, is the tag a good idea to stream video with? Thank you very much for the advice, I can use all the pointers* I can get! If you need something clarified/code posted/explanations further than what I have given, please ask and I will do so!
Google Compute Engine OpenERP
23,682,731
0
2
513
0
python,debian,openerp,google-compute-engine
you could limit access to your OpenERP instance by specifying --allowed_ip_sources="x.x.x.x" the IP or the CIDR range from where you expect the application to be accessed. Additionally limit access of 8060 port only to your OpenERP instance, by tagging the instance as say ERP and apply --target_tags="ERP" to limit traffic from your source IP range to hit only the specific ERP instance.
0
1
0
0
2013-11-26T02:36:00.000
2
0
false
20,207,499
0
0
1
1
I already install OpenERP and PostgreSQL in google compute engine. Using debian 7. when i check with ifconfig as root user. I just got 2 ip addres. 127.0.0.1 and my internal ip address. My external IP/IP Public can't detected by debian 7. I use ephemeral ip address for my external IP. I allready try run OpenERP service using 127.0.0.1:8069 and my internal IP 10.240.226.xxx. I can't access it from my external IP 8.34.xxx.xx:8069. Please give me advice to fix these problem? and where i can contact or find Google "Help & Support" or submit "ticket support", beside using stackoverflow and google group?
Run compiled Python
20,207,935
3
1
115
0
python,django
can you execute Python programs from .pyc files where there is no .py file? Yes. Simply place the .pyc file wherever the .py file would normally be used (except into your text editor, of course). If yes, is this also possible in Django? How? No difference. The interpreter handles the files the same way regardless of what framework is being used. Is it a good way to make web apps "almost closed source"? Not really. Decompiling compiled Python bytecode is trivial.
0
0
0
1
2013-11-26T03:19:00.000
2
1.2
true
20,207,882
0
0
1
1
So I've been entering the world of Python just recently, and directed it to quick, personal programs made for myself and professional use for web application design with Django. I've taken a few introductory Python tutorials and most Django tutorials, and have been reading Python documentation whenever possible. I've recently seen that .pyc files are just bytecode (compiled) .py scripts, and don't make the Python language any faster, only lighter and non-human-readable. However, in a medium-low traffic site (let's say, 95% of web sites), this is negligible in difference from PHP, for example (and I find Python to be thousands of times more productive). The question is: can you execute Python programs from .pyc files where there is no .py file? If yes, is this also possible in Django? How? Is it a good way to make web apps "almost closed source"?
Recommendation engine using collaborative filtering in Python
20,237,347
0
0
1,190
0
python,algorithm,neo4j,recommendation-engine
I think you won't find any out-of-the box solution for you problem, as it is quite specific. What you could do with Neo4j is to store all your data that you use for building recommendations (users, friendships links, users' restaurants recommendations and reviews etc) and then build you recommendation engine on this data. From my experience it is quite straightforward to do once you get all your data in Neo4j (either with Cypher or Gremlin).
0
0
0
0
2013-11-26T20:59:00.000
1
1.2
true
20,227,834
0
0
1
1
I have developed a search engine for restaurants. I have a social network wherein users can add friends and form groups and recommend restaurants to each other. Each restaurant may serve multiple cuisines. All of this in Python. So based on what restaurants a user has recommended, we can zero in on the kind of cuisines a user might like more. At the same time, we will know which price tier the user is more likely to explore(high-end, fast food, cafe, lounges etc) His friends will recommend some places which will carry more weightage. There are similar non-friend users who have the recommended some the restaurants the user has recommended and some more which the user hasn't. The end problem is to recommend restaurants to the user based on: 1) What he has recommended(Other restaurants with similar cuisines) - 50% weightage 2) What his friends have recommended(filtering restaurants which serve the cuisines the user likes the most) - 25% weightage 3) Public recommendation by 'similar' non-friend users - 25% weightage. I am spending a lot of time reading up on Neo4j, and I think Neo4j looks promising. Apart from that I tried pysuggest, but it didn't suit the above problem. I also tried reco4j but it is a Java based solution, whereas I'm looking for a Python based solution. There is also no activity on the Reco4j community, and it is still under development. Although I've researched quite a lot, I might be missing out on something. I'd like to know how would you go about implementing the above solution? Could you give any use cases for the same?
user system with social authentication in django
20,229,262
1
0
74
0
python,django,facebook,authentication
There is an app called django-allauth. If you read their official documentation, it is pretty easy to follow. As per their instructions, you install the core app, and any other authentication you need (like facebook, oauth which google uses). Then, you have to go to facebook, get developers key, and add it to your django admin. Basically, when somebody tries to login using facebook, the signin process sends the keys to facebook, and check if the user exists. If it does, then the authentication app creates user on the backend, just like a normal signin process. You can get javascript from facebook to make a login window.
0
0
0
0
2013-11-26T22:11:00.000
1
0.197375
false
20,229,048
0
0
1
1
I've read about a lot of different apps for django for integrating social authentication to django projects. But, I'm having some trouble understanding how this integration works Does it extends the default USER models? Where do I find those kind of information in the applications? I basically need a user system that has groups (for permission purposes). The user would be able to register using a common registration proccess or facebook. Will I be able to achieve that with any kind of application? Thanks in advance.
Django-tables2 Sorting TemplateColumn
21,063,484
0
2
448
0
python,django,sorting,django-tables2
In the matter of fact, this can't be done. if TemplateColumn name is based on name in model, sorting works fine. As far as I am concerned If you want present other data it is impossible.
0
0
0
0
2013-11-27T13:28:00.000
1
1.2
true
20,243,803
0
0
1
1
Is it somehow possible, to add custom sort method to values generated using TemplateColumn? because on basic it tries to find column name in model and returns FieldError: Cannot resolve keyword u'coulmn_name' into field. Choices are: [all fields in model].
How to install django for python 3.3
33,155,616
1
14
16,364
0
python,django,macos
to setup django in pyton3 sudo apt-get install python3-pip sudo pip3 install virtualenv virtualenv -p /usr/bin/python3.X venv source venv/bin/activate congrats you have setup python3 django and now have many packages to work with Note: X stands for the version of python
0
0
0
0
2013-11-27T19:39:00.000
4
0.049958
false
20,251,562
1
0
1
2
I had python 2.6.1 because it was old I decide to install python 3.3.2 but, when I type "python" in my mac it prints it is version 2.6.1 and when I type python3 it shows that this is 3.3.2. I installed django 1.6 but when I check, understand that it is installed for old version of python (python 2.6.1). I want to instal it for my python 3.3.2 what should I do? any way to uninstall python 2.6.1 and when I enter python in terminal it's version be 3.3.2? I have mac os 10.6.8
How to install django for python 3.3
46,796,659
0
14
16,364
0
python,django,macos
To install django for python3, you need to use pip3 instead of pip. python defaults to python2. pip defaults to pip for python2. So, when you install pip using whatever package manager you have, you are essentially installing pip for python2. To remove Python2: $sudo apt remove python To install pip for python3: $sudo apt install python3-pip To install pip for python2: $sudo apt install python-pip Note: I am using apt package manager. You should use the package manager for your OS.
0
0
0
0
2013-11-27T19:39:00.000
4
0
false
20,251,562
1
0
1
2
I had python 2.6.1 because it was old I decide to install python 3.3.2 but, when I type "python" in my mac it prints it is version 2.6.1 and when I type python3 it shows that this is 3.3.2. I installed django 1.6 but when I check, understand that it is installed for old version of python (python 2.6.1). I want to instal it for my python 3.3.2 what should I do? any way to uninstall python 2.6.1 and when I enter python in terminal it's version be 3.3.2? I have mac os 10.6.8
Mac OS deploy Django + Apache on Amazon EC2
20,256,055
1
0
304
0
python,django,apache,deployment,amazon-ec2
You use Terminal to SSH into your AWS EC2 environment. All commands past there are 100% platform based (ubuntu, amazon linux, red hat, etc). You wouldn't use any Mac OS commands besides creating the SSH connection. There's a tutorial on how to do that through the EC2 console.
0
1
0
0
2013-11-27T20:35:00.000
1
1.2
true
20,252,595
0
0
1
1
I am trying to deploy Django and Apache to Amazon EC2 server. Currently, i have already got the AWS account and lunched the instance on server. But the problem is that i cannot find a tutorial about how to deploy Django and Apache to Amazon EC2 WITH Mac OS, all i can find are Linux system deploying tutorials. Where can i find deploying tutorial for Mac OS?
Writing user.get_profile() custom function which should create auth profile if there is not any
20,254,928
1
1
84
0
python,django
I am a bit confused. Are you trying to let users create account and sign in? Then use django-registration which is easy and works out of the box.
0
0
0
0
2013-11-27T21:28:00.000
2
0.099668
false
20,253,410
0
0
1
1
I am trying to write custom get_profile() function which should create user profile for users who are registered thru admin or any other way where post_save was not called. How can I start this?
create module in openerp through interface
23,950,717
0
0
226
0
python,xml,module,openerp
i had the same error just a while ago you need to give a proper name to your model without upper case my example : Remise is the designation and x_remise is the module name
0
0
0
0
2013-11-28T09:33:00.000
1
0
false
20,262,330
0
0
1
1
when i create a module through interface it shows me error when click on save button error in create m2o screen ERROR ValidateError Error occurred while validating the field(s) res_model,src_model: Invalid model name in the action definition.
Change Property of db.Model to custom Type
20,269,288
0
0
49
0
google-app-engine,python-2.7
Its not sql. You dont clone or delete 'tables', no such thing in the datastore. To do the migration you would use task queues to run through a query. You probably need to stop your frontend while doing so. Task queues have a longer limit than the 60sec you mention and each taskqueue will create another one until you finish pro essing all items in your query. Yiu also complain that its harder than other enviroments but it isnt so. The problem maybe is that you chose to use the datastore instead of cloud sql which you could also have used. Each has its pros and cons.
0
1
0
0
2013-11-28T12:58:00.000
1
0
false
20,266,882
0
0
1
1
I'm trying to change the Property several Fields on my GAE AppEngine to a custom Type (Encrypted Content). Most of them are currently String or Text Properties. Since we have multiple millions of Entries in our DB, migration is not an easy task. I'm looking for a best practise, here is what I think will work best but this might be very challenging to execution time limits plus I'm a little bit frightened about the costs for this task. clone table to tmp_table delete table create table with new attributes insert values from tmp_table into table What sounds like a short hiking trip on most environments feels a little bit more complex on GAE ;) My Questions to you: - Are there any know best practises you are aware of / did you already achieve this challenge & how? - Any Idea how to trigger the process (I would estimate it takes several minutes so the 60 second limit
Django Nginx Gunicorn = 504 Timeout
20,278,315
6
8
5,881
0
python,django,nginx,gunicorn
When you hold down F5: You've started hundreds of requests. Those requests have filled your gunicorn request queue. The request handlers have not been culled as soon as the connection drops. Your latest requests are stuck in the queue behind all the previous requests. Nginx times out. For everyone. Solutions: Set up rate-limiting buckets in Nginx, keyed on IP, such that one malicious user can't spam you with requests and DOS your site. Set up a global rate-limiting bucket in Nginx such that you don't overfill your request queue. Make Nginx serve a nice "Reddit is under heavy load" style page, so users know that this is a purposeful event Or: Replace gunicorn with uwsgi. It's faster, more memory efficient, integrates smoothly with nginx, and most importantly: It will kill the request handler immediately if the connection drops, such that F5 spam can't kill your server.
0
0
0
0
2013-11-29T02:40:00.000
2
1.2
true
20,277,537
0
0
1
1
I'm trying to publish a Django application on the production server using Nginx + Gunicorn. When I doing a simple stress test on the server (holding the F5 key for a minute) the server returns a 504 Gateway Time-out error. Why does this happen? This error only appears for the user when doing multiple concurrent requests, or the system will be fully unavailable to everyone?
Iterate through 2 loops in GAE Python templates
20,301,699
0
0
86
0
python,list,google-app-engine,jinja2
It sounds like you want to use itertools.product(list1, list2). This will create all combinations of list1 and list2. For example, if list1 = [1,2] and list2 = [1,2,3] then itertools.products(list1,list2) = [ (1,1),(2,1),(3,1),(2,1),(2,2),(2,3)]
0
0
0
0
2013-11-29T17:53:00.000
2
0
false
20,291,176
0
0
1
1
I am using Jinja2 template in python for Google App Engine. I need to iterate through 2 lists list1 and list2 in the same loop in the html file. I tried using zip as described in some of the posts but it is not working. Something similar in C : for(i=0.j=0; I<len(list1) && j < len(list2) ; I++,j++) Can anyone suggest some ways to implement the same?
Restrict Python API access to single Arduino entity
20,298,873
1
0
78
0
python,api,flask,arduino
Configure your WSGI container or its associated web server to only allow access to the Flask application from the IP address assigned to the Arduino's network interface.
0
0
0
1
2013-11-30T09:53:00.000
2
0.099668
false
20,298,833
0
0
1
1
I am basically writing an API in Python, using Flask, and I would like to restrict access to its endpoints so that only an entity, namely an Arduino, can have GET and POST access. How should I make this possible and what should I be looking for?
How to save Information in Database using BeautifulSoup
20,305,193
0
0
861
1
python,database,python-2.7,beautifulsoup,mysql-python
You're doing it wrong! Make an object that represents a row in the database, use __getitem__ to pretend it's a dictionary. Put your database logic in that. Don't go all noSQL unless your tables are not related. Just by being tables they are ideal for SQL!
0
0
0
0
2013-11-30T19:46:00.000
4
0
false
20,304,863
1
0
1
2
I'm getting different information for a particular thing and i'm storing those information in a dictionary e.g. {property1:val , property2:val, property3:val} now I have several dictionary of this type (as I get many things ..each dictionary is for a thing) now I want to save information in DB so there would be as many columns as key:value pair in a dictionary so what is the best or simplest way to do that. Please provide all steps to do that (I mean syntax for login in DB, push data into row or execute sql query etc... I hope there wont be more than 4 or 5 steps ) PS: All dictionaries have the same keys, and each key always has the same value-type . and also number of columns are predefined.
How to save Information in Database using BeautifulSoup
20,305,076
0
0
861
1
python,database,python-2.7,beautifulsoup,mysql-python
If your dictionaries all have the same keys, and each key always has the same value-type, it would be pretty straight-forward to map this to a relational database like MySQL. Alternatively, you could convert your dictionaries to objects and use an ORM like SQLAlchemy to do the back-end work.
0
0
0
0
2013-11-30T19:46:00.000
4
0
false
20,304,863
1
0
1
2
I'm getting different information for a particular thing and i'm storing those information in a dictionary e.g. {property1:val , property2:val, property3:val} now I have several dictionary of this type (as I get many things ..each dictionary is for a thing) now I want to save information in DB so there would be as many columns as key:value pair in a dictionary so what is the best or simplest way to do that. Please provide all steps to do that (I mean syntax for login in DB, push data into row or execute sql query etc... I hope there wont be more than 4 or 5 steps ) PS: All dictionaries have the same keys, and each key always has the same value-type . and also number of columns are predefined.
Periodic OperationalError: (2006, 'MySQL server has gone away')
20,309,286
4
2
2,432
1
python,mysql,mysql-python,pythonanywhere
It normally because your mysql network connect be disconnected, may by your network gateway/router, so you have two options. One is always build a mysql connect before every query (not using connect pool etc). Second is try and catch this error, then get connect and query db again.
0
0
0
0
2013-12-01T02:33:00.000
1
1.2
true
20,308,097
0
0
1
1
I am hosting a web app at pythonanywhere.com and experiencing a strange problem. Every half-hour or so I am getting the OperationalError: (2006, 'MySQL server has gone away'). However, if I resave my wsgi.py file, the error disappears. And then appears again some half-an-hour later... During the loading of the main page, my app checks a BOOL field in a 1x1 table (basically whether sign-ups should be open or closed). The only other MySQL actions are inserts into another small table, but none of these appear to be associated with the problem. Any ideas for how I can fix this? I can provide more information as is necessary. Thanks in advance for your help. EDIT Problem turned out to be a matter of knowing when certain portions of code run. I assumed that every time a page loaded a new connection was opened. This was not the case; however, I have fixed it now.
ImportError: No module named _csv . Qpython for android logs
31,173,939
0
0
840
0
importerror,qpython
To install _csv or any other module, follow these steps. Here's what I did to install websocket (and all of its dependencies): To install websocket on the phone: Start QPython Click the big button Select “run local script” Select “pip_console.py” Type “pip install websocket”
1
0
0
0
2013-12-01T04:17:00.000
2
0
false
20,308,674
0
1
1
2
I put goog_appengine inside android located at /mnt/sdcard I also put wsgiref folder at same location. from Qpython I manage to "send control key" + "d" I got sh $ I put command like the ff: "$python /mnt/sdcard/google_appengine/appcfg.py" But Igot ImportError: no module _csv I feel putting these is not same architecture " /usr/lib/python2.7/lib-dynload/_csv.x86_64-linux-gnu.so" That come from ubuntu 13.04. What to do next, Where I can find _csv module for Qpython+android_version. Is it possible to upload my code through android?
ImportError: No module named _csv . Qpython for android logs
21,482,814
0
0
840
0
importerror,qpython
You can install _csv from QPython's system. ( You can find system icon in qpython's new version 0.9.6.2 )
1
0
0
0
2013-12-01T04:17:00.000
2
0
false
20,308,674
0
1
1
2
I put goog_appengine inside android located at /mnt/sdcard I also put wsgiref folder at same location. from Qpython I manage to "send control key" + "d" I got sh $ I put command like the ff: "$python /mnt/sdcard/google_appengine/appcfg.py" But Igot ImportError: no module _csv I feel putting these is not same architecture " /usr/lib/python2.7/lib-dynload/_csv.x86_64-linux-gnu.so" That come from ubuntu 13.04. What to do next, Where I can find _csv module for Qpython+android_version. Is it possible to upload my code through android?
Why does Django say there is no module named views?
20,308,829
1
1
166
0
python,django
The views.py must be in the same folder as in the urls.py. If not, while importing the views.py, its better to specify the exact path of the views.py, from the SYS_PATH of the project (from the folder where you have the manage.py file), which will help
0
0
0
0
2013-12-01T04:41:00.000
2
0.099668
false
20,308,788
0
0
1
1
I have a Django project that I wrote. I am testing it on the development server. It is saying that there is no module named views, even though the file views.py is one level higher than it in the directory views. Why is this? Does the views.py need to be in the same folder as the urls.py? Is that causing this?
Change menu name openerp
20,322,373
3
2
325
0
python,xml,openerp,overwrite
yes you can. you just need to create a module with two files. one is __openerp__.py with correct dependency to the base modules and an xml file for updating the menu name.
0
0
0
0
2013-12-01T17:29:00.000
1
1.2
true
20,315,057
0
0
1
1
I want to change an openerp module menu name. I know how to do it, i'ts actually pretty easy, but this one is a core module sale and i don't want to touch it's code, because of updates issues and stuff. So, i'll need to inherit this view and change it's name, from another module, can i do this without a module.py or a full __init__.py file? Just the openerp manifest file and an xml to overwrite it? Thanks in advance!
Keeping JVM running
20,315,993
1
0
469
0
java,python,jvm
Without fixing python so it doesn't do you this, you can start a java service which calls your code and have python talk to it via TCP e.g. using protobuf. This way the service can be running all the time.
0
1
0
0
2013-12-01T19:03:00.000
1
0.197375
false
20,315,970
1
0
1
1
We've been working on a web application using Django. One library we needed to use was written in java, so I made a single jar file containing all the java code we need to use. The python script simply calls the java program using subprocess module and resumes its execution. Everytime the java program is called, it initializes the jvm, does a little work, and then uninitializes itself. This introduces some overhead which might not be that significant in the end but nevertheless having to go through this construct/destroy circle every time we need something from the java library bothers me. Is there an elegant way of doing this without the overhead i just described above?
I need to overwrite an existing Python installation in ubuntu 12.04.3
20,324,883
0
0
533
0
python,django,ubuntu
Sounds like an issue with your path - python not finding django becuase it doesnt know where to look for it. Look up issues regarding path and see if those help.
0
1
0
1
2013-12-02T09:29:00.000
2
1.2
true
20,324,828
0
0
1
1
and thanks ahead of time. I am relatively new to Linux and am using Ubuntu 12.04.3. Basically, I've been messing around with some files trying to get Django to work. Well, I though I should do another install of Python2.7 for some reason. Stupidly, I manually installed it. Now when I open the Python shell and do 'import django', it can't be found. I just want to go back to using the Python that was on Ubuntu by default, or overwrite the one I installed manually with one using apt-get. However, I am unable to figure out how to do this nor have I found a question that could help me. Any help is much appreciated. I've been working on this for 6 hours now... --EDIT-- Ok well I'm just trying to go ahead and have the PYTHONPATH look in the right place. I've seen in other posts that you should do this in the ~/.profile file. I went into that file and added this line export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/dist-packages "import django" is still coming up with "no module found" I tried doing "import os" and then "os.environ["PYTHONPATH"], which gave me: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/UserDict.py", line 23, in getitem raise KeyError(key) KeyError: 'PYTHONPATH' As far as I can tell, this means that I do not have a PYTHONPATH variable set, but I am unsure as to what I am doing wrong. --ANOTHER EDIT-- As I am not a very reputable member, I am not allowed to answer my own question before 8 hours from my original question, so I am putting it as an update. Hey guys, thank you all for the quick responses and helpful tips. What I did was open a python shell and type: sys.path.append('/usr/local/lib/python2.7/dist-packages') and it worked! I should have done this from the beginning instead of trying to overwrite my manual Python installation. Once again, thank you all for the help. I feel so relieved now :)
Which is a better practice - global import or local import
20,346,290
23
17
4,974
0
python,django,import
You surely must have noticed that almost all Python code does the imports at the top of the file. There's a reason for that: the overhead of importing is minimal, and the likelihood is that you will be importing the code at some point during the process lifetime anyway, so you may as well get it out of the way. The only good reason to import at function level is to avoid circular dependencies. Edit Your comments indicate you haven't understood how web apps generally work, at least in Python. They don't start a new process for each request and import the code from scratch. Rather, the server instantiates processes as required, and each one serves many requests until it is finally killed. So again it is likely that during that lifetime, all the imports will end up being needed.
0
0
0
0
2013-12-03T08:31:00.000
3
1.2
true
20,346,189
1
0
1
2
I am developing an app in django and I had a doubt if importing a library at the global level has any impact over the memory or performance than importing at the local ( per-function) level. If it is imported per function or view, the modules that are needed alone are imported saving space right? Or are there any negatives in doing so?
Which is a better practice - global import or local import
20,346,377
-2
17
4,974
0
python,django,import
When the script is run, it will store the modules in memory, i'm sure you understand that. If you're importing on a local scope, the module will be imported each time the client calls the function. But if the module is imported at a global level, there will be no need for that! So, in this case: global import wins.
0
0
0
0
2013-12-03T08:31:00.000
3
-0.132549
false
20,346,189
1
0
1
2
I am developing an app in django and I had a doubt if importing a library at the global level has any impact over the memory or performance than importing at the local ( per-function) level. If it is imported per function or view, the modules that are needed alone are imported saving space right? Or are there any negatives in doing so?
Is it possible to run scripts on django using only ftp?
20,346,988
2
0
219
0
python,mysql,django,ftp
ftp stands for "file transfer protocol", not for "remote shell", so no, you cannot use ftp to execute a command / program / script / whatever. But why don't you just ask your hosting how to get a dump of your data ?
0
0
0
0
2013-12-03T09:02:00.000
1
1.2
true
20,346,778
0
0
1
1
I am newbie to python and django, but this time I need a fast solution. I've got a problems, using hosting where my django application is deployed so I need to migrate to another server, but I have no ssh or telnet to server, only ftp connection for this server. I need to export data from django database. I wanted to write a script and put it somewhere in django application for data export, but when I put my modification on server behavior does not change(as nothing changed). Also when I remove .pyc files from djagno (for example. views.pyc) - no changes, and when I remove .py file - nothings changes (for example views.py). As far as I read about django, it is possible that server is running with option "-noreload". So question is it any possible way to dump database only via ftp and django/python? (remote connection via mysql is disabled)
Identify Browser alert messges in Mechanize - Python
22,406,798
0
0
244
0
python,mechanize,mechanize-python
Answering my own question. Browser giving an alert message simply means that our the node is injected into DOM. By simply looking for the string that I injected in the response body, I could determine whether the given input is reflected through the browser without proper sanitization.
0
0
1
1
2013-12-03T09:24:00.000
1
1.2
true
20,347,235
0
0
1
1
I am trying to develop a small automated tool in python that can check Forms inputs of a web application for XSS vulnerability. I hope to do this using python mechanize library so that I can automate form filling and submit and get the response from the python code. Though mechanize is also works as a browser, is there a way to detect a browser alert message for an input containing a script. Or else is there any other library for python such that I can perform this functionality. Any sample code will be a great favor. PS : I am trying to develop this so that I can find them in an application we are developing and include them in a report and NOT for Hacking purpose. Thank you.
How to run Python server without command prompt
20,349,538
3
2
1,565
0
python,django
You run the runserver command only when you develop. After you deploy, the client does not need to run python manage.py runserver command. Calling the url will execute the required view. So it need not be a concern
0
0
0
0
2013-12-03T11:08:00.000
3
0.197375
false
20,349,474
0
0
1
1
I'm developing some Python project with Django. When we render the Python/Django application, we need to open the command prompt and type in python manage.py runserver. That's ok on for the development server. But for production, it looks funny. Is there anyway to run the Python/Django project without opening the command prompt?
Modifying JSON response via Flask after_request
20,365,707
1
0
1,188
0
python,json,http,flask
I never needed to do something like this myself, but you can probably do this by subclassing the Response class. Let's say you create a JSONResponse class as a subclass of Response. The constructor of this class takes the same arguments as the parent class, but instead of a string for the body it takes a dictionary. So you do not call jsonify() at this point, just pass the dictionary with the data into the JSONResponse object. The response object takes the dictionary and stores it aside in a member variable, and then calls the parent response class and sets an empty response body for now. I think this will fool Flask into thinking the response is valid. When you get to the after_request handler you have access to the response object, so you can get the dictionary, still in its native form, and make any modifications you want. The JSONResponse class has a method that is called, say, render() that you call when you are done modifying the dictionary. This method calls jsonify() on the final version of the data and updates the response body in the parent class.
0
0
0
0
2013-12-04T01:52:00.000
1
1.2
true
20,365,356
1
0
1
1
I'm (attempting) to create a RESTlike API via Flask and would like to include the HTTP response code inside the returned json response. I've found the flask.jsonify() very helpful in generating my responses and I can manipulate the response via the app.after_request decorator. The issue I have is that the response data is already serialized by the time I can read it in the function I decorate with app.after_request so to insert the response.status_code would require de-serializing and re-serializing every request. I'm very new to flask and am unsure of the 'correct' way to get the status_code into the response, preferably before it gets serialized into a completed response.
Unable to start phantomjs with ghostdriver
26,636,714
0
2
2,389
0
python,selenium,phantomjs
Not sure what version of Ghostdriver you are on, but I got that error on 1.9.7 until I upgraded to selenium 2.40
0
0
1
0
2013-12-04T03:56:00.000
2
0
false
20,366,522
0
0
1
2
I am running a code that has selenium component, which requires phantomJS. I am getting the following error message: Unable to start phantomjs with ghostdriver.' ; Screenshot: available In my code, I specified my phantomJS path(the bin path), but such measure didn't work. I have placed the phantomJS-osx folder at the same location as my folder for selenium - would it be the cause of my problem? thanks
Unable to start phantomjs with ghostdriver
20,742,773
-2
2
2,389
0
python,selenium,phantomjs
This is a bug. Please use selenium 2.37.2
0
0
1
0
2013-12-04T03:56:00.000
2
-0.197375
false
20,366,522
0
0
1
2
I am running a code that has selenium component, which requires phantomJS. I am getting the following error message: Unable to start phantomjs with ghostdriver.' ; Screenshot: available In my code, I specified my phantomJS path(the bin path), but such measure didn't work. I have placed the phantomJS-osx folder at the same location as my folder for selenium - would it be the cause of my problem? thanks
How to "merge" two Python twisted applications?
20,429,005
0
2
247
0
python,asynchronous,twisted,tornado,reactor
So far I found, that if you merge two twisted applications, you should remove reactor.run() from one of them, leaving only one reactor.run() in the end. And be sure that twisted.reactor implementation is same for both applications. More comments welcome.
0
1
0
0
2013-12-05T15:28:00.000
2
0
false
20,403,921
0
0
1
1
I have two applications, written on twisted framework, for example one using twisted.web, and other using twisted.protocols.*, not web. How can I "merge" them in one, effectively sharing one reactor for both apps? What are the best practices for that tasks? Actually I need to connect SIPSimpleApp and TornadoWeb. They both can use twisted reactor.
PHP / Python / Ruby - Long running tasks with short previews
20,409,383
2
0
81
0
php,python,ruby
Language is irrelevant. Just put "short" operation in function (object, if it is complex) and use it from 2 places: web-code which needs "preview" will call it once and get its piece of data long-running background process will call it iteratively as much as needed and will store result of function in DB instead of returning it to user immediately Can be easily done in PHP. Long-running processeses are not a problem since 5.3
0
0
0
1
2013-12-05T17:44:00.000
1
1.2
true
20,406,998
0
0
1
1
I have a web frontend which uses data from a task that must be run frequently in bulk (which takes more time than I'd like to use PHP for). The data can be stored in a database so I was planning on writing a Java application to run the task and use the database as a middleman to get the results of this task accessible to the web. Problem is, a "preview" of this data is needed occasionally. IE, sometimes the user needs to request a sample of the data (which can be computed quickly) to be generated on cue. This presents a real problem for me, this preview IS more suited for a language like PHP even though it's essentially the same task. It's just two cases, in case A there are real jobs from many users to be done so the task takes a sufficiently long time to complete (longer than a PHP request can hold), in case B it's a baby job for just one user ran on the spot which could be completed in PHP without issue. I don't want to write this code twice, it would make maintenance a nightmare so I kind of need to pick a language and stick with it. The frontend is designed but not implemented so I have an oppertunity to write the site in PHP, Ruby or Python if need be. I know PHP, so I would only consider switching to Python or Ruby if one of those languages offered a solution to this problem. but I know so little about these languages that I really cannot begin to know if they offer a solution without learning them (which I don't have the time for atm). In short, is there a non-hackish way to write short, quick event-driven code AND long-running repetitive code with Ruby on Rails or Python? If not do you have any ideas how to satifsy these two cases with either PHP or Java?
Using relative URL's
20,422,180
1
2
195
0
python,cherrypy
Try <img src="/page_first/my_image.png"/>
0
0
1
0
2013-12-06T09:59:00.000
2
0.099668
false
20,421,001
0
0
1
2
I do a simple web application written in Python using cherrypy and Mako. So, my question is also simple. I have one page with URL http://1.2.3.4/a/page_first. Also there is an image that available on URL http://1.2.3.4/a/page_first/my_image.png. And I want to locate my_image.png on the page_first. I added a tag <img src="my_image.png"/>, but it is not shown. I looked at web developer tools->Network and saw that request URL for image was http://1.2.3.4/a/my_image.png, instead of http://1.2.3.4/a/page_first/my_image.png. Why does it happen? Thanks.
Using relative URL's
20,422,773
2
2
195
0
python,cherrypy
The page address needs to be http://1.2.3.4/a/page_first/ (with trailing slash). ADDED: You don't seem to understand relative URLs, so let me explain. When you reference an image like this <img src="my_image.png"/>, the image URL in the tag doesn't have any host/path info, so path is taken from the address of the HTML page that refers to the image. Since path is everything up to the last slash, in your case it is http://1.2.3.4/a/. So the full image URL that the browser will request becomes http://1.2.3.4/a/my_image.png. You want it to be http://1.2.3.4/a/page_first/my_image.png, so the path part of the HTML page must be /a/page_first/. Note that the browser will not assume page_first is "a directory" just because it doesn't have an "extension", and will not add the trailing slash automatically. When you access a server publishing static dirs and files and specify a directory name for the path and omit the trailing slash (e. g. http://www.example.com/some/path/here), the server is able to determine that you actually request a directory, and it adds the slash (and usually also a default/index file name) for you. It's not generally the case with dynamic web sites where URLs are programmed. So basically you need to explicitly include the trailing slash in your page path: dispatcher.connect('page','/a/:number_of_page/', controller=self, action='page_method') and always refer to it with the trailing slash (http://1.2.3.4/a/page_first/), otherwise the route will not be matched. As a side note, usually you put the images and other static files into a dedicated dir and serve them either with CherryPy's static dir tool, or, if it's a high load site, with a dedicated server.
0
0
1
0
2013-12-06T09:59:00.000
2
1.2
true
20,421,001
0
0
1
2
I do a simple web application written in Python using cherrypy and Mako. So, my question is also simple. I have one page with URL http://1.2.3.4/a/page_first. Also there is an image that available on URL http://1.2.3.4/a/page_first/my_image.png. And I want to locate my_image.png on the page_first. I added a tag <img src="my_image.png"/>, but it is not shown. I looked at web developer tools->Network and saw that request URL for image was http://1.2.3.4/a/my_image.png, instead of http://1.2.3.4/a/page_first/my_image.png. Why does it happen? Thanks.
How do I store files in googleappengine datastore
20,424,484
0
0
71
1
python,google-app-engine,blob,google-cloud-datastore
Datastore has a limit on the size of objects stored there, thats why all examples and documentation say to use the blobstore or cloud storage. Do that.
0
1
0
0
2013-12-06T10:47:00.000
1
0
false
20,421,965
0
0
1
1
Just wondering how to store files in the google app engine datastore. There are lots of examples on the internet, but they are using blobstore I have tried importing db.BlobProperty, but when i put() the data it shows up as a <Blob> i think. It appears like there is no data Similar to None for a string Are there any examples of using the Datastore to store files Or can anyone point me in the right direction I am new to programming, so not to complex, but I have a good hang of Python, just not an expert yet. Thanks for any help
Web2py launch script
20,437,241
1
0
1,158
0
python,web2py
Look at section 4.17.1 of the web2py manual (or Google "web2py cron"). You can run a script on startup of web2py by registering it in the crontab file as: "@reboot web2py *scripts/myscript.py" web2py should be the username that it will run as, which should be the same as what web2py runs as. In my setup I have a user named 'web2py' to run the app. The asterix before scripts/myscript.py indicates that you want to run the script in the web2py environment. Keep in mind that you run the risk of locking issues if your script is trying to use the database at the same time as the normal web2py process.
0
0
0
1
2013-12-06T15:09:00.000
1
1.2
true
20,427,217
0
0
1
1
I need a launch script which has access to "db" and other web2py modules. This script must be running constantly. I know that Web2py has launch parameters from which you can run python files in the web2py enviroment, but i don't know how that works. Can this parameter solve my problem and if so, how do I go about it? Thanks!
RS-485 Serial Port Baud Rate Performance Efficiency
20,437,926
5
3
1,777
0
python,performance,serial-port,baud-rate
You're going to give up some time when the direction of communication is reversed. So there's some "dead time" between when one side receives the last stop bit and when it loads the first response byte into the UART transmitter and starts driving the first start bit. I'm calculating that this dead time is 5 ms (almost 5 bit times, i.e. half a byte counting framing overhead) per two-way run, or 0.495 seconds of your 2.895 total seconds. This isn't bad, but it could be a little better. However, I'm not sure you'll get much improvement without writing your own UART driver. (This all assumes, of course, that the clocks both computers are using are crystal accurate. This isn't always true, since UARTs at 8N1 can tolerate up to about 2% clock difference between each end.) In embedded land, if we wanted to do this with absolute minimum bandwidth loss, we'd write the driver as a standard two-way full-duplex driver, with some way to know when to switch directions (e.g. on packet bounds). This driver would then only push bytes in the correct direction, leaving the other queue unused. At the user (application) level, we'd have to make sure those queues were never starved. That means that, in your example, the 13-byte response packet would need to be ready to go before the 10-byte incoming packet is fully received. The other end would need to do the same. With larger machines, the usual practice is to "coalesce" several packets in each direction and transmit them consecutively, so as to minimize the number of times that you have to change direction. This increases latency, though, and requires more memory, which could be a problem with a small microcontroller with only a couple kB of RAM. IMHO, given your small packets, frequent direction reversals, and lack of driver-level optimizations, that bandwidth looks about right.
0
0
0
1
2013-12-07T04:49:00.000
1
1.2
true
20,437,735
0
0
1
1
I am developing an application in Python that communicates to a device over RS-485 two wire, half-duplex. I have enough of the application working that I can perform some performance tests. I am using a laptop with a USB to 485 converter. The communications is setup as 9600,N,8,1. For my speed test I send a message with a total length of 10 bytes including the check byte. Then I wait for the reply of 13 bytes. I decode the reply as it is coming in. When the response is complete. I then send the next message. I repeat this 100 times as fast as possible. This takes 2.895 seconds. From this I calculate that I am transmitting/receiving 23 bytes * 100 iterations / 2.895 seconds = 794 bytes/s. If I understand it correctly serial port communication of 9600 N-8-1 has 1 start bit, 8 data bits and 1 stop bit. This means that it has a 2 bit overhead. So the actual theoretical transmission rate is (9600 bits / s) * (8 data bits / 10 transmission bits) * (1 Byte / 8 bits) = 960 bytes / s. My program is transmitting/receiving at a combined rate of 794 bytes/s out of a possible 960 bytes / s = 82.7%. Should I be able to achieve near 100% of the 960 bytes/s. Or is it typical to have this much bandwidth un-utilized?
How do I try and run code that I have written in ACE Cloud 9?
20,442,855
0
0
530
0
javascript,php,python,vbscript,cloud9-ide
You could possibly make a temporary file in your system, and in an iframe, open the file. Important Note This could be insecure as they could get the URL and execute code to delete ../../../ or something, which could harm your files.
0
0
0
1
2013-12-07T11:07:00.000
1
0
false
20,440,581
0
0
1
1
I am using ACE to allow people to code freely on my website. How would I run this code. I would like a run button in the bottom left corner (I can do that in css), but how would I run it, as it is python. I have added extra tags, as you can write these languages in the ace editor. When I mean, a run button, I mean like on codecademy, where you write some code, then it is submitted.
Disadvantages of using multiple apps django
20,473,908
6
2
373
0
python,django,django-apps
Divide et impera. This is one of the basic rule of programming. Divide your problem in smaller pieces and on the long run you will be happy: Code re-usability Maintenance Elegance? Also if you are working on an opensource project your main goal would be to find someone else who is interested in it and that could help you. It is easier to find someone interested in something really specific than to find someone who wants to adopt your super-huge app which does a lot of beautiful things that nobody else like.
0
0
0
0
2013-12-09T15:06:00.000
1
1.2
true
20,473,837
0
0
1
1
In django,What is the difference between creating multiple applications and using the same application and using all models and views in the same application? Will the latter create any problems?
How to add verbose name after a field in Admin - Django
20,495,156
3
1
597
0
python,django,verbose
you just need to go to. /admin/templates/admin/includes/fieldset.html template. Here you can see source code like. {% if field.is_checkbox %} {{ field.field }} {{ field.label_tag }} Just change code to : {% if field.is_checkbox %} {{ field.label_tag }} {{ field.field }} We put field.label_tag before field.field
0
0
0
0
2013-12-10T11:02:00.000
2
1.2
true
20,492,683
0
0
1
1
I have inserted a verbose name for a field in my models (Boolean Field) and when displaying in the admin, the checkbox is shown before the verbose name. How can I do so that the checkbox shows after the verbose name in the admin console?! Or is there another way of assigning a specific label to a field other than the fieldname so that it shows correctly in the admin? Thanks!
Which platform to use for fastest neo4j graph traversal?
20,512,703
5
0
208
0
java,python,performance,neo4j
In general, the fastest way to do traversals in neo4j is with the Java API. You might consider testing to see if it is fast enough before potentially prematurely optimizing. Try one of the python libraries w/ Cypher to see how it performs. If you do have to resort to the Java API, you can usually get away with writing a simple unmanaged extension (<50 lines of java/scala), and then call that from your python.
0
0
0
0
2013-12-11T06:48:00.000
1
0.761594
false
20,512,397
0
0
1
1
I have to do traversals on neo4j graph in real time. The graph contains around 200,000 nodes and 300,000 relationships. My main concern is that results should be super fast. Should I write the traversal algorithms in Java? Does Using python (py2neo or bulbflow) for the same has significant performance issues? My personal preference is for python here if performance is same for both python and java.
What would be the more practical uses for a Django application w/out a database?
20,525,176
1
0
70
0
python,django
I do not recommend using Django if you are not interested in using a database. Having written that disclaimer, if you insist on still using it, you can just scan over the documentation and identify what is still available to you if you do not have a database: You can use Django's security features to help protect against clickjacking, cross site request forgeries, etc. You can take advantage of Django's support for internationalization if you want to support multiple languages on your website. You can have Django handle validation of any forms you have on your website. ...basically you can create a static website that takes advantage of the rapid prototyping enabled by a framework built using Python.
0
0
0
0
2013-12-11T16:03:00.000
2
1.2
true
20,524,025
0
0
1
1
I recently got into Django out of curiosity after developing for quite a while w/ Ruby on Rails and Node.js, and found that it's splendid for working w/ databases. Django is primarily known for working with databases and every tutorial I've ever found on it has included databases. Django supports not requiring databases however, and, just out of curiosity since I'm still rather inexperienced w/ Django, what would be some practical uses w/ Django w/out requiring databases?
Run python program on windows 2008 server with web gui
20,571,773
0
0
143
0
python,python-2.7,windows-server-2008-r2
Yes, this is possible. However, you need to decouple execution of your programme from your web interface. Probably the simplest setup is to use supervisor to run both your program and your web interface. How your program and your web interface interact is up to you. You could even have your web interface control supervisor, or see if there is a third party web interface for supervisor.
0
0
0
0
2013-12-13T16:41:00.000
2
1.2
true
20,571,568
1
0
1
1
I have made this python (2.7) program that takes a few hours to complete, looping through stuff all the time. I also have a windows 2008 server which I want to use to run this program, I can run it just fine on its own and leave it alone for a while, but I want to use a web interface to achieve the same effect. I currently use cherrypy and made a form that submits to another page and executes the code there, which works somewhat, but when I close the browser the execution stops. What I really want to do is create a form that provides a function with some arguments and start a standalone python script from there, and possibly also include a stop button to stop the execution. Is this in any way possible?
Distribution Python package to Debian package with installing additional things
20,574,224
0
0
98
0
python,django,debian-packaging
How to install not only Django project, but also Python and Django with it? What and where and how should I write the script? If you created a deb file, as it gets interpreted, you should write the python dependency in the debian/control file. This project demand diffrent additions, such as grappelli, tinymce, filebrowser. Should I do anything with it? If this packages are in any repository (or your repository) then you can either, put them as recommendation or as suggestion in the control file.
0
0
0
0
2013-12-13T19:04:00.000
1
0
false
20,574,073
1
0
1
1
I have a Django project needed to be installed in Debian. I make packages via stdeb. I do not understand two things, on which I can`t find answers: How to install not only Django project, but also Python and Django with it? What and where and how should I write the script? This project demand different additions, such as grappelli, tinymce, filebrowser. Should I do anything with it?
How do I unlock the app engine database when localhost runs?
20,578,822
9
7
3,369
0
python,google-app-engine,localhost,google-cloud-datastore
This can happen if you're running multiple instances of dev_appserver without giving them distinct datastore files/directories. If you need to be running multiple instances, see dev_appserver.py --help and look at the options for specifying paths/files.
0
1
0
0
2013-12-14T01:42:00.000
4
1
false
20,578,757
0
0
1
2
Right now I get a blank page when localhost runs, but the deployed app is fine. The logs show the "database is locked". How do I "unlock" the database for localhost?
How do I unlock the app engine database when localhost runs?
59,824,595
0
7
3,369
0
python,google-app-engine,localhost,google-cloud-datastore
So with your command to start the server which should be start_in_shell.sh -f -p 8xxx -a 8xxx do include a -s flag after the -f as below: start_in_shell.sh -f -s -p 8xxx -a 8xxx Sometimes some unanticipated error somewhere causes this issue. Remember to keep only one of the instances with this flag(-s) and others should be started as you do usually. This should make it work.
0
1
0
0
2013-12-14T01:42:00.000
4
0
false
20,578,757
0
0
1
2
Right now I get a blank page when localhost runs, but the deployed app is fine. The logs show the "database is locked". How do I "unlock" the database for localhost?
How suitable is opting for RethinkDB instead of traditional SQL for a JSON API?
20,600,546
14
11
2,835
1
python,sql,database,nosql,rethinkdb
I'm working at RethinkDB, but that's my unbiased answer as a web developer (at least as unbiased as I can). Flexible schema are nice from a developer point of view (and in your case). Like you said, with something like PostgreSQL you would have to format all the data you pull from third parties (SoundCloud, Facebook etc.). And while it's not something really hard to do, it's not something enjoyable. Being able to join tables, is for me the natural way of doing things (like for user/userArtist/artist). While you could have a structure where a user would contain artists, it is going to be unpleasant to use when you will need to retrieve artists and for each of them a list of users. The first point is something common in NoSQL databases, while JOIN operations are more a SQL databases thing. You can see RethinkDB as something providing the best of each world. I believe that developing with RethinkDB is easy, fast and enjoyable, and that's what I am looking for as a web developer. There is however one thing that you may need and that RethinkDB does not deliver, which is transactions. If you need atomic updates on multiple tables (or documents - like if you have to transfer money between users), you are definitively better with something like PostgreSQL. If you just need updates on multiple tables, RethinkDB can handle that. And like you said, while RethinkDB is new, the community is amazing, and we - at RethinkDB - care a lot about our users. If you have more questions, I would be happy to answer them : )
0
0
0
0
2013-12-15T17:37:00.000
1
1.2
true
20,597,590
0
0
1
1
I am building the back-end for my web app; it would act as an API for the front-end and it will be written in Python (Flask, to be precise). After taking some decisions regarding design and implementation, I got to the database part. And I started thinking whether NoSQL data storage may be more appropriate for my project than traditional SQL databases. Following is a basic functionality description which should be handled by the database and then a list of pros and cons I could come up with regarding to which type of storage should I opt for. Finally some words about why I have considered RethinkDB over other NoSQL data storages. Basic functionality of the API The API consists of only a few models: Artist, Song, Suggestion, User and UserArtists. I would like to be able to add a User with some associated data and link some Artists to it. I would like to add Songs to Artists on request, and also generate a Suggestion for a User, which will contain an Artist and a Song. Maybe one of the most important parts is that Artists will be periodically linked to Users (and also Artists can be removed from the system -- hence from Users too -- if they don't satisfy some criteria). Songs will also be dynamically added to Artists. All this means is that Users don't have a fixed set of Artists and nor do Artists have a fixed set of Songs -- they will be continuously updating. Pros for NoSQL: Flexible schema, since not every Artist will have a FacebookID or Song a SoundcloudID; While a JSON API, I believe I would benefit from the fact that records are stored as JSON; I believe the number of Songs, but especially Suggestions will raise quite a bit, hence NoSQL will do a better job here; for SQL: It's fixed schema may come in handy with relations between models; Flask has support for SQLAlchemy which is very helpful in defining models; Cons for NoSQL: Relations are harder to implement and updating models transaction-like involves a bit of code; Flask doesn't have any wrapper or module to ease things, hence I will need to implement some kind of wrapper to help me make the code more readable while doing database operations; I don't have any certainty on how should I store my records, especially UserArtists for SQL: Operations are bulky, I have to define schemas, check whether columns have defaults, assign defaults, validate data, begin/commit transactions -- I believe it's too much of a hassle for something simple like an API; Why RethinkDB? I've considered RehinkDB for a possible implementation of NoSQL for my API because of the following: It looks simpler and more lightweight than other solutions; It has native Python support which is a big plus; It implements table joins and other things which could come in handy in my API, which has some relations between models; It is rather new, and I see a lot of implication and love from the community. There's also the will to continuously add new things that leverage database interaction. All these being considered, I would be glad to hear any advice on whether NoSQL or SQL is more appropiate for my needs, as well as any other pro/con on the two, and of course, some corrections on things I haven't stated properly.
Web page building with python 3.3?
20,601,999
0
2
104
0
python,web,wsgi
It will be hard, between python2 and python3 there is a lot of incompatibility, and somehow the developers of the most python frameworks somehow won't understand, why they should port their software to the newer version of the language. The simplest way if you use python 2. The best way were to start an independent, python 3 fork of your most loved python framework. EDIT: newer django supports python3, thus it should work.
0
0
0
0
2013-12-16T00:55:00.000
2
0
false
20,601,898
0
0
1
1
I am going through a tutorial on building a website with django. It suggests using mod_python but I have heard to stay away from that and use wsgi instead. Problem is I am running python 3.3 (and apache 2.4.2 for that matter, everything seems to be compatible with apache 2.2). Is there any way to get all of this working on 3.3? Or is my best bet to go back to python 2.7? Thanks. Edit: I am on Windows, so that seems to be another roadblock.
Validation when displaying already existing element
20,622,467
1
0
31
0
python,django
Errors are shown for the "data" parameter ( or instance if it's a modelform ), not "initial". You need to pass the original values as the data parameter if you want to display errors. And then just use the usual validation methods ( raising ValidationError in clean_* methods , field specific validation, etc. ). I wouldn't mess up with the error dictionary, it's an internal API.
0
0
0
0
2013-12-16T13:04:00.000
2
1.2
true
20,611,656
0
0
1
1
When editing an already existing element in Django, I would like to show ValidationErrors for fields that are not good (because somewhere else something changed). I've tried to overload the __init__ of the form and set form_obj.errors['__all__']="something" but it doesn't display any errors. How should I approach this?
I want to locate the specific building the user is in. Should I use html5 geolocation or build my own custom map?
20,619,667
1
0
213
0
python,html,google-app-engine,geolocation,gps
How precise HTML5 geolocation is depends entirely on what the user's browser supports. On a phone, it may have access to the phone's idea of the user's location (based on GPS plus cell and WiFi triangulation); on a desktop machine, there's little to go on besides IPs, so it can't do any better than you could do yourself. But either way, the user may have disabled or limited it (or it may be disabled or limited by default for him). Or may be using a browser that doesn't support HTML5 locations. Or may be using an add-on that fuzzes or flat-out lies about location. So: is that precise enough to pinpoint buildings? It can be. Or is building my own map with customized coordinates a better option? How would that help? If you don't know the coordinates the user is at, you have nothing to look up on the map.
0
0
1
0
2013-12-16T19:44:00.000
1
0.197375
false
20,619,533
0
0
1
1
I'm building a web app with google app engine and python. I've read that html5 geolocation is much more precise than IP geolocation, but is that precise enough to pinpoint buildings? Or is building my own map with customized coordinates a better option?
How to I determine whether a character is valid-for/rendered-in html?
20,629,430
0
1
120
0
python,html
What is a valid character in HTML depends on your definition for “HTML” and “valid”. Different HTML versions have different rules for formally valid characters, and they may have characters that are valid but not recommended. Moreover, there are general policies such as favoring Normalization Form C; though not part of HTML specifications, such policies are often regarded as relevant to HTML, too. What is rendered (and how) depends on the browser, the style sheets of the HTML document, and available fonts in the user’s computer. Moreover, not all characters are rendered as such. For example, in normal HTML content, any contiguous sequence of whitespace characters is treated as equivalent to a single space character. So the answer is really “It depends.” Consider asking a much more targeted practical question to get a more targeted answer.
0
0
1
0
2013-12-17T07:58:00.000
2
0
false
20,628,825
0
0
1
1
Some characters, such as ordinal 22 or 8, don't display in html (using chrome, for example when copy-and-pasting them into this 'Ask question' editor; I am assuming utf-8). How do I determine which characters are valid html, and of the valid, which are rendered? A table/reference would be helpful (I couldn't find one by google-ing), but preferably I need a set of rules or a solution that can be implemented in python.
How to structure backend of a fantasy sports analytics website on Django?
20,646,874
3
2
1,392
0
python,database,django,model-view-controller,analytics
There isn't a right answer to this question. Different programmers use different structures. We can, however, provide advice. Your project will definitely have a core application, in charge of users and account management. All common functionality should be provided by this app. Login/logout/recovery functions fall into this category, and so do high-scores, history, friends, etc. Do that first. When it's working, you'll most likely want to implement leagues as different apps. The logic driving each sport is different, so it makes sense to keep it separate, and mount it in separate URL paths. All of these apps will, and should, depend heavily on the core. Fair warning: you'll probably find yourself repeating patterns when implementing each app. Some of these patterns you can migrate safely to the core, but some others will look the same but be just different enough to warrant their own code. Implement first, find common ground, abstract last. This architecture will let you enable and disable leagues, as well as push league-specific upgrades, with little to no hassle. You can work on different leagues without the fear of breaking stuff elsewhere. In other words, you have the right initial approach. Work on it, make mistakes, learn, refactor, abstract. Trying to get it perfect on the first try will only slow you down.
0
0
0
0
2013-12-17T23:25:00.000
1
1.2
true
20,646,758
0
0
1
1
I'm looking to make an analytics fantasy sports site and I need a little help thinking how to structure the site as a whole. It's most definitely been done before but I'm doing this for educational purposes and because this is a hobby of mine! The idea for the site is: Users can create an account It'll use the Yahoo/ESPN API to draw their individual league data (rosters, stats, etc) Each user account can be linked with multiple leagues across many sports (i.e. 2x bball leagues, 1x football, 1x baseball) The website will perform certain analytics based on the sport, and type of league they are playing in (h2h or roto). Going through the django tutorial, I realized that they not only use a mvc approach but also make a distinction between project and app. My question is: How do I structure the backend of the website? Does each sport get it's individual app? What about each type of league? And finally, does the "log-in / account creation" get an app of it's own as well? It spans across all the fantasy sports. Just a little confused, as it's my first time creating a website like this. Similarly, I understand that I should just take it one step at a time, but I just want to get a good understanding of the overall vision
Is using django auth Group the right way to solve this?
20,653,824
0
2
144
0
python,django,usergroups
You can make an many-to-many relationship between users, groups and classrooms (additional model that will point to these three models, giving group for user in specified classroom)
0
0
0
0
2013-12-18T01:34:00.000
1
0
false
20,648,128
0
0
1
1
A little background: I am building a discussion board app aimed at educators. It's essentially a reddit-style discussion board where responses to a prompt are 'up-voted' or 'down-voted'. The content creators are anonymous to everyone except an admin/teacher user. So far it works for a single "classroom"; i.e., there can be one or more admins, one or more students, but so far there is only one "classroom". All the students will see the same discussion threads. My Problem: I want to expand it so that there can be 'unlimited' classrooms and that any teacher who is interested in using the service can create a group and add students (manually, or by way of some token, etc). I also want students to be able to participate in one or more groups. It seems that refactoring the models slightly to have a foreign key to django.contrib.auth.models.Groupshould make this possible, but I am not sure if this is what Group is designed to do. At first blush Group and the related Permission look a lot more like the Unix groups metaphor. What I am looking for is a way to have a teacher-user to create a group and to have a student-user join this group and view and create group-specific content. Am I headed in the right direction? Is there a much better way to accomplish what I am trying to do?
Install Scrapy for Python 2.6
22,181,034
0
2
1,711
0
python,scrapy,python-2.6
easy_install Scrapy==0.18.4 worked for me
0
0
0
0
2013-12-18T06:55:00.000
2
0
false
20,651,529
1
0
1
1
I am using CentOS and my default Python version is 2.6. I installed Scrapy using pip install Scrapy and I executed the code below from scrapy.selector import Selector And I got this message: Scrapy 0.20.2 requires Python 2.7. I can't just upgrade my current version of Python because I have lots of programs that depends on it. If possible, I would like to install the correct version of Scrapy on my Python 2.6.
Implementing session-like storage in python application
20,670,147
1
1
375
0
python,authentication
If you're using Unix, rely on the fact that it's a multi user system. That is, the user has already logged in using his own credentials, so you don't need to do anything, just use its home directory to store the data, taking care to block other users from accessing it by using permissions. You can improve this to provide encryption too. For global application data, you can specify a "manager" user or group, with its own directory, where the application can write. All this might be possible on Windows systems too.
0
0
0
0
2013-12-18T21:54:00.000
3
0.066568
false
20,669,240
0
0
1
3
I will keep it short. Can someone please point me in the right direction in: How to authenticate users in native applications written in Python? I know in web there are sessions, but I can't think of a way to implement authentication, that will 'live' for some time and on expiry I can logout the user? EDIT: I am referring to desktop type of apps, I am fairly happy with the implementation for Web based development in Twisted EDIT 2 The application I am thinking about will not authenticate against a server, but a self-contained application, an example the idea is a Cash Register/Point of Sale (my idea is kinda different, but parts of the functionality is the same), in which I need to authenticate the cashier, so I can log the transactions processed by him/her, print name on receipt and etc. All will be based in one single machine, no server communication or anything
Implementing session-like storage in python application
20,669,715
1
1
375
0
python,authentication
You seem to be very confused and fixated on "sessions" for some reasons, maybe because your background is in the web apps? Any-who you don't need "sessions" because with desktop application you have no trouble telling who is using the software without needing some elaborate tools. You don't need server, you don't need authentication tools, you don't need anything - just store that user within your single application. That is all really - a variable within your application called "user" and maybe some interface at the boot to pick one from available users. And if you need it to last between boots, just save it in a file and read from it.
0
0
0
0
2013-12-18T21:54:00.000
3
0.066568
false
20,669,240
0
0
1
3
I will keep it short. Can someone please point me in the right direction in: How to authenticate users in native applications written in Python? I know in web there are sessions, but I can't think of a way to implement authentication, that will 'live' for some time and on expiry I can logout the user? EDIT: I am referring to desktop type of apps, I am fairly happy with the implementation for Web based development in Twisted EDIT 2 The application I am thinking about will not authenticate against a server, but a self-contained application, an example the idea is a Cash Register/Point of Sale (my idea is kinda different, but parts of the functionality is the same), in which I need to authenticate the cashier, so I can log the transactions processed by him/her, print name on receipt and etc. All will be based in one single machine, no server communication or anything
Implementing session-like storage in python application
20,669,948
1
1
375
0
python,authentication
It’s not entirely clear what kind of security you are expecting. In general, if the end user has physical access to the machine and a screwdriver, you’re pretty much screwed—they can do whatever they want on that machine. If you take hardware security as a given, but want to ensure software security, then you’re going to have to do server communication within the machine’s boundaries. You have to separate the server and the client, and run the server in a security context that is inaccessible to the user. The server will then do both the authentication and whatever operations need authentication (printing out receipts etc.). For example, under a Unix-like OS, you would run a daemon under a dedicated system user or under root; on Windows, you would have a system service running as LOCAL SERVICE or whatever that’s called. In this way, the operating system’s built-in security features will ensure (given proper maintenance, like timely application of security hotfixes) that the user cannot influence the behavior of the software that does the sensitive operations. The protocol between the client and the server can be anything, and you can do authentication in much the same way as in HTTP—indeed, you may even use HTTP itself. Finally, if you’re certain that your users will not be tampering with your system at all—e.g. because they lack the technical skills, or are being watched by CCTV cameras—you can forget all that stuff and go with Puciek’s answer.
0
0
0
0
2013-12-18T21:54:00.000
3
1.2
true
20,669,240
0
0
1
3
I will keep it short. Can someone please point me in the right direction in: How to authenticate users in native applications written in Python? I know in web there are sessions, but I can't think of a way to implement authentication, that will 'live' for some time and on expiry I can logout the user? EDIT: I am referring to desktop type of apps, I am fairly happy with the implementation for Web based development in Twisted EDIT 2 The application I am thinking about will not authenticate against a server, but a self-contained application, an example the idea is a Cash Register/Point of Sale (my idea is kinda different, but parts of the functionality is the same), in which I need to authenticate the cashier, so I can log the transactions processed by him/her, print name on receipt and etc. All will be based in one single machine, no server communication or anything
Prevent creating of expensive object on each request
20,676,165
0
3
56
0
python,python-2.7,web.py
Assuming your application is served by a long running process (as opposed to something like plain CGI), AND your database is never updated, you always have the option to instantiate your Object_X at the module's top-level (making it a global), so it will only be created once per process. Now it means that you'll have some overhead on process start, and that you'll have to restart all your processes everytime your db is updated. The real question IMHO is why do you want to load all your db right from the start ? If that's for "optimization" then there might be better tools and strategies (faster db, caches etc).
0
0
1
0
2013-12-19T04:07:00.000
2
0
false
20,673,260
0
0
1
1
I have an object which loads all the data from DB Object_X. This object has a few methods defined. I pass some parameter and based on parameter I call one of the functions in Object_X, it uses pre-populated data in object and parameter to get some result. I have created a web service which invokes any method defined in Object_X and returns a result. My problem is that for every request I am loading all the data from db again and again which is time consuming. Is there a way that I can load the data one time when I start a server and uses the same object for each subsequent request?
Is this possible - Python script to fill a Google spreadsheet?
50,629,830
0
0
3,149
1
python,google-sheets
Yes, it is possible and this is how I am personally doing it so. search for "doGet" and "doPost(e)
0
0
0
0
2013-12-19T22:45:00.000
3
0
false
20,693,168
0
0
1
1
I dont even know if this is possible. But if it is, can someone give me the broadstrokes on how I can use a Python script to populate a Google spreadsheet? I want to scrape data from a web site and dump it into a google spreadsheet. I can imagine what the Python looks like (scrapy, etc). But does the language support writing to Google Drive? Can I kick off the script within the spreadsheet itself or would it have to run outside of it? Ideal scenario would be to open a google spreadsheet, click on a button, Python script executes and data is filled in said spreadsheet.
CGI with Python2.7
20,701,061
0
0
326
0
python,http,webserver,cgi
To use it as CGI you must move your script into cgi-bin or similar directory of HTTP server. Then point your browser into http://127.0.0.1/cgi-bin/my_scipt.py and see results. In case of problems see at HTTP server error log. In case of strange errors show us what HTTP server and OS you use, example "Apache 2.2 on WinXP".
0
0
0
1
2013-12-20T09:50:00.000
1
1.2
true
20,700,738
0
0
1
1
Am using python2.7. My task is to create a web page say login screen in browser using python. I tried CGI. My code is showing HTML file(all the html code from to ) in CMD screen. Whereas i want them in browser as web page. Any help?.
Data truncated for column 'temp' at row 1
20,712,349
1
0
2,106
1
python,mysql,database,django,amazon-ec2
Your column is only 2 chars wide, but you are trying to store the strings 'HIGH', 'MEDIUM', 'LOW' from your TEMP choices (the first value of each tuple is saved in the database). Increase max_length or choose different values for choices, e.g. TEMP = ( ('H', 'High'), ('M', 'Medium'), ('L', 'Low'), ). It worked fine in SQLite because SQLite simply ignores the max_length attribute (and other things).
0
0
0
0
2013-12-20T21:24:00.000
2
1.2
true
20,712,174
0
0
1
1
i have deployed a simple Django application on AWS. The database i use is MySQL. Most parts of this application runs well. But there happens to be a problem when i submitted a form and store data from the form into a model. The error page presents Data truncated for column 'temp' at row 1. temp is a ChoiceField like this: temp = forms.ChoiceField(label="temperature", choices=TEMP), in the model file the temp is a CharField like this temp = models.CharField(max_length=2, choices=TEMP). The error happens at .save(). How can i fix this problem? Any advice and help is appreciated. BTW, as what i have searched, the truncation problem happens because of data type to be stored in database. But i still cannot figure out how to modify my code.
Add variable in HtmlXPathSelector select function
20,721,196
1
0
145
0
python,scrapy
Use str.format to insert variable value into xpath expression: sel.select('//a[contains(@href, "{0}")]/@href'.format(url_type)).extract()
0
0
1
0
2013-12-21T16:35:00.000
1
1.2
true
20,721,145
0
0
1
1
Instead of "rss", I want to add a global variable to it. So that I don't have to change it again and again. sel.select('//a[contains(@href, "rss")]/@href').extract() to something like this: sel.select('//a[contains(@href, url_type)]/@href').extract()