@ponyorm

Страница 16 из 75
Alexander
12.01.2017
11:56:04
Vasiliy can you open a new GitHub issue? https://github.com/ponyorm/pony/issues Solving this issue should fix @dadecar problem too

Davide
12.01.2017
12:02:12
Yes, please! ?

Google
Alexander
12.01.2017
12:16:48
Thanks!

I think I fixed the bug. Previously the "connection already closed" exception masked the original exception which causes the connection closing. Now you can see the reason for connection closing, and if it is caused by some bug in Pony you can open another issue related to that specific problem.

https://github.com/ponyorm/pony/commit/1146ff1f4c3525393d4636406ae41213a628f4b1

Mikki
13.01.2017
11:37:53
Welcome :)

Freelance Web Developer
13.01.2017
11:45:02
Thank you

Vasiliy
13.01.2017
14:07:05
Thanks, now i receive another exception, your patch is really help me! For example: File ".../pony/orm/dbapiprovider.py", line 55, in wrap_dbapi_exceptions except dbapi_module.DatabaseError as e: raise DatabaseError(e) DatabaseError: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

Alexander
13.01.2017
14:27:17
You need to check, maybe your PostgreSQL client and server versions differ: http://stackoverflow.com/questions/15934364/psql-server-closed-the-connection-unexepectedly/15977710#15977710

stsouko
14.01.2017
11:58:37
Hello! Is it possible to use fixed-length bit string dtype of postgres in pony?

Alexey
14.01.2017
12:47:17
Hello! Is it possible to use fixed-length bit string dtype of postgres in pony?
You can specify the type this way https://docs.ponyorm.com/api_reference.html?highlight=sql_type#cmdoption-arg-sql_type

stsouko
14.01.2017
12:50:30
ok. if I specify sql_type('bit(8)') then which type I get in Python?

Alexey
14.01.2017
12:51:56
Which type in Python do you need?

stsouko
14.01.2017
12:54:19
Ideally https://pythonhosted.org/bitstring/bitarray.html

I want to implement search by Jaccard/tanimoto similarity on bitstrings (popcount(bs1 & bs2)/popcount(bs1 | bs2))

Google
stsouko
14.01.2017
13:09:11
moreover. I want to use postgres GIN, but I can't find normal documentation with examples for implementing it

Alexander
14.01.2017
13:50:53
@nougmanoff you can define column in the following way: data = Required(str, sql_type='bit(8)') Then in Python you can work with data as with strings: obj.data = '10101010' When working with data in Python, you can manually convert them to bitarray format if you want: array = bitstring.BitArray('0b' + obj.data) I just checked, and it works. Maybe some time in the future we will add specific support for bitstrings in Python.

stsouko
14.01.2017
13:52:23
Thank You!

Alexander
14.01.2017
13:54:48
Can you tell a bit more about how do you want to use GIN?

stsouko
14.01.2017
14:48:27
I found https://github.com/jirutka/smlar/

with implemented GIN support. but this module don't support tanimoto metric. also I found https://github.com/eulerto/pg_similarity

but this module works only with text

Luckydonald
14.01.2017
14:51:38
Huh, looks interesting

Anyone stumbled about a good text search Postgres plugin, e.g. like what elasticsearch offers?

stsouko
14.01.2017
14:53:05
I want implement this: http://pubs.acs.org/doi/abs/10.1021/ci200552r

and I think GIN is suitable for this

Luckydonald
14.01.2017
14:55:14
Never mind, my wifi derped.

stsouko
14.01.2017
14:57:58
for text search http://blog.scoutapp.com/articles/2016/07/12/how-to-make-text-searches-in-postgresql-faster-with-trigram-similarity

Luckydonald
14.01.2017
15:06:28
Noticed, on the online editor still strg+A (or cmd+A on mac) isn't working in text fields

Also I am missing an option to set sql_default='NOW()'

Also the comment is not included in the Postgres database?

Also, cascade delete isn't working in the GUI, if I select False, the python code will still contain True

Artur Rakhmatulin
15.01.2017
17:16:12
do you press save button ?

Google
Luckydonald
16.01.2017
00:09:51
do you press save button ?
Normally it autosaves

And got pony.orm.core.DBSchemaError: Table "StickerPack" cannot be created, because table "stickerpack" (with a different letter case) already exists in the database. Try to delete "stickerpack" table first. with case insensitive Postgres SQL

Lol, dat number

Ngalim
16.01.2017
02:03:48
hi

Micaiah
16.01.2017
02:04:07
hi
Hello!

Ngalim
16.01.2017
02:04:20
i am currently new to pony orm, and now trying to create simple app with pony-orm and flask

Micaiah
16.01.2017
02:04:38
Good combo

Ngalim
16.01.2017
02:04:50
i've separated models.py, controllers.py

but when i want to call Model.select() it gives error ERDiagramError: Mapping is not generated for entity 'Model'

did i call it wrong?

Micaiah
16.01.2017
02:07:14
did i call it wrong?
did you call generate_mapping before the select?

Ngalim
16.01.2017
02:08:19
did you call generate_mapping before the select?
i've already have the table, it's from mySQL table

should i call generate_mapping?

when i call generate_mapping i've got this error pony.orm.core.ERDiagramError: Cannot define entity 'Employee': database mapping has already been generated

Micaiah
16.01.2017
05:56:33
Ngalim
16.01.2017
06:06:38
Micaiah
16.01.2017
06:20:16
I would handle all of your DB setup in models

http://pastebin.com/T8xE6nxz

Looks like db.bind is getting called *before* Employee is created by the interpreter

Google
Ngalim
16.01.2017
06:58:28
hmm .. ok i'll try to fix it

Alexander
16.01.2017
07:22:15
Hi Ngalim! db.bind(...) is used to specify database type and parameters of database connection. db.generate_mapping(...) is used to notify Pony: "all necessary entities are defined". At this moment Pony understands which tables should be used to represent specified entities. It is possible to specify create_tables=True option to generate tables, but even if tables are already created, calling generate_mapping is necessary, because this is the moment when Pony creates internal linking between entities and tables. When application is imported, the sequence of operations should be the following: from pony import orm db = Database() class X(db.Entity): ... class Y(db.Entity): ... db.bind(...) db.generate_mapping(...) with db_session: result = select(...) That is, generate_mapping should be called after all entities are defined, but before first select is issued. If you want to put entities in a separate module, I suggest you to define db right in that module, but perform bind and generate_mapping outside of it. This way you separate entity definitions and database configuration options. It may looks something like that: models.py: db = Database() class Person(db.Entity): name = Required(str) controllers.py: from flask import Blueprint from model import db, Person employee_bp = Blueprint(...) main.py: from flask import Flask from controllers import employee_bp from models import db app = Flask(__name__) ... app.register_blueprint(employee_bp) if __name__ == '__main__': db.bind(...) db.generate_mapping() app.run(...)

Ngalim
16.01.2017
07:30:37
Hi Ngalim! db.bind(...) is used to specify database type and parameters of database connection. db.generate_mapping(...) is used to notify Pony: "all necessary entities are defined". At this moment Pony understands which tables should be used to represent specified entities. It is possible to specify create_tables=True option to generate tables, but even if tables are already created, calling generate_mapping is necessary, because this is the moment when Pony creates internal linking between entities and tables. When application is imported, the sequence of operations should be the following: from pony import orm db = Database() class X(db.Entity): ... class Y(db.Entity): ... db.bind(...) db.generate_mapping(...) with db_session: result = select(...) That is, generate_mapping should be called after all entities are defined, but before first select is issued. If you want to put entities in a separate module, I suggest you to define db right in that module, but perform bind and generate_mapping outside of it. This way you separate entity definitions and database configuration options. It may looks something like that: models.py: db = Database() class Person(db.Entity): name = Required(str) controllers.py: from flask import Blueprint from model import db, Person employee_bp = Blueprint(...) main.py: from flask import Flask from controllers import employee_bp from models import db app = Flask(__name__) ... app.register_blueprint(employee_bp) if __name__ == '__main__': db.bind(...) db.generate_mapping() app.run(...)
Thank you

i'll fix mine now

Alexey
16.01.2017
08:36:55
@luckydonald thank you for reporting bugs and suggesting regarding the editor. We'll fix that. Also, would like to let you know that currently we are working on a new version of the editor. The old version was done using KnockoutJS and it proved to be not very convenient in the long run. The new version is done using React+Redux. Such architecture makes it easier and faster to add new features.

Romet
16.01.2017
08:42:41
+1 for react&redux

Святослав
16.01.2017
08:43:10
JS ?

Micaiah
16.01.2017
11:05:01
+1 for react&redux
Where is a good place to learn react+redux in a Python context?

Romet
16.01.2017
11:24:10
Not sure what you mean by in a Python context but at work we work almost exclusively with a python/django/DRF + react/redux stack

Don't think there are any guides that talk about specific backends in combination with react/redux that aren't node-based.

Micaiah
16.01.2017
11:32:34
Okay thanks!

I'm on code academy and it looks like it is using some node extensions in the background to compile the JSX, what would you use with Django (or in my case Flask) to compile JSX?

Roman
16.01.2017
12:07:57
@micaiahparker try https://github.com/facebookincubator/create-react-app

It's allow you to start working with react without writing tons of configs for webpack/babel/jest etc

You will run node (webpack) during development and as result you get compiled js file

Micaiah
16.01.2017
12:10:16
And then I can link to the compiled JS in a Jinja template for prod?

Roman
16.01.2017
12:10:31
Yeah

Micaiah
16.01.2017
12:10:37
Sweet! Thanks

Wow, looks like JSX has changed quite a bit since when this code-academy lesson was made.

Artur Rakhmatulin
16.01.2017
12:22:33
anyone try to use djony this new version Pony & Django? djony is very old... i think project is dead https://github.com/nnseva/djony

Google
Alexander
16.01.2017
12:27:10
I doubt that someone recently used djony, and it may not work with the current version of Pony/Django, but it is possible that the code can be fixed. It may be consiered as a proof of concept that Django/Pony integration is possible

Artur Rakhmatulin
16.01.2017
12:29:04
is there any working concept of django and pony now?

Alexander
16.01.2017
12:29:41
I think there are no production-ready code at this moment

We personally just use Pony+Flask+ReactJS, so integration with Django was not our priority, but later we can add it

Artur Rakhmatulin
16.01.2017
12:34:27
I was wrote some logic modules on Python with ponyOrm ) it works and im happy. I will want develop web application with Django like java + spring MVC. And i dont know there any known working methodics what can help me.

ok ) i will read about flask maybe this way better

Roman
16.01.2017
13:00:40
Webpack is best solution for now

Artur Rakhmatulin
16.01.2017
13:10:59
Wasn't spring the one where you write java code, which gets translated into html/js ?
nowhere ) I dont develop front-end I am just supporting old java project with Java+Spring now. Fron-end was developing with GWT.

Micaiah
16.01.2017
13:31:04
Webpack is best solution for now
With webpack is bundle.js path dependent? IE, can I move it to ./static

Roman
16.01.2017
13:33:37
@micaiahparker What do you mean? In webpack you can set any (relative or absolute) destination path include './static'

http://webpack.github.io/docs/configuration.html#output

Luckydonald
16.01.2017
13:43:19
This is about baking a big app.js file right? I was looking into https://github.com/miracle2k/webassets (and flask https://github.com/miracle2k/flask-assets)

Luckydonald
16.01.2017
14:01:34
But I couldn't get around to test it myself

Micaiah
16.01.2017
14:02:13
I'm not sure what route webasset wants one to take to actually install javascript libraries..

Страница 16 из 75