The idea is that a transaction starts when a request starts, and it’s automatically rolled back if there’s an exception. This is behavior you want from the start! It’s half (err, ¼) the point of using a database. I mostly agreed with the rest of the article but this strikes me as massive blooper. I can see no reason this would be considered good advise. It's the database equivalent of the GIL, can't figure out what y…
The transaction is internal to the database. It's essentially a list of operations to perform, if something goes wrong it provides a list of things to reverse. If the db transaction fails, then there would need to be some code to handle rolling back operations outside of the database. I don't think db transactions were to fault in your situation.
I only know PHP. How do I write a Web application in Python?
111–120 of 196 posts
Re: I only know PHP. How do I write a Web application in Python?
#112What's wrong with mysql?
The multiple database engine mess leads to its own problems compared to engines like postgresql. Do you use the InnoDB engine, and rely on third-party products, like galera, for clustering, or do you use NDB and suffer its weaknesses in referential integrity, and difficulty in configuration?
Finally, you get into issues where MySQL isn't nearly as featureful as PostgreSQL. For example, PostgreSQL supports a multitude of languages for creating server-side procedural functions -- pgsql, perl, python, tcl, etc, whereas MySQL only supports C, and only pre-compiled functions. This limits the utility, and leads to these quite useful features being left by the wayside because numerous coders were weaned on a database that didn't support doing these nice things for them.
While mysql does have certain uses, I'd argue severely that postgresql is a much better designed foundation for working on new projects. The attention to detail, the emphasis on not eating your data, and the level of features means that you can spend more time coding, and in the language you want to use, and less time fiddling with your database software.
Re: I only know PHP. How do I write a Web application in Python?
#113Is there any cheap & easy webhosting available for Python? Occasionally I get commisioned to build small websites ( I don't want the hassle/expense of having to setup and run VPS/AWS infastructure. I just want to give someone a bunch of files and say "sign up for some cheap webhosting, ask them to give you a DB called X and upload these". I usually end up just doing it in PHP, but it has always felt like a poor reaso…
Heroku is a good choice, > This quickstart will get you going with Python and the Flask web framework on the Cedar stack. For Django apps, please see the Django quickstart. https://devcenter.heroku.com/articles/python It can be very cheap or free at low scale, > Each application receives 750 free dyno hours per month. https://devcenter.heroku.com/articles/dynos
Re: I only know PHP. How do I write a Web application in Python?
#114Is there any cheap & easy webhosting available for Python? Occasionally I get commisioned to build small websites ( I don't want the hassle/expense of having to setup and run VPS/AWS infastructure. I just want to give someone a bunch of files and say "sign up for some cheap webhosting, ask them to give you a DB called X and upload these". I usually end up just doing it in PHP, but it has always felt like a poor reaso…
Heroku is a good choice, > This quickstart will get you going with Python and the Flask web framework on the Cedar stack. For Django apps, please see the Django quickstart. https://devcenter.heroku.com/articles/python It can be very cheap or free at low scale, > Each application receives 750 free dyno hours per month. https://devcenter.heroku.com/articles/dynos
I am assuming with this , you would very much build you application around their infrastructure so it would become fairly well coupled to it?
A lot of services (such as godaddy) will offer packages like domain name + email + web hosting for a flat monthly fee. This keeps things very simple, but the snag is they only ever seem to support PHP.
I don't really want to have to explain to someone why they have a massive bill because some action on their website caused them to use lots of "dyno hours".
Re: I only know PHP. How do I write a Web application in Python?
#115I'd say the necessity of this post is why PHP is as popular as it is. With PHP, there are no package managers I have to install; there is no template language to learn; there is often no version control; there is no "framework"; etc. You just drop in a .php file and, most likely, it will just run. If I need a quick dynamic page on my server, it's much easier to do this in PHP than in Python or Ruby. Until Python or R…
CGI scripts have much of PHPs simplicity. You can just drop in a executable file, and depending bit on server configuration, it will just run. With Python a basic hello world would look something like this: #!/usr/bin/python print "Content-type: text/plain" print "" print "Hello World!" So 3 lines of "boilerplate", and then you can do anything you want. No extra packages to install or languages to learn. No framework…
Hello World!
One line. I didn't have to worry about Linux/Windows, knowing HTTP headers or the fact that I need two CRLFs after the last header[1]. I just wanted a page that says "Hello World!" and that's what I got.Don't get me wrong, I would never choose to write a web app in PHP over python. But it is brain dead simple to go from nothing to something in a few keystrokes. Which is precisely what people just learning to write web apps want (right or wrong).
[1] I can't remember how long it took me to figure out that I needed the second CRLF after the "Content-Type: text/html" when I was learning perl (or even the fact that I needed to specify the Content-Type in the first place).
Re: I only know PHP. How do I write a Web application in Python?
#116Nice littel overview, but... "Unicode sucks. This is a universal truth." And here I stopped reading. Unicode is the best thing around, what sucks it that Py2 does not implement it very well. Py3 does, and that is the main reason I really would like to use it and hope Django will soon fully support it. (Because: there are other languages beside the European ones)
Fair point. Correction: working with encodings sucks. Py3 isn't magnitudes better with Unicode; it's better about converting incoming bytes, and it makes literals into real strings. But the former isn't necessarily a good thing, and you can get the latter with a `__future__` import. Always dying on implicit conversions is definitely nice, though.
Re: I only know PHP. How do I write a Web application in Python?
#117Is there any cheap & easy webhosting available for Python? Occasionally I get commisioned to build small websites ( I don't want the hassle/expense of having to setup and run VPS/AWS infastructure. I just want to give someone a bunch of files and say "sign up for some cheap webhosting, ask them to give you a DB called X and upload these". I usually end up just doing it in PHP, but it has always felt like a poor reaso…
Heroku is a good choice, > This quickstart will get you going with Python and the Flask web framework on the Cedar stack. For Django apps, please see the Django quickstart. https://devcenter.heroku.com/articles/python It can be very cheap or free at low scale, > Each application receives 750 free dyno hours per month. https://devcenter.heroku.com/articles/dynos
No, a simple Rails app is not very coupled to Heroku.
The deployment process is simpler and pretty unique to Heroku, but it's usually pretty easy to move away from Heroku or deploy in parallel to another location. I actually deploy one app to Heroku and I have an offsite backup process that deploys the same codebase to a NGINX/Passenger setup and clones the production Heroku data to that instance.
Your mileage will vary, of course. If you start using a bunch of Heroku plugins, you'll find it's harder to maintain an easy dual-deploy setup.
Re: I only know PHP. How do I write a Web application in Python?
#118The idea is that a transaction starts when a request starts, and it’s automatically rolled back if there’s an exception. This is behavior you want from the start! It’s half (err, ¼) the point of using a database. I mostly agreed with the rest of the article but this strikes me as massive blooper. I can see no reason this would be considered good advise. It's the database equivalent of the GIL, can't figure out what y…
Re: I only know PHP. How do I write a Web application in Python?
#119Earlier quoted context omitted.
What frameworks and platforms would you recommend for web development with java? I am writing my senior project at college in java (mainly because of the wide amount of image processing libraries available) and would love to add web capabilities.
I tend to prefer Python/Flask for Web dev to Python but if you are inclined to use Java there's only really one framework that doesn't make me want to tear my eyeballs out. That framework is Spring MVC. It is DI, adapters for vendor-specific libraries and utility. It's probably not the easiest thing to start with just because it is so flexible that it can be hard to know where to start. A good "Hello World" Spring MV…
Re: I only know PHP. How do I write a Web application in Python?
#120I'd say the necessity of this post is why PHP is as popular as it is. With PHP, there are no package managers I have to install; there is no template language to learn; there is often no version control; there is no "framework"; etc. You just drop in a .php file and, most likely, it will just run. If I need a quick dynamic page on my server, it's much easier to do this in PHP than in Python or Ruby. Until Python or R…
While this might be nice for the beginner getting started, it's also a brilliant way to encourage bad habits in people who want to turn it into a career.
Leaving the "PHP is a templating language" pedantry aside, this 'benefit' encourages the aspiring developer to not bother separating concerns. Just go ahead and throw HTML into PHP and vice-versa; throw all your database logic, SQL, and connection details into those self-same files that are being served; leave XSS vulnerabilities in all your code because you probably weren't told to wrap your output in `htmlspecialchars` or whatever.
Shit like that needs to stop. But as the barrier to entry is so low, the same mistakes will be repeated ad infinitum. I would love to figure out a way to introduce a beginner coder to a language, without scaring them off, but without being lax with security and separation of concerns.
That being said, I do agree about frameworks, but I also think that this is because there is no "one true framework" for PHP (Zend, Symfony and Cake don't fit the bill, I don't think). There's no Rails, or Django, and there's no Sinatra or Flask as a minimal alternative. PHP is dire for framework development, not because of the language, but because so many groups of developers are trying to re-invent the same framework (but with their own idea of what 'the PHP way' should be - Javatastic bloat like Symfony and Zend, or Rails mimicry with no real understanding of PHP not being anything like Ruby), treading the same ground over and over again, when there could be more collaboration to provide the definitive offering.
If that were to change, and for the better, I might extend my argument to say that such a framework may be a great way to learn PHP, just like Rails was a great way for many to learn Ruby.