|
Lumpy posted:No, i mean use the request.set_cookie("key", "value", 1000) method to set a cookie so I can read it in the future. Or is there some other way to do that? Uh, you can literally do this in any method in a CBV. They all have access to the request object either through `request` or `self.request`, depending on the method's args. I'd probably do it in `get()` or `post()`.
|
# ? May 22, 2013 21:48 |
|
|
# ? Jun 5, 2024 06:58 |
|
MonkeyMaker posted:Uh, you can literally do this in any method in a CBV. They all have access to the request object either through `request` or `self.request`, depending on the method's args. sorry.. I'm dumb.. set_cookie() is on response, not request. But my question still stands. \/\/ Thank you. I figured it was something that simple, but I could not for the life of me divine how to do it. Lumpy fucked around with this message at 13:43 on May 23, 2013 |
# ? May 23, 2013 03:12 |
|
It really just depends on the functionality you need. You can pretty much do it wherever, but I personally dislike overriding dispatch/get/post so I usually don't unless I have to. Here are a couple of examples: https://gist.github.com/anonymous/33cc0f8dfdc860e91213. Needless to say you could write a mixin or the like for this functionality but the simplistic (if inelegant) approaches there should work. entr0py fucked around with this message at 05:19 on May 23, 2013 |
# ? May 23, 2013 05:11 |
|
Is there any pre-packaged easy way to emulate the heroku experience to some degree on a shared host like Dreamhost? I've got a couple projects that are a long way from being worth paying any money to host on Heroku, but it would be sweet if I could just git push them or something to Dreamhost and not worry about getting/updating requirements and the like...
|
# ? May 23, 2013 18:57 |
|
Thermopyle posted:Is there any pre-packaged easy way to emulate the heroku experience to some degree on a shared host like Dreamhost? I've got a couple projects that are a long way from being worth paying any money to host on Heroku, but it would be sweet if I could just git push them or something to Dreamhost and not worry about getting/updating requirements and the like... Write some simple Fabric scripts?
|
# ? May 23, 2013 21:51 |
|
Thermopyle posted:Is there any pre-packaged easy way to emulate the heroku experience to some degree on a shared host like Dreamhost? I've got a couple projects that are a long way from being worth paying any money to host on Heroku, but it would be sweet if I could just git push them or something to Dreamhost and not worry about getting/updating requirements and the like... If it's not a super serious app why not run it on Heroku's free tier? edit: as an alternative Fabric scripts or setting poo poo under saltstack/puppet/chef would work, with saltstack being my new favorite hotness. deimos fucked around with this message at 21:58 on May 23, 2013 |
# ? May 23, 2013 21:55 |
|
MonkeyMaker posted:Write some simple Fabric scripts? Yeah, I guess this is what I'm going to do. I was just wondering if there was anything else. deimos posted:If it's not a super serious app why not run it on Heroku's free tier? I'm already using my free tier for another toy project and I was just considering alternatives to setting up another heroku account. Maybe I'll check out saltstack...
|
# ? May 23, 2013 22:59 |
|
Thermopyle posted:Yeah, I guess this is what I'm going to do. I was just wondering if there was anything else. you can't ever "use [your] free tier", it's free per app.
|
# ? May 23, 2013 23:13 |
|
MonkeyMaker posted:you can't ever "use [your] free tier", it's free per app. D'oh!
|
# ? May 23, 2013 23:20 |
|
Thermopyle posted:D'oh! Seriously? That's amazing.
|
# ? May 24, 2013 04:31 |
|
MonkeyMaker posted:Write some simple Fabric scripts? This. There's lots of solutions out there to do things manually, and their worth investigating if you want to control deployment a bit more. By the way, MonkeyMaker, thanks to your GSWD intro I'm making a push to start using Vagrant. Makes so much sense especially for some of my bigger stuff where there's Celery, Rabbitmq, PDF renderers and all sorts to install, virtualenv by itself isnt enough to handle dependencies really. however for me your chef cookbooks are straight out not working for me at the moment, evern trying to replace them with cookbooks from Opscode's site. Is the Chef gem's API out of step with some of the Cookbooks or something? Might have a look into using Puppet instead, at the moment I just have a page long shell script that's doing the trick, but I know in bigger setups I want something a little more expressive.
|
# ? May 24, 2013 05:35 |
|
bonds0097 posted:Seriously? That's amazing. I know, I'm terrible sometimes.
|
# ? May 24, 2013 05:37 |
|
Maluco Marinero posted:Might have a look into using Puppet instead, at the moment I just have a page long shell script that's doing the trick, but I know in bigger setups I want something a little more expressive. Risking repeating myself, saltstack is really really really growing on me to program infrastructure, it's not super mature but it's being developed at breakneck speed, if you're ditching chef for something try saltstack. And there's this.
|
# ? May 24, 2013 18:42 |
|
Maluco Marinero posted:This. There's lots of solutions out there to do things manually, and their worth investigating if you want to control deployment a bit more. My cookbooks haven't kept up with Vagrant and VirtualBox releases because I'm horrible at this support thing. I've been working on them but I haven't had time to actually get them all sorted out. From what I've heard, though, making the cookbooks install Ruby 1.9 instead of 1.8 fixes a lot of the problems.
|
# ? May 24, 2013 20:01 |
|
Is Getting started with Django a good place to learn? Is there a trick to viewing answers on their forums? I get an error at the beginning, when running vagrant up. (ArgumentError: wrong number of argumnets) There are a number of posts about this on the front page of the forum, but the replies/answers are not loading, only the question. Example. Any ideas?
Dominoes fucked around with this message at 03:36 on Jun 2, 2013 |
# ? Jun 2, 2013 03:31 |
|
Dominoes posted:Is Getting started with Django a good place to learn? Is there a trick to viewing answers on their forums? I get an error at the beginning, when running vagrant up. (ArgumentError: wrong number of argumnets) There are a number of posts about this on the front page of the forum, but the replies/answers are not loading, only the question. Example. Any ideas? MonkeyMaker can confirm that it's a terrible place. I kid! He's the person behind GSWD I haven't actually done any of the GSWD stuff yet, but I hear good things. Be sure you also go through the official Django tutorial.
|
# ? Jun 2, 2013 03:53 |
|
Dominoes posted:Is Getting started with Django a good place to learn? Is there a trick to viewing answers on their forums? I get an error at the beginning, when running vagrant up. (ArgumentError: wrong number of argumnets) There are a number of posts about this on the front page of the forum, but the replies/answers are not loading, only the question. Example. Any ideas? I don't think it's a good way to start. Its reliance on the Vagrant stuff is unfortunate because you'll probably get stuck there due to mismatch in Ruby/Chef versions. You'll basically be defeated before you even start messing around with Django. :p Instead, I would recommend the following: - Follow the official Django Tutorial here: https://docs.djangoproject.com/en/dev/intro/tutorial01/ - Get this awesome book full of best practices: Two Scoops of Django - https://django.2scoops.org/ - Try a more involved tutorial like this one at NetTuts: http://net.tutsplus.com/tutorials/python-tutorials/building-ribbit-with-django/ - Get the basics of Vagrant/Chef here: http://blog.smalleycreative.com/tutorials/setup-a-django-vm-with-vagrant-virtualbox-and-chef/ At that point, I think you could try the GSWD tutorial and actually be able to troubleshoot the issues with Vagrant/Chef yourself (as long as your google is good). And you can reference Two Scoops throughout GSWD and the NetTuts stuff to get some additional perspective and apply principles and practices. Honestly, I would avoid the 'precise64' and 'precise32' Vagrant boxes like the plague. Instead, get this box: https://dl.dropboxusercontent.com/u/165709740/boxes/precise64-vanilla.box and then manually 'sudo apt-get ruby1.9.1' and 'gem install chef' yourself. That ensures you don't have outdated Ruby/Chef on the VM. EDIT: Note, I think the GSWD tutorial itself is pretty great. The infrastructure is just lacking. That said, it covers cool stuff like the use of virtual environments, splitting settings files between dev/prod (though it employs the anti-pattern of leaving local settings out of version control, which is a questionable practice), using South for Database migrations, etc. bonds0097 fucked around with this message at 04:01 on Jun 2, 2013 |
# ? Jun 2, 2013 03:59 |
|
I'm developing a stupid web based RPG and I've hit a small wall. What is the best way to rate limit form submissions to prevent dudes from rapid-fire clicking the "FIGHT A MONSTER" button?
|
# ? Jun 2, 2013 23:44 |
|
bonds0097 posted:I don't think it's a good way to start. Its reliance on the Vagrant stuff is unfortunate because you'll probably get stuck there due to mismatch in Ruby/Chef versions. You'll basically be defeated before you even start messing around with Django. :p Someone just posted an identical problem to to mine on the getting started with Django forum - He has vagrant up issues, sees multiple threads about it with answers, but can't see the answers. Dominoes fucked around with this message at 00:15 on Jun 3, 2013 |
# ? Jun 3, 2013 00:07 |
|
You should invest in the overhead of getting Vagrant up and running if you're serious about doing any substantial Django development. It's an amazing tool and will really change the way you treat your dev environments. I also love projects that distribute a Vagrantfile and some simple cookbooks in their repos to get you up and running with dependencies. If you have a functioning Vagrant installation you can get going in no time. That said, Vagrant's usability on Windows has only recently gotten really stable from what I've heard so if you're running things from a Windows host you still might have some bumps.
|
# ? Jun 3, 2013 05:28 |
|
Dominoes posted:Is Getting started with Django a good place to learn? Is there a trick to viewing answers on their forums? I get an error at the beginning, when running vagrant up. (ArgumentError: wrong number of argumnets) There are a number of posts about this on the front page of the forum, but the replies/answers are not loading, only the question. Example. Any ideas? Since I don't have SSL on the site, maybe try dropping the 's' on the URL? Works for me. As for the Vagrant issues, I'm aware of them, just haven't had time to test and release an update to the Chef recipes. I'm told it's as simple as updating Ruby to 1.9 instead of 1.8. EDIT: Those of you that don't like the reliance on Vagrant, are you volunteering to answer all the "how do I set this up on Windows" questions?
|
# ? Jun 3, 2013 06:25 |
|
MonkeyMaker posted:Since I don't have SSL on the site, maybe try dropping the 's' on the URL? Works for me.
|
# ? Jun 3, 2013 18:45 |
|
MonkeyMaker posted:Since I don't have SSL on the site, maybe try dropping the 's' on the URL? Works for me. Hey shout me out on irc if you want help with the Chef/Vagrant stuff. (I'm etc/drank on there)
|
# ? Jun 4, 2013 04:55 |
|
Lorcrimes posted:I'm developing a stupid web based RPG and I've hit a small wall. What is the best way to rate limit form submissions to prevent dudes from rapid-fire clicking the "FIGHT A MONSTER" button? Quoting this because I'm working with him on the project and would also like to know the best way to approach this -- even if it is just "read about jquery" or whatever would be most reasonable. However, I also have a question regarding some model definitions I'm doing for this thing too. Currently, we have a hero model that looks like this (ignore all of the math, we haven't worked any of the actual game mechanics out and the comments are just reminders for the dummy combat script we are working on.): code:
code:
In addition to not knowing if it is necessary or a good idea in practice to write out possible exploits like this at the database level, I also have absolutely no idea how I would even make it so that a field can only have exactly n objects in it at maximum. So the actual question I'm asking here is how would I do that, even if it isn't really totally necessary I'd still like to know what the deal is. You can just point me to docs or a term to search stack overflow for or something, I tried googling it but I'm still pretty new to all of this so I fall short on terminology sometimes and miss really obvious answers.
|
# ? Jun 5, 2013 01:22 |
|
Dominoes posted:Thanks. I'm going to take your advice and stick with the official tutorial for now, which doesn't require extra software. I tried the smalley link in your post, and it also gives me a vagrant up error (although a different one). I'll try Two Scoops and NetNuts after finishing the default ones. This is a lot more complicated than I thought! (it looks like it's more complicated than Python itself.) I'm working with MonkeyMaker to provide a fully compatible package you can use but if you want to use his VM download from the first lesson as he describes it you can just comment out line 41 of the Vagrantfile and bring up the VM. You may have to remove your old VM from Virtualbox, or you can just move out the .vagrant stuff in the directory if you don't care about having an orphaned VM sitting on your machine. For the curious, the Vagrantfile was upgrading Chef to a version that breaks with 1.8.x. If you just provision your box with that box's built in version of Chef it will come up fine.
|
# ? Jun 5, 2013 03:52 |
|
The March Hare posted:RPG hero database stuff I'm new with Django and everything myself so someone else please correct me if I'm wrong but I think the term that might help with stack overflow/google searches is "database integrity". I think you should be fine with a custom model save method that unequips all items in the slot before equipping the new item and saving to the db. Another option would be to pass an Error if the slot was occupied but that's really up to your user interface preferences. Short of a user completely circumventing your Django implementation and editing the database directly I'm not sure how they could get around the save() method. In my dumb side projects I may write some tests to make sure any custom saves are correctly called and execute but that's it.
|
# ? Jun 5, 2013 04:12 |
|
etcetera08 posted:I'm working with MonkeyMaker to provide a fully compatible package you can use but if you want to use his VM download from the first lesson as he describes it you can just comment out line 41 of the Vagrantfile and bring up the VM. You may have to remove your old VM from Virtualbox, or you can just move out the .vagrant stuff in the directory if you don't care about having an orphaned VM sitting on your machine.
|
# ? Jun 5, 2013 04:21 |
|
Dominoes posted:Awesome. I'm still getting the wrong number of arguments error after editing the Vagrantfile. I'm going to finish the official Django tutorial first, then dive into GSWD. Ah, ok, I'll keep looking into it. Should have an update tomorrow. EDIT: Works for me with only that slight edit. Should be running Chef client 10.14.2. You're probably still trying to provision the VM that already upgraded its own Chef install. Before it crashes out what do your equivalent lines to these say? My guess is that it will say Chef 11.xx. code:
etcetera08 fucked around with this message at 06:10 on Jun 5, 2013 |
# ? Jun 5, 2013 06:01 |
|
A puzzling problem here: I'm using Django CMS (Django v1.4.5, Django-CMS v2.3.5, Python v2.7.3 on Ubuntu) and have a template with two placeholders. I create a page based on that template, fill-in and save both parts. When I go to save the page, I get the dialog: quote:Not all plugins are saved. Are you sure ... Although both placeholders are labelled above as "Plugin saved successfully". Even if you hit "OK" at this point, the page doesn't save. So this is a bit of head scratcher. Any pointers where I should look?
|
# ? Jun 7, 2013 13:30 |
|
etcetera08 posted:Ah, ok, I'll keep looking into it. Should have an update tomorrow.
|
# ? Jun 7, 2013 17:21 |
|
Dominoes posted:Correct. Chef 11.4.4 So, that's your problem. Go in and delete the VM from Virtualbox and then remove all .vagrant artifacts (I think it will be a directory for your version of Vagrant). Then do `vagrant up` again and you should be golden.
|
# ? Jun 7, 2013 23:25 |
|
etcetera08 posted:So, that's your problem. Go in and delete the VM from Virtualbox and then remove all .vagrant artifacts (I think it will be a directory for your version of Vagrant). Then do `vagrant up` again and you should be golden.
|
# ? Jun 8, 2013 00:18 |
|
I successfully ran Vagrant up, installed Putty, and successfully (I think) entered Vagrant with SSH, ran 'sudo ./postinstall.sh'. It seemed to complete, with a few messages about not being able to delete directories. Based on going ahead at this point and things not working in the steps after, I think the note on the GSWD page about not seeing shared folders applies. (Was running sudo ./postinstall.sh supposed to dump some files/folders in my directly that has Cheffile and Vagrantfile?) I followed the steps of exiting the SSH, and running 'vagrant halt' and 'vagrant up' from a non-putty terminal. When I ran vagrant up, it showed chef-11.4.4. again, and errored out with 'wrong number of arguments' as before.
Dominoes fucked around with this message at 16:22 on Jun 8, 2013 |
# ? Jun 8, 2013 01:34 |
|
I have a model that has a few foreign keys in it. I'd like the ListView for this model to contain simple dropdown filters for these foreign keys, so users can restrict what appears in the list depending on their selection. I've been searching for the best/simplest way to to do this but there seem to be many different ideas and approaches. Can anyone recommend a good package to use for this? I've found django-filter which looks like it provides what I need. What's the consensus on django-filter?
|
# ? Jun 9, 2013 10:11 |
|
App I'm working on now (on Heroku) will be re-hosting images from various urls. I'd like to keep this on the Heroku free tier as long as possible. I'm using django-storages, and I'm wondering what's the best way to get an image from an URL onto S3. Right now, I do something like: Python code:
Is this a good way of doing this? Is there a better way to get an image from an url onto S3?
|
# ? Jun 10, 2013 23:27 |
|
Do you pronounced it "earl"?
|
# ? Jun 10, 2013 23:30 |
|
Dominoes posted:Do you pronounced it "earl"? Depends on my mood.
|
# ? Jun 11, 2013 00:44 |
|
Thermopyle posted:App I'm working on now (on Heroku) will be re-hosting images from various urls. I'd like to keep this on the Heroku free tier as long as possible. You might also have to worry about Heroku's per-request timeout if you're downloading from a particularly slow site. I think it's 30 seconds? After that, your process gets killed. When it comes time to go bigger with it, check out running it as a Celery task. Use SQS as your queue and it's cheap.
|
# ? Jun 11, 2013 18:46 |
|
Gounads posted:You might also have to worry about Heroku's per-request timeout if you're downloading from a particularly slow site. I think it's 30 seconds? After that, your process gets killed. You have 30 seconds to start responding. Streaming an hour long response is fine, as long as something is sent within the first 30 seconds. Your process wont get killed if you don't respond in 30 seconds, just that request.
|
# ? Jun 12, 2013 06:48 |
|
|
# ? Jun 5, 2024 06:58 |
|
Gounads posted:You might also have to worry about Heroku's per-request timeout if you're downloading from a particularly slow site. I think it's 30 seconds? After that, your process gets killed. beanstalkd is supercool for this too. Its dumb as a bag of rocks, but it works loving well. I use it to offload web crawling tasks relating to social media poo poo.
|
# ? Jun 12, 2013 08:05 |