How would I go about plugging mongoengine into pyramid? - python

I've created a basic mongoengine app using the pyramid_mongodb scaffold...however I'd like to include mongoengine. I'm wondering what I should actually keep from the scaffolds code.

Not a answer regarding the scaffold. I wouldn't recommend using the scaffold since it's not really usable for root_factory and so on, the subscribers isn't really needed too.
I wrote an addon for pyramid. It's called pyramid_mongo.
Documentation:
http://packages.python.org/pyramid_mongo/
Github:
https://github.com/llacroix/pyramid_mongo
I saw your question today and felt it could be a good addon to the plugin.
I just pushed it to github so you need to clone it from there for now, installing using pip will load the old version without support for mongoengine.
In other words in your config, do everything like in the docs and add something like:
mongo.mongoengine=true
It will attach mongo from the config to mongoengine. All other api will work with or without mongoengine and mongoengine should work. It just added it today, it doesn't support multiple connections and multiple dbs. I can also add support for multiple dbs too. But I feel mongoengine may do some things on his own that could conflict with my plugin like authorization.
Once I write tests, I'll push it to python packages and it will be possible to install from pip or easy_install. For now, pull it from github

Related

Upgrade SQLite version inside a python3.6 venv without root or affecting the global packages

First off, I know similar questions have been answered, but I can't find any solutions for my particular constraints. If there is one, please point me to it.
I'm trying to start a django project. However, I can't run the development server. The problem seems to be the SQLite version. I have 3.7.17 installed, django requires 3.9 or later. So I need to upgrade it. The problem is I'm using one machine from many, used by multiple developers all working on different projects, but sharing the same global python packages. So whatever changes I need to make, need to be inside my venv. And I don't have root access on the machine. Also, I don't plan on using SQLite as the DB for the project, so if that means I can somehow bypass this requirement, that would be fine as well. However, I assume, in that case I'll need to somehow transfer the django admin app to my DB of choice as well?
Note: I'm quite new to web development or programming in general, so a dumbed down explanation would be greatly appreciated. Thanks.

official support of MongoDB in django

I want to use the MongoDB database in Django.
Officially there are no Django-MongoDB drivers available. I found some third-party sources, but they're outdated. I found some projects on GitHub, but they are also outdated (last updated 2-3 year ago).
What are my option? Is there any official support for MongoDB in Django?
This tutorial looks like best solution at this point.
You need to install django#nonrel and djangotoolbox so non-relational db can work properly on your django project.
After installing mongodb-engine just activate it in settings.py file

confused about Solr Django and Haystack installation

I'm following the tutorial in the Haystack for using solr in django. I download haystack ad it to my installed apps, and I like to check my development to make sure my apps still working. So when I go to my my localhost it says
A server error occurred. Please contact the administrator.
and in my terminal it says
raise MissingDependency("The 'solr' backend requires the installation of 'pysolr'. Please refer to the documentation.")
and when I go to the pysolr documentation it seems as if it's to be used without haystack. There is no mention pysolr in haystack docs and no mention of haystack in pysolr docs. Not only that, but pysolr gives an example that says
# If on Python 2.X
Im using python 3. I understand theres a learning curve but is there anything that has all the resources in one post? Or must I just trial and error it out? and also can it be Kind of up to date? 2.x to 3.5 is a big gap. There are surprisingly no google videos or vimeo videos on this. any and all help is welcome. I know anything worth having or knowing isn't easy to come by but sheesh? the few sites Ive seen also have the url like this in urls.py
(r'^search/', include('haystack.urls')),
but if I do it like that I get an error
regex_pattern = pattern.regex.pattern
AttributeError: 'tuple' object has no attribute 'regex'
this may seem like nothing to someone experienced, but to the untrained this can lead to a lot of confusion to the proper syntax.
Haystack uses different adapters to talk to different backend services, such as ElasticSearch or Solr.
The Solr adapter uses pysolr:
You’ll also need a Solr binding, pysolr. The official pysolr package, distributed via PyPI, is the best version to use (2.1.0+). Place pysolr.py somewhere on your PYTHONPATH.
You shouldn't have to do anything with pysolr yourself, as that is only used inside the haystack Solr adapter. Be sure to follow the tutorial for setting up the schema and getting the indexing running.
just pip install pysolr and move about your day.
Personally, I used(in my virtual env):
python3 -m pip install pysolr

Having trouble with download_app and coursebuilder

I inherited an appengine coursebuilder project a couple months ago, and we've been trying to upgrade to a more recent version of coursebuilder. In order to do this, the first step is to download local version of the course.
Whenever I run appcfg.py download_app -A $projectID -V $versionNumber ./folderToSaveTo
It downloads a different version of the course, one that looks like an old test version with old placeholder text, all links to lessons set to private, etc.
When I look at the versions of the course in the appengine dashboard, there is only a single version, so I'm not sure what it's even downloading.
Alternatively, it was suggested I use the ETL tool provided with coursebuilder to download the files instead, but that had a bunch of other issues associated with it as well. Previously I had asked the question directly on the coursebuilder forum where the ETL tool was initially suggested.
Thanks in advance for any help,
-Tyler Nolan
appcfg's download_app will only look within the default module. You should check if there are any drop-downs in the Developers Console UI which will allow you to look into whether there are other modules.
gcloud preview app modules download on the other hand, does allow you to specify modules.
Hopefully this helps you find the "real version" of your app.
It's also possible that what you download is displaying default data because it's not being viewed in a manner which is properly connected to the database, so it falls back to look like that.

Python Web Framework with best Mongo support

I'm looking to write a small web app to utilise a dataset I already have stored in a MongoDB collection. I've been writing more Python than other languages lately and would like to broaden my repertoire and write a Python web app.
It seems however that most if not all of the current popular Python web development frameworks favour MySQL and others with no mention given to MongoDB.
I am aware that there are more than likely plugins written to allow Mongo be used with existing frameworks but so far have found little as to documentation that compares and contrasts them.
I was wondering what in people's experience is the Python web development framework with the best MongoDB support?
Many thanks in advance,
Patrick
I have not tried MongoKit although it has been around for a while and retains a good reputation. I personally prefer MongoEngine and feel very comfortable with it (maybe because I like its nice homepage and good documentation). There is also a very good opensource project named Mumblr which demonstrates a Django-MongoEngine-MongoDB combination, which I think a very good starter for any project. I'm developing a CMS for my own company using this app.
I've used MongoKit with Pylons before and it worked out good.
You might want to refer to this post though: MongoDB ORM for Python?
There is no stable support for mongodb using django framework. I tried using mongoengine, but unlike models, provided for admin in django framework, there is no support for mongoengine.
Correct if I am wrong.
Flask is the best framework to use with MongoDB. It has a mongodb library called flask-pymongo
Make sure you run the following commands before starting your project.
$ pip3 install Flask
$ pip3 install Flask-PyMongo

Categories