Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
MonkeyMaker
May 22, 2006

What's your poison, sir?

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()`.

Adbot
ADBOT LOVES YOU

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

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.

I'd probably do it in `get()` or `post()`.

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

entr0py
Jan 31, 2004


A real-life robot.
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

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

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...

MonkeyMaker
May 22, 2006

What's your poison, sir?

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?

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

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

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

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?

edit: as an alternative Fabric scripts or setting poo poo under saltstack/puppet/chef would work, with saltstack being my new favorite hotness.

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...

MonkeyMaker
May 22, 2006

What's your poison, sir?

Thermopyle posted:

Yeah, I guess this is what I'm going to do. I was just wondering if there was anything else.


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...

you can't ever "use [your] free tier", it's free per app.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

MonkeyMaker posted:

you can't ever "use [your] free tier", it's free per app.

D'oh!

bonds0097
Oct 23, 2010

I would cry but I don't think I can spare the moisture.
Pillbug

Seriously? That's amazing.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

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.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

bonds0097 posted:

Seriously? That's amazing.

I know, I'm terrible sometimes.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

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.

MonkeyMaker
May 22, 2006

What's your poison, sir?

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.

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.

My cookbooks haven't kept up with Vagrant and VirtualBox releases because I'm horrible at this support thing. :smith:

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.

Dominoes
Sep 20, 2007

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

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

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.

bonds0097
Oct 23, 2010

I would cry but I don't think I can spare the moisture.
Pillbug

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

Lore Crimes
Jul 22, 2007

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?

Dominoes
Sep 20, 2007

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

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.
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.)

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

etcetera08
Sep 11, 2008

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.

MonkeyMaker
May 22, 2006

What's your poison, sir?

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?

Dominoes
Sep 20, 2007

MonkeyMaker posted:

Since I don't have SSL on the site, maybe try dropping the 's' on the URL? Works for me.
It looks like answers/replies from this weekend are newer may be showing up, but older ones aren't.

etcetera08
Sep 11, 2008

MonkeyMaker posted:

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?

Hey shout me out on irc if you want help with the Chef/Vagrant stuff. (I'm etc/drank on there)

The March Hare
Oct 15, 2006

Je rêve d'un
Wayne's World 3
Buglord

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:
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Hero poo poo goes here.
class Hero(models.Model):
    user = models.ForeignKey(User)
    name = models.CharField(max_length=30)
    gender = models.CharField(
        max_length=1, choices=(
            ('M', 'Male'),
            ('F', 'Female'),
        )
    )
    level = models.IntegerField(default=1)
    # Served as a percentage value 0-100,
    # impacts the width of the expbar on the fight page.
    current_exp = models.IntegerField(default=0)
    # Hero Stats - Inheret base stats from race/class stats, by default set to
    # nothing.
    # Impacts attack damage rolls for melee weapons/bows.
    strength = models.IntegerField(default=1)
    # Impacts attack damage rolls for wizards.
    intelligence = models.IntegerField(default=1)
    # Impacts hit chance, ranged weapon damage.
    dexterity = models.IntegerField(default=1)
    # Impacts evasion rate and # of attacks.
    agility = models.IntegerField(default=1)
    # Impacts your max HP.
    vitality = models.IntegerField(default=1)
    # Adds bonuses to loot generation and hit/evade/crit.
    luck = models.IntegerField(default=1)
    active = models.BooleanField(default=0)

#----------------------------------------------------------------------
# Hero Race -- Base stats and stat growth.
    hero_race = models.CharField(
        max_length=2, choices=(
            ('HU', 'Human'),
            ('OR', 'Orc'),
            ('GO', 'Goblin'),
            ('EL', 'Elf'),
            ('ME', 'Merfolk'),
            ('DW', 'Dwarf'),
            ('FA', 'Faery'),
            ('GN', 'Gnome'),
            ('GI', 'Giant'),
            ('TR', 'Troll'),
        )
    )

#----------------------------------------------------------------------
# Hero Class -- Base stats and stat growth. Possibly weapon aptitudes?
    hero_class = models.CharField(
        max_length=2, choices=(
            ('WA', 'Warrior'),
            ('PA', 'Paladin'),
            ('CL', 'Cleric'),
            ('MA', 'Mage'),
            ('RO', 'Rogue'),
            ('BA', 'Battle Mage'),
            ('VA', 'Vampire'),
            ('BA', 'Barbarian'),
            ('RA', 'Ranger'),
            ('MO', 'Monk'),
        )
    )

#----------------------------------------------------------------------
# Hero Job -- Adds a trait or two, like increased gold drop rates for
# merchants or whatever, who knows.
    hero_job = models.CharField(
        max_length=2, choices=(
            ('ME', 'Merchant'),
            ('', ''),
            ('', ''),
            ('', ''),
            ('', ''),
            ('', ''),
            ('', ''),
            ('', ''),
            ('', ''),
            ('', ''),
        )
    )

#----------------------------------------------------------------------
# Total stat values.
    @property
    def total_str(self):
        return self.strength + sum(self.equipment_set.filter(
            is_equipped=1).values_list('strength', flat=True)
        )

    @property
    def total_int(self):
        return self.intelligence + sum(self.equipment_set.filter(
            is_equipped=1).values_list('intelligence', flat=True)
        )

    @property
    def total_dex(self):
        return self.dexterity + sum(self.equipment_set.filter(
            is_equipped=1).values_list('dexterity', flat=True)
        )

    @property
    def total_agi(self):
        return self.agility + sum(self.equipment_set.filter(
            is_equipped=1).values_list('agility', flat=True)
        )

    @property
    def total_vit(self):
        return self.vitality + sum(self.equipment_set.filter(
            is_equipped=1).values_list('vitality', flat=True)
        )

    @property
    def total_luk(self):
        return self.luck + sum(self.equipment_set.filter(
            is_equipped=1).values_list('luck', flat=True)
        )

#----------------------------------------------------------------------
# Maximal HP value.
    @property
    def max_hp(self):
        hero = Hero.objects.get(user=User, active=1)
        return hero.vitality + sum(hero.equipment_set.filter(
            is_equipped=1).values_list('vitality', flat=True)
        ) * hero.level

#----------------------------------------------------------------------
# Combat stuff.
    @property
    def hit(self):
        return self.total_dex + self.total_luk / 10

    @property
    def evade(self):
        return self.total_agi + self.total_luk / 10

#----------------------------------------------------------------------
# Unicode stuff.
    def __unicode__(self):
        return u'%s' % (self.name)
Then we also have this code for equipment that your dude can wear:

code:
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Equipment poo poo goes here.
class Equipment(models.Model):
    strength = models.IntegerField()
    intelligence = models.IntegerField()
    dexterity = models.IntegerField()
    agility = models.IntegerField()
    vitality = models.IntegerField()
    luck = models.IntegerField()
    name = models.CharField(max_length=256)
    slot = models.CharField(max_length=32)
    owner = models.ForeignKey(Hero)
    is_equipped = models.BooleanField(default=0)
    weapontype = models.CharField(max_length=32)
So the way things are currently handled, the @properties on the Hero class tabulate total stat values from items equipped to the active hero. This all works just fine, but I'm not sure if I should figure out a way to make it so that any given hero can only have, for example, exactly one item with a slot = "hat" equipped at a time as a precaution against exploits, or if it will be enough to just have the code that equips items unequip all other items from that slot before equipping the new item.

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.

etcetera08
Sep 11, 2008

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.)

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.

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.

spencer for hire
Jan 27, 2006

we just want to dance here, someone stole the stage
they call us irresponsible, write us off the page

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.

Dominoes
Sep 20, 2007

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.

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.
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.

etcetera08
Sep 11, 2008

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:
Running chef-solo...
stdin: is not a tty
[2013-06-05T05:03:05+00:00] INFO: *** Chef 10.14.2 ***

etcetera08 fucked around with this message at 06:10 on Jun 5, 2013

nonathlon
Jul 9, 2004
And yet, somehow, now it's my fault ...
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?

Dominoes
Sep 20, 2007

etcetera08 posted:

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:
Running chef-solo...
stdin: is not a tty
[2013-06-05T05:03:05+00:00] INFO: *** Chef 10.14.2 ***
Correct. Chef 11.4.4

etcetera08
Sep 11, 2008

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.

Dominoes
Sep 20, 2007

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.
Thanks - Vagrant up completed without errors.

Dominoes
Sep 20, 2007

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

Lister_of_smeg
May 25, 2005
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?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

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:
import requests
from django.core.files.base import ContentFile

class AnImageModelOfExcellence(models.Model):
    image = models.ImageField(upload_to='place_of_wonders')

def imbibe_image(url):
    wonder = AnImageModelOfExcellence()
    image_request = requests.get(url, stream=True)
    wonder.image.save("gaiety_named.jpg", ContentFile(image_request.content))
    return wonder
I don't know the maximum size these images might be, but they're usually fairly high resolution jpegs (2000x1000), and I have this nebulous worry about Heroku and memory/storage limits.

Is this a good way of doing this? Is there a better way to get an image from an url onto S3?

Dominoes
Sep 20, 2007

Do you pronounced it "earl"?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

Do you pronounced it "earl"?

Depends on my mood.

Gounads
Mar 13, 2013

Where am I?
How did I get here?

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.

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:
import requests
from django.core.files.base import ContentFile

class AnImageModelOfExcellence(models.Model):
    image = models.ImageField(upload_to='place_of_wonders')

def imbibe_image(url):
    wonder = AnImageModelOfExcellence()
    image_request = requests.get(url, stream=True)
    wonder.image.save("gaiety_named.jpg", ContentFile(image_request.content))
    return wonder
I don't know the maximum size these images might be, but they're usually fairly high resolution jpegs (2000x1000), and I have this nebulous worry about Heroku and memory/storage limits.

Is this a good way of doing this? Is there a better way to get an image from an url onto S3?

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.

Pardot
Jul 25, 2001




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.

Adbot
ADBOT LOVES YOU

duck monster
Dec 15, 2004

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.

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.

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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply