As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Thinking of a web service entirely built on top of MongoDB, while I am pretty confortable with PyMongo, I would like to know if you guys have any positive or negative experiences/stories about either of these ODMs: MongoKit, MongoEngine and MongoAlchemy, the latter having a Flask specific package "Flask-mongoalchemy".
I use MongoEngine with flask no problems. We've written (collected resources) which include wtform support and flask-debugger support as well:
https://github.com/MongoEngine/flask-mongoengine/
I don't really have any real experience or story to offer, but i played with both MongoKit and MongoAlchemy, and i personally decided to try MongoAlchemy, because i like the syntax a little better (probably due to my Django heritage).
MongoKit:
class BlogPost(Document):
structure = {
'title':unicode,
'body':unicode,
'author':unicode,
'date_creation':datetime.datetime,
'rank':int
}
MongoAlchemy:
class BloodDonor(Document):
first_name = StringField()
last_name = StringField()
age = IntField(min_value=0)
gender = EnumField(StringField(), 'male', 'female')
blood_type = EnumField(StringField(), 'O+','A+','B+','AB+',)
Both will help you to validate your data, will let you impose something like a schema (only on application level), and will save you some typing (specifically brackets).
MongoKit is more complete. I chose MongoAlchemy because I didn't want to type structure = {} all the time, and specifying your db and collection using con.test.example.BlogPost() just felt wrong (although you don't have to do it this way).
Try both, and choose the one which works better for you.
As you already mentioned, there is a Flask-MongoAlchemy extension, which works great.
If you want to use MongoKit, the excellent Flask documentation will get you going in no time:
http://flask.pocoo.org/docs/patterns/mongokit/
The great thing is that you just can try one, if you don't like it you can switch to another, or drop to pymongo without having to change anything in the database.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I feel that Zend has decided to abandon the possibility of having the name of a form element with square bracket like something['otherone'].
In Zend Framework 1, you could make $element->setBelongsTo ('piece'), if you wanted to display an input element of style
I read the documentation and searched the ZF2 code, and this feature seems to have disappeared.
Why?!
Is it in Zend Framework 2 a way to do this.
Matthew if you pass by here, i need your help!
In Zend Framework 1 you have to use setBelong to method because zf was removing brackets from attribiute name. In ZF2 you can use brackets in name so you don't need to use setBelong to method.
use Zend\Form\Element;
use Zend\Form\View\Helper;
$text = new Element\Text('something[otherone]');
$viewHelperElement = new Helper\FormText();
echo $viewHelperElement->render($text);
Outpu will be:
<input type="text" name="something[otherone]" value="">
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I watched a talk in live where the person said they at work are doing Scala functionally, they use case classes, transform a type to another, immutability everywhere, etc.
How does this actually work? I'd love to see a simple hello world application with pure functional approach.
Also I can't see how can I get rid of var altogether because sometimes I just need it.
There is a course on Coursera just about that.
"Hello world" is not really good to demonstrate the functional approach, as there is nothing functional about it. (In fact, as #delnan noted, writing to the standard output is considered a side effect, so this program can never be made purely functional.)
The most likely reason for you to need var is using imperative style loops, which is indeed not the functional approach. The functional equivalent would be to either use some of the available filter / transform functions on a collection, or use recursion.
Simple example: finding all strings in a list which start with 'F'. Imperative style (Java):
List<String> result = new ArrayList<String>();
for (String s : strings) {
if (s.startsWith("F")
result.add(s);
}
Imperativeness would be even more pronounced with the old style iterator loop.
In contrast, functional style could be something like:
val result = strings.filter(_.startsWith("F"))
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I would like to give a good name to class that will contain both methods for encryption and
decryption using the same alghoritm.
Does anyone have an idea for naming seemingly opposing expressions under one term?
I found a name for class that encodes and decodes a string of characters, ie. "codec" (COder-DECoder).
I dont want to use the codec term for encryption operations if I already used it for character encoding.
Methods will be something like:
NameOfTheClass.Encrypt(string plainText);
NameOfTheClass.Decrypt(string cipherText);
Such classes are usually named after the cipher they implement. If you have a base class with virtual methods that will be implemented by several different cipher classes, that class usually has a name like BlockCipher or something, depending on exactly what you are doing with it.
Is it an absolute logical requirement that encryption and decryption be the same operation? If not, I'd have both Encrypt and Decrypt methods, since they are different logical operations. If so, you can either use 'Crypt' or something that better describes the algorithm you're using or the reason you're using it.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Standard ML
OCaml
Haskell
some other
It is similar in the power of its static type system to Haskell, though its type inferencing is severely hampered by the need to support OO-style subtyping. Scala also lacks higher-rank polymorphism and impredicativity, both of which Haskell has. On the other hand, Scala's implicits-based type class mechanism, while more verbose than Haskell, is more flexible.
There are many axes on which to compare, of course; Scala's evaluation semantics are strict, like that of ML, whereas Haskell is lazy.
Both in feature set and in the way it's being used, Haskell is probably closest from that list, although the actors library shows a strong Erlang heritage.
Something like this: http://dibblego.wordpress.com/2007/05/23/the-power-of-type-classes-with-scala-implicit-defs/ gives a good idea of where Haskell and Scala are equivalent
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I can say that I really love Scala but now I would like to know the features you cannot live without when working with Scala? What about Scala 2.8?
If I had to go back to Java here's what I'd miss the most: closures, higher order functions, pattern matching, case classes, and the emphasis on immutability.
I've been on 2.8 for a while. If I had to go back to 2.7, the main thing I'd miss is the consistency, cleanness, and richness of the 2.8 collections API. It's waaaaaay better the 2.7 stuff. But I'd also really miss named and default arguments.
Type inference saves so much pointless typing. map and foreach and the like on collections are great, especially in combination with default-lazy iterators and really easy function syntax.
But, as someone who does a lot of scientific computing, what I'd actually miss the most is being able to write high-performance code, wrap it in efficient classes, and then use maps and mathematical operators (+, *, whatever) to manipulate those high-level constructs the way that I actually think about them.
As for 2.8 vs. 2.7--the improvement is pretty incremental from my perspective. It's a little better in many areas; there's little to point to and say, "Oh wow, that!". I expect the new specialized annotation will help me a lot, but I haven't seen it fully in action in the library yet, so I'm withholding judgment.
I enjoy writing in Scala. That's the #1 feature in my book :)
I can just get on with what I want instead of dancing through Java's hoops:
val/var means I don't have to write the type twice
Closures mean I don't have to write lots of anonymous interfaces and can re-use lots more code
Named parameters mean I don't have to remember the position of each argument - great for both reading and writing
Case classes mean I get toString and equals for free... makes debugging far easier!
A decent API for collections (e.g. map, fold) mean that I can say what I want to do instead of dancing the iteration dance
As for 2.8 vs 2.7... I've only ever really spent quality time with 2.8 ;-)
I think it is not a feature but the conciseness which Scala achieves is what I like the most.
This is of course only possible because of type inference, closures, a great type system etc.
I just do not think you can break it down to one or two features. They work together and the result, concise code, is what I would call the killer feature.