Re: [pylons-discuss] Recommendations for writing API routes?

2024-09-11 Thread Mikko Ohtamaa
Hi,

Alternatively fastapi is a very popular and maintained framework today.
Though as far as I know, it runs on the top of Flask, not Pyramid. Not sure
if Pyramid integration exists.

https://github.com/fastapi/fastapi

Br,
Mikko

On Wed, 11 Sept 2024 at 16:11, Laurent Daverio  wrote:

> Hello List,
>
> I would like to ask about recommended packages for writing API routes in
> Pyramid. I mostly know two ways of doing it:
>
> - using Pyramid views with a JSON renderer
> - using Cornice
>
> At one time, I was using `pyramid_openapi3` on tope of it, but I decided
> to stop, due to having lots of issues with it (but that's another story).
>
> I generally prefer Cornice, however there a lot of features I don't use,
> like validations, and "resources" (I only use "services", as "resources"
> are not flexible enough for my needs).
>
> So, at this point, my question is: if you were to recommend something
> "better" than Cornice ("better" meaning essentially "lighter"), what would
> it be?
>
> Thanks in advance,
>
> Laurent.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/CAB7cU6xtNQdj%3Dby9WjeJwJZkpV4-GOmDeyaq1XqyJZ_dGC%3D%2B0w%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsN86a_taRKS_9BAZsusVokUeSvvtuYOTRAHzEtYi57Ow%40mail.gmail.com.


Re: [pylons-discuss] PyramidConf, Fall 2023, Spain

2022-11-01 Thread Mikko Ohtamaa
Hi all,

I'll definitely be in Pyracon 2023. Happy to attract some of my friends
from Finland as well.

Br,
Mikko

On Sun, 23 Oct 2022, 13:23 Nejc Zupan,  wrote:

> Now that lockdowns are (hopefully!) a part of history, I started thinking
> of organizing a Pyramid conference.
>
> The general idea is two days of talks and a day for a sprint. Wed to Fri.
> Probably Spain, in October or November 2023.
>
> I want to gauge if there is interest from the community in attending and
> sponsoring such an event?
>
> Can we even get enough talks to fill up two days?
>
> Some of the topics I’d personally *love* to hear talks on:
> * Migration to Pyramid 2.0
> * Databases use cases (why/why not Posgres, Mongo, etc.)
> * Performance & scaling
> * Deployment use cases (containers vs. more traditional, even baremetal
> deployments, etc.)
> * Dev tips, testing best practices
> * Typing of Pyramid projects (mypy and friends)
> * Success stories
> * Frameworks on top of pyramid
>
>
> I’m sure there’s more!
>
>
> Cheers,
> Neyts
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/E0915DB6-A6C3-49A0-BAAB-B2172C6167E2%40gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtWsO75VR6ktKnj%3D2BM8CWrPh94xzSRPxkn%2B7kcszyACQ%40mail.gmail.com.


[pylons-discuss] Top like monitoring for Pyramid / Gunicorn

2022-08-21 Thread Mikko Ohtamaa
Hi all,

I am running Pyramid + SQLAlchemy website on the top of Gunicorn. Sometimes
requests get stuck of the Pyramid application becomes non-responsive for
certain requests (not all). Despite good attempts using Gunicorn statsd
monitoring, I have had no good success to pin down these problematic
requests.

Do you know any tools that could offer UNIX top like monitoring for the
currently active requests? I know this is a far shot - Gunicorn did not
seem to offer any interface in its documentation to offer anything like
this. And if this is not the case, which is unfortunately likely, what
would be nice way to pull start request and stop request events from
Pyramid to a separate CLI tool, so one could see when bad things start to
happen?

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUs%2BfahvVuq6Ww5i7WfTND2_h45_t7KnXOtofE_ubZxPZw%40mail.gmail.com.


Re: [pylons-discuss] Re: using pyramid without an ORM ?

2022-08-18 Thread Mikko Ohtamaa
Hi all,

A very interesting discussion thread!

>
> thats my own opinion , there is nothing wrong with SQLALCHEMY but I don't
> quite understand whats going on internally so I stopped.
>

This might be a bit off-topic, but this is the weak area of SqlAlchemy. It
is very brilliant engineering, but it is a very complex beast. Due to the
legacy of Python documentation practices, its own documentation of
reference manual is not as good as some others (e.g. Django) making
SQLAlchemy harder to learn.

Nowadays I program SQLAlchemy by using StackOverflow. This is after 10
years of using SQLAlchemy. Makes the process more tolerable. However, the
extra power you get from it in a big project is worth it. The project needs
to be a big though, and fit nicely into the web app/CRUD style scope.

Which brings me to the offtopic questions: what are the best alternatives
of SQLAlchemy in Python today - something that could be a bit easier to
approach and might work better for smaller projects?

Myself, I am probably too old to start learning anything new, so I just use
SQLAlchemy and then drop to raw SQL strings when I need to deal with
something ORM cannot handle.

Br,
Mikko


>
> the more I look into postgres the more I want to make a use of it is
> features.
>
>
>
>
> On Wednesday, August 17, 2022 at 9:46:06 PM UTC+3 mmer...@gmail.com wrote:
>
>> I think it's worth noting that zope.sqlalchemy's session registration
>> supports a "readonly" initial state, similar to active and changed that
>> we've all harped on in the past. I'd probably just look into using that and
>> sticking with existing patterns. If you go all-in on readonly as a pattern
>> I think it could be a lot simpler but hey, this lets you use the existing
>> pattern.
>>
>> On Wed, Aug 17, 2022 at 1:26 PM Jonathan Vanasco 
>> wrote:
>>
>>> If it's read-only, i would not have it join the transaction and just
>>> create the cleanup subscriber in the @reify .
>>>
>>> > # Because this was in the tutorial.
>>>
>>> I believe that is in there because of me. This pattern is used to
>>> provide access to the current request within SqlAlchemy objects and various
>>> @property or @reify decorated methods.  Without it, you must explicitly
>>> pass in a request (so no decorators) or use the `get_current_request`
>>> function which should generally be avoided.  There is a bit of discussion
>>> on it in the PR, and the cookiecutter template has many notes on it. See
>>> https://github.com/Pylons/pyramid-cookiecutter-starter/pull/111
>>>
>>> On Tuesday, August 16, 2022 at 5:50:02 PM UTC-4 Mike Orr wrote:
>>>
 The SQLite database is pregenerated for a release and contains only
 reference information. It's read only to the web application. So I'm
 wondering if it's worth even hooking the session into the transaction
 manager at all. I have a request subclass, and to open a session I use
 a reified method:

 @reify
 def sa_session(self):
 engine = self.registry.sa_engine # Attribute set during startup
 configuration.
 info = {"request": self} # Because this was in the tutorial.
 sess = sqlalchemy.orm.Session(engine, info=info)
 zope.sqlalchemy.register(sess) # Is this worth doing for a
 read-only database?
 return sess

 The transaction manager closes the session for me, so without it I
 guess I'd have to have a subscriber that rolls back and closes the
 request. I don't want to have to do it in every view because it's not
 view-specific logic.

 On Tue, Aug 16, 2022 at 9:19 AM 'Jonathan Vanasco' via pylons-discuss
  wrote:
 >
 > On Tuesday, August 16, 2022 at 11:45:24 AM UTC-4 Mike Orr wrote:
 > > It is rolling back in some of my testing when there's no
 > > insert/delete/update, but I want to make sure it always does, just
 in
 > > case something somehow modifies the database when we didn't intend
 to.
 > > It's not that big a deal but it's what I'd like. I'm not sure if
 > > SQLAlchemy is issuing rollback if there were no changes, or if it
 will
 > > always do so.
 >
 > That's from SQLAlchemy. It will rollback if there were no database
 writes. SQLAlchemy is unaware of raw sql being a write operation, so you
 need to use the `mark_changed` function from zope.sqlalchemy. This is a
 weird idiosyncrasy of SQLAlchemy and transaction - the transaction could be
 completely successful, but SQLAlchemy will rollback because there was no
 activity within it's scope.
 >
 > It sounds like you're trying to do the opposite of what the
 `transaction` package is designed to do.
 >
 > The way I normally deal with situations like that is to control if
 SQLAlchemy joins the transaction or not. In most projects, I only use the
 transaction on specific views that require this type of integration - such
 as anything that sends an email (pyramid_mailer integrates with
 pyramid_tm).
 >
 > It a

Re: [pylons-discuss] Pyramid Response with File-like .write() interface

2022-08-10 Thread Mikko Ohtamaa
Hi Michael, others,

On Tue, 9 Aug 2022 at 20:28, Michael Merickel  wrote:

> This harkens back to the discouraged write() callable in WSGI PEP 
> returned by the start_response() invocation. The PEP as well as Pyramid as
> a framework would encourage you to map the logic into an app_iter as Bert
> suggested.
>
> I think you'll want to define a file-like object that you can write to and
> set as the app_iter. The question will be whether you try to do this by
> writing from a separate thread or in some other way because once you return
> control to the WSGI server to iterate on your app_iter then you are no
> longer in control - you'll need some buffer between where you're generating
> your parquet file and what you're returning from the app_iter. I don't
> think a simple tempfile is good enough because you want the app_iter to
> wait instead of stopping when it hits an EOF unless you know that you've
> reached the end of the buffer.
>
>
Thank you for the good commentary.

This is very good insight, I didn't think about the threading issue. I
think I will attempt an approach where I just use a buffer like Theron
mentioned and then have a library to write from the buffer from another
thread.

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvKj%3DUAeESmWmauVnhBzSObH3jhKeori7GwOJkKkvaPKA%40mail.gmail.com.


[pylons-discuss] Pyramid Response with File-like .write() interface

2022-08-09 Thread Mikko Ohtamaa
Hi all,

I'd like to stream dynamically generated Parquet-files from Pyramid server.
Parquet library itself offers writing to any file-like object. I am aware
of app_iter and FileResponse interfaces in Pyramid. However, does Pyramid
(or any example or utility class) offer a Python file-like interface, where
I could just dynamically .write() stuff?

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUudomfEGYnqAUk57XgOvatDLtFGGk%2Be5tFzu0w81Ez4Lg%40mail.gmail.com.


[pylons-discuss] Pyramid, partial and resumable downloads, HTTP Accept Ranges

2022-06-28 Thread Mikko Ohtamaa
Hi,

What would be an easy way to support partial downloads / resumes with
Pyramid? Namely HTTP Accept Ranges come to my mind, but there could be
others.

- Serving files directly from FS using FileResponse

- Using gunicorn as a web server

https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.5

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUurRhwaqBem%3DVi3OEYWw-oMZh0fhRqCqZcjPiGibyO8Rw%40mail.gmail.com.


Re: [pylons-discuss] Waitress and multiprocess pooling

2022-05-23 Thread Mikko Ohtamaa
Hi,


> What is your gunicorn config?
>

The config is below. Just to clarify, the performance issues (latency) were
with Waitress and now after switching to gunicorn all the issues have
pretty much disappeared.

gunicorn \
  --name backend \
  --bind 127.0.0.1:3456 \
  --workers 8 \
  --threads 2 \
  --env "SCRIPT_NAME=/api" \
  --statsd-host "localhost:8125" \
  --access-logfile logs/gunicorn_access.log \
  --error-logfile logs/gunicorn_error.log \
  "backend.server.server:gunicorn_entry_point()"

>
>
> On May 23, 2022, at 04:52, Mikko Ohtamaa  wrote:
>
> 
> Hi all,
>
> Thank you for your kind support.
>
> We have been running a Gunicorn for half a week now and you can clearly
> where we switched over, as the request latency is much more stable none. We
> also managed to solve all configure problems with Gunicorn thanks to your
> kind help.
>
> Backend latency:
>
> 
>
> Even PostgreSQL latency is more controlled now, don't though not sure if I
> understand why - probably something to do with PSQL, Waitress, psycopg2 and
> SQLAlchemy connection pooling.
>
> 
>
>
>
> Br,
> Mikko
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvVk43R8HCnDvWWipi3%3D54hKbF%3DjnDosMP%3D%3DTNS%3D2JN-g%40mail.gmail.com
> <https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvVk43R8HCnDvWWipi3%3D54hKbF%3DjnDosMP%3D%3DTNS%3D2JN-g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/BFE62D2E-90DF-432E-80CC-A2235375D89C%40gmail.com
> <https://groups.google.com/d/msgid/pylons-discuss/BFE62D2E-90DF-432E-80CC-A2235375D89C%40gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuX40NcPtkU%2BW%3DU9H504Re0_qJsJnLFtLqq7YORGJR3wQ%40mail.gmail.com.


Re: [pylons-discuss] Re: Waitress and multiprocess pooling

2022-05-18 Thread Mikko Ohtamaa
On Fri, 13 May 2022 at 00:14, Jonathan Vanasco  wrote:

> - What's the recommended modern multiprocess enabled web server to do more
> scaleable Pyramid hosting?
>
> I like uWSGI, but others like gunicorn and I think there is another
> popular option.
>

I decided to go with Gunicorn, because I used uWSGI extensively. Gunicorn
is somewhat easier to manage with modern Python package management tools
like Poetry, plus you do not encounter the potential issues raising from
compiling C.

So far so good, only option I missing from Gunicorn is Waitress's
"url_prefix". Is there a generic way for setting the WSGI application root
/  URL prefix that is not specific to Waitress?

Opened a StackOverflow question on this one:
https://stackoverflow.com/questions/72284506/setting-application-url-prefix-with-gunicorn

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtMQwaPvG3QdrjGgpt9sB_pHb3ZHzODF_V1TN56T%2BGmOw%40mail.gmail.com.


Re: [pylons-discuss] Re: Waitress and multiprocess pooling

2022-05-13 Thread Mikko Ohtamaa
>
> Regardless of the server you choose, please be aware they may (though I am
> pretty sure they all will) all cause issues with your current codebase due
> to the characteristics of copy-on-write memory optimization.  Usually the
> issues I've seen are with database connections and random seed generators.
> Most of the libraries you are probably using will support correcting this
> with specific calls to make after the process forks.  If you're using
> SqlAlchemy, look at Engine.dispose() and most crypto libraries have an
> `atfork` function.
>

Thank you Jonathan. This is golden, rarely seen, insight.

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsLPsfw7AMzf2T5GJUrt6BdTeo9FW9Tyf0g46XCLES%3DKg%40mail.gmail.com.


Re: [pylons-discuss] Waitress and multiprocess pooling

2022-05-13 Thread Mikko Ohtamaa
Apologies for a "pop up" visit here, I have been AWOL forever, but I think
> I do know an answer to at least the first question.
>
>
You can check out any time you like But you can never leave.

https://www.youtube.com/watch?v=EqPtz5qN7HM

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuZbkBKVgHU%3DniVqJJxUAq9QO4PxB-J4DqQR470ZwyNxw%40mail.gmail.com.


[pylons-discuss] Waitress and multiprocess pooling

2022-05-12 Thread Mikko Ohtamaa
Hi,

I am running a Pyramid based website and now traffic is picking up. I feel
I might bump the problems of Waitress scalability soon. As far as I
understand, Waitress does not offer multiple process pooling modes, only
threading. This, combined with Python GIL, might cause problems if requests
start to be more and more CPU bound.

- Am I correct and Waitress is limited by Python threading?

- What's the recommended modern multiprocess enabled web server to do more
scaleable Pyramid hosting?

Thank you,
Mikko

Ps. Site is here, also we are hiring if anyone is looking for gigs or jobs
in Pyramid + SQLAlchemy:

https://tradingstrategy.ai/

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvvcDM%2B2D4Pw0crPA3dXjUkiz1_hSDftEpuXgODK_b50A%40mail.gmail.com.


Re: [pylons-discuss] Looking for best option for Pyramid deployment

2022-02-20 Thread Mikko Ohtamaa
Hi Thierry,


I've built a custom content management framework based on Pyramid; it's a
> classic web application, based on ZODB and RelStorage with a PostgreSQL
> backend, a Redis cache and an Elasticsearch index, and I'm actually looking
> for the best production deployment option.
> Until now, I always used Apache with mod_wsgi, and I'm actually quite
> happy with it, but I'd like to know if there is a better option with better
> performance!
> In development mode, I already tried using "native" Waitress server, a
> GUnicorn server, and I just tried using Pypy with Waitress or GUnicorn but
> performances were quite "disappointing"!
>

I have been running Pyramid behind Apache, Nginx reverse proxies with
mod_wsgi, Uwsgi and plenty of other options. I am currently running
Cloudflare + Caddy + Waitress combination.

- Cloudflare is the easiest CDN for static media files, making JS and CSS
load an order of magnitude faster if they were served from my web server
- Caddy is way simpler to configure than Apache or Nginx, especially want
comes to HTTPS, but still quite performant
- Waitress is good enough and it is headache-free, unlike uWSGI or mod_wsgi
- 99% times the performance penalty does not depend on the web server
components, but the Python application itself. There is no meaningful
performance differences between web servers until you start to do dozens of
requests per second.

The architecture I am running is overviewed here:
https://tradingstrategy.ai/blog/building-cryptocurrency-website

Here is the Caddy configuration for Waitress reverse proxy:
https://github.com/tradingstrategy-ai/proxy-server/blob/master/Caddyfile#L29

Best regards,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUv5a1m7i%2BGv%2BCyKND8mC3sxFm5o6RVSOGw%3DK6upRANWsw%40mail.gmail.com.


Re: [pylons-discuss] Programmatically creating and closing Waitress server: OSError: [Errno 9] Bad file descriptor

2022-01-25 Thread Mikko Ohtamaa
Hi Bert,

On Mon, 24 Jan 2022 at 19:11, Bert JW Regeer  wrote:

> It’s using waitress under the hood, it’s not single threaded.
>

Thank you so much. I had somehow misunderstood it is not the real thing.
Then will proceed with StopableWSGIServer.

I assume I can pass the same construction arguments I could pass for a
normal Waitress?

Br,
Mikko


>
> On Jan 24, 2022, at 09:51, Mikko Ohtamaa  wrote:
>
> Hi Michael,
>
>
>> Have you looked at the StopableWSGIServer in webtest? I wonder if it can
>> help debug what you've been seeing.
>>
>>
>> https://docs.pylonsproject.org/projects/webtest/en/latest/api.html#webtest.http.StopableWSGIServer
>>
>
> Thanks for the heads up. In this case, I hope to have a proper process and
> threading support for the server. FAIK StopableWSGIServer is
> single-threaded, but I could be wrong.
>
> -Mikko
>
>
>>
>> - Michael
>>
>> On Jan 22, 2022, at 05:11, Mikko Ohtamaa  wrote:
>>
>> Hi,
>>
>> I am trying to add webhook support to the otherwise command-line
>> application using Waitress web server. Webhook endpoints are defined as
>> Pyramid routes. I also wish to test this functionality using pytest.
>>
>> The server gets created fine, but on pytest shutdown, I am getting an
>> error: OSError: [Errno 9] Bad file descriptor. What would be the nice way
>> to spin Waitress up and down on demand?
>>
>> How do I create the server instance:
>>
>> def create_webhook_server(host: str, port: int, username: str, password:
>> str, queue: Queue) -> MultiSocketServer:
>> app = create_pyramid_app(username, password, queue, production=False)
>> server = create_server(app, host=host, port=port)
>> logger.info("Webhook server will spawn at %s:%d", host, port)
>> return server
>>
>> How do I start and test the server in the unit test:
>>
>> def test_auth_ok():
>> """Username and password allow to access the webhook"""
>> queue = Queue()
>> server = create_webhook_server("127.0.0.1", 5000, "test", "test",
>> queue)
>> server_url = "http://test:test@127.0.0.1:5000";
>> webhook_thread = Thread(target=server.run)
>> webhook_thread.start()
>> # Test home view
>> resp = requests.get(server_url)
>> assert resp.status_code == 200
>> server.close()
>>
>> The exception I am getting:
>>
>> tests/test_webhook_auth.py::test_auth_ok
>>   
>> /Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/_pytest/threadexception.py:75:
>> PytestUnhandledThreadExceptionWarning: Exception in thread Thread-1
>>
>>   Traceback (most recent call last):
>> File 
>> "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
>> line 973, in _bootstrap_inner
>>   self.run()
>> File 
>> "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
>> line 910, in run
>>   self._target(*self._args, **self._kwargs)
>> File
>> "/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/server.py",
>> line 322, in run
>>   self.asyncore.loop(
>> File
>> "/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
>> line 245, in loop
>>   poll_fun(timeout, map)
>> File
>> "/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
>> line 172, in poll
>>   r, w, e = select.select(r, w, e, timeout)
>>   OSError: [Errno 9] Bad file descriptor
>>
>> warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
>>
>> tests/test_webhook_auth.py::test_auth_failed
>>   
>> /Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/_pytest/threadexception.py:75:
>> PytestUnhandledThreadExceptionWarning: Exception in thread Thread-2
>>
>>   Traceback (most recent call last):
>> File 
>> "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
>> line 973, in _bootstrap_inner
>>   self.run()
>> File 
>> "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3

Re: [pylons-discuss] Programmatically creating and closing Waitress server: OSError: [Errno 9] Bad file descriptor

2022-01-24 Thread Mikko Ohtamaa
Hi Michael,


> Have you looked at the StopableWSGIServer in webtest? I wonder if it can
> help debug what you've been seeing.
>
>
> https://docs.pylonsproject.org/projects/webtest/en/latest/api.html#webtest.http.StopableWSGIServer
>

Thanks for the heads up. In this case, I hope to have a proper process and
threading support for the server. FAIK StopableWSGIServer is
single-threaded, but I could be wrong.

-Mikko


>
> - Michael
>
> On Jan 22, 2022, at 05:11, Mikko Ohtamaa  wrote:
>
> Hi,
>
> I am trying to add webhook support to the otherwise command-line
> application using Waitress web server. Webhook endpoints are defined as
> Pyramid routes. I also wish to test this functionality using pytest.
>
> The server gets created fine, but on pytest shutdown, I am getting an
> error: OSError: [Errno 9] Bad file descriptor. What would be the nice way
> to spin Waitress up and down on demand?
>
> How do I create the server instance:
>
> def create_webhook_server(host: str, port: int, username: str, password:
> str, queue: Queue) -> MultiSocketServer:
> app = create_pyramid_app(username, password, queue, production=False)
> server = create_server(app, host=host, port=port)
> logger.info("Webhook server will spawn at %s:%d", host, port)
> return server
>
> How do I start and test the server in the unit test:
>
> def test_auth_ok():
> """Username and password allow to access the webhook"""
> queue = Queue()
> server = create_webhook_server("127.0.0.1", 5000, "test", "test",
> queue)
> server_url = "http://test:test@127.0.0.1:5000";
> webhook_thread = Thread(target=server.run)
> webhook_thread.start()
> # Test home view
> resp = requests.get(server_url)
> assert resp.status_code == 200
> server.close()
>
> The exception I am getting:
>
> tests/test_webhook_auth.py::test_auth_ok
>
> /Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/_pytest/threadexception.py:75:
> PytestUnhandledThreadExceptionWarning: Exception in thread Thread-1
>
>   Traceback (most recent call last):
> File 
> "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
> line 973, in _bootstrap_inner
>   self.run()
> File 
> "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
> line 910, in run
>   self._target(*self._args, **self._kwargs)
> File
> "/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/server.py",
> line 322, in run
>   self.asyncore.loop(
> File
> "/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
> line 245, in loop
>   poll_fun(timeout, map)
> File
> "/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
> line 172, in poll
>   r, w, e = select.select(r, w, e, timeout)
>   OSError: [Errno 9] Bad file descriptor
>
> warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
>
> tests/test_webhook_auth.py::test_auth_failed
>
> /Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/_pytest/threadexception.py:75:
> PytestUnhandledThreadExceptionWarning: Exception in thread Thread-2
>
>   Traceback (most recent call last):
> File 
> "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
> line 973, in _bootstrap_inner
>   self.run()
> File 
> "/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
> line 910, in run
>   self._target(*self._args, **self._kwargs)
> File
> "/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/server.py",
> line 322, in run
>   self.asyncore.loop(
> File
> "/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
> line 245, in loop
>   poll_fun(timeout, map)
> File
> "/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
> line 172, in poll
>   r, w, e = select.select(r, w, e, timeout)
>   OSError: [Errno 9] Bad file descriptor
>
> warnings.warn(pyte

[pylons-discuss] Programmatically creating and closing Waitress server: OSError: [Errno 9] Bad file descriptor

2022-01-22 Thread Mikko Ohtamaa
Hi,

I am trying to add webhook support to the otherwise command-line
application using Waitress web server. Webhook endpoints are defined as
Pyramid routes. I also wish to test this functionality using pytest.

The server gets created fine, but on pytest shutdown, I am getting an
error: OSError: [Errno 9] Bad file descriptor. What would be the nice way
to spin Waitress up and down on demand?

How do I create the server instance:

def create_webhook_server(host: str, port: int, username: str, password:
str, queue: Queue) -> MultiSocketServer:
app = create_pyramid_app(username, password, queue, production=False)
server = create_server(app, host=host, port=port)
logger.info("Webhook server will spawn at %s:%d", host, port)
return server

How do I start and test the server in the unit test:

def test_auth_ok():
"""Username and password allow to access the webhook"""
queue = Queue()
server = create_webhook_server("127.0.0.1", 5000, "test", "test", queue)
server_url = "http://test:test@127.0.0.1:5000";
webhook_thread = Thread(target=server.run)
webhook_thread.start()
# Test home view
resp = requests.get(server_url)
assert resp.status_code == 200
server.close()

The exception I am getting:

tests/test_webhook_auth.py::test_auth_ok

/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/_pytest/threadexception.py:75:
PytestUnhandledThreadExceptionWarning: Exception in thread Thread-1

  Traceback (most recent call last):
File 
"/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
line 973, in _bootstrap_inner
  self.run()
File 
"/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
line 910, in run
  self._target(*self._args, **self._kwargs)
File
"/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/server.py",
line 322, in run
  self.asyncore.loop(
File
"/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
line 245, in loop
  poll_fun(timeout, map)
File
"/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
line 172, in poll
  r, w, e = select.select(r, w, e, timeout)
  OSError: [Errno 9] Bad file descriptor

warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))

tests/test_webhook_auth.py::test_auth_failed

/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/_pytest/threadexception.py:75:
PytestUnhandledThreadExceptionWarning: Exception in thread Thread-2

  Traceback (most recent call last):
File 
"/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
line 973, in _bootstrap_inner
  self.run()
File 
"/usr/local/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py",
line 910, in run
  self._target(*self._args, **self._kwargs)
File
"/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/server.py",
line 322, in run
  self.asyncore.loop(
File
"/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
line 245, in loop
  poll_fun(timeout, map)
File
"/Users/moo/Library/Caches/pypoetry/virtualenvs/tradeexecutor-13XfP0tc-py3.9/lib/python3.9/site-packages/waitress/wasyncore.py",
line 172, in poll
  r, w, e = select.select(r, w, e, timeout)
  OSError: [Errno 9] Bad file descriptor

warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtiHH3N00sUthcUKj6Ur-ZjNsAGkXByo5FEPvuKZY%3DgNg%40mail.gmail.com.


[pylons-discuss] Hiring Pyramid / SQLAlchemy devs for an algorithmic trading product

2022-01-07 Thread Mikko Ohtamaa
Hi all,

We have recently launched a new service Trading Strategy:
https://tradingstrategy.ai/

* What our product does can be read here:
https://tradingstrategy.ai/blog/announcing-trading-strategy-protocol

* What is our software stack can be read here:
https://tradingstrategy.ai/blog/building-cryptocurrency-website

We are currently looking for

- Frontend developers with existing Svelte experience
- Backend developers with existing SQLAlchemy experience

All work is fully remote with 2-4 trips to Europe every year. Please let me
know if anyone is looking for new ventures in 2022.

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtv3uuNx0NXgeD-ZKDJPARiCdS5SH4v%3Dm5-aMAQOuCKZg%40mail.gmail.com.


Re: [pylons-discuss] Serving large authenticated files

2021-07-14 Thread Mikko Ohtamaa
Hi Theron and others,

On Wed, 14 Jul 2021 at 17:57, Theron Luhn  wrote:

> Pyramid has FileResponse
> https://docs.pylonsproject.org/projects/pyramid/en/latest/api/response.html#pyramid.response.FileResponse,
> which does use wsgi.file_wrapper you linked to (if available).
>

This is perfect and exactly what I was looking for. Thank you.


>
> Generally in this situation I offload the file to S3 or similar, and have
> Pyramid generate a signed URL to redirect to.  Operationally much simpler.
>

A good point. I will check this out if this makes sense pricing wise. I am
not using EC2 or any Amazon infrastructure, as I have specific processing
needs for which their cloud servers are too expensive.

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsTO%2Bp0%2BcGLBvXOyPmhPPauGHdA2413sOq3WoXu%2B8ngeQ%40mail.gmail.com.


[pylons-discuss] Serving large authenticated files

2021-07-14 Thread Mikko Ohtamaa
Hi,

I need to serve large authenticated files (several gigabytes). I will do an
API key check before the user can download a file.

What is the most efficient way to serve these out from Pyramid? Assuming I
do not want to block processes or threads - is it possible?

- Zope 2 used to have a sendfile (
https://www.python.org/dev/peps/pep-0333/#id36) - is there anything
equivalent for waitress

- Any ideas about caching the file in the frontend servers (Caddy,
Cloudflare) and then just creating a short-lived HTTP redirect (<1h) to the
actual target

- Other ideas

Cheers,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuTG7xZ9tFf5raSmotjOWPJx31dcXyDujk4222_GDq74w%40mail.gmail.com.


Re: [pylons-discuss] Problem between Pyramid's CSRF protection and Deform

2021-04-28 Thread Mikko Ohtamaa
Hi Laurent,


>
> The Deform Demo
> (https://deformdemo.pylonsproject.org/pyramid_csrf_demo/) shows how to
> use a deferred value to create hidden field "csrf_token" in the
> generated forms
>


>
> But there's a problem: the token generated that way doesn't have the
> same value as when I directly call get_csrf_token() in a template.
>

Usually, this value is tied to the user session. Out of my head, without
inspecting the code, I would suspect issues with, or mishandling of,
cookies, sessions and such.

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuVJAJ6rAOrgmQ0W%2Bu_RVfo598oWU%3D5U_k-4JrvtOM7Cg%40mail.gmail.com.


Re: [pylons-discuss] Live event notification through ASGI / websockets

2020-09-25 Thread Mikko Ohtamaa
Hi,

I cannot answer your question, but I have two ideas about what might or
might not help your use case.

- What I have seen many projects doing is to handle notifications via
Firebase https://firebase.google.com/ - both web and mobile - this is
because Firebase is "proven" and also supports native mobile app
notifications easily

- getstream.io provides activity feed tyle notifications as a SaaS service.
I think they started as an open source Python project long time ago, but
now have only Saas model https://getstream.io/

Br,
Mikko

On Fri, 25 Sep 2020 at 10:39, Nick Beeuwsaert 
wrote:

> Hello,
>
> I was wondering if anyone had any experience / ideas regarding using
> Pyramid and ASGI to deliver live notifications through a websocket stream?
>
> I've followed the info here
> ,
> regarding getting ASGI set up and have a working websocket now. I just need
> help notifying any connected websockets of events.
>
> So far I've tried pushing to an asyncio queue, but I could just be using
> queues wrong.
>
> Curious if anyone has any ideas for this
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/6b902987-f86b-48ee-b24d-5f66259bef4fo%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvOR_BtcP073RnxXt17546HzJ3Ypr9aCrprbHftSWWKuA%40mail.gmail.com.


Re: [pylons-discuss] Recommendation for a Python-based wiki

2020-04-19 Thread Mikko Ohtamaa
Hi,

Another point to make, Gitbook is good for user guides (no cross
references, no source code snippets, etc.) Gitbook also offers hosting and
very friendly editor. Many OSS projects are using it.

Br,
Mikko

On Sun, 19 Apr 2020 at 22:02, Mikko Ohtamaa  wrote:

> Hi all,
>
> Here is a "modern" option. Netlify CMS provides an online editor that
> mimics static site generator workflow.
>
> * You can edit pages and posts on their website
> * Changes are pushed to Github document repo
> * Netlify will automatically rebuild a static web site and host it
>
> Netlify is free for hosting and in many ways easier and more powerful than
> e.g. readthedocs or Github. However, their online editor + Github
> integration is still very young.
>
> Br,
> Mikko
>
> On Sun, 19 Apr 2020 at 21:07, Sydo Luciani  wrote:
>
>> What do you think of :
>>
>> https://github.com/SystematicD/pyramid_wiki
>>
>> Flat file based documentation powered by Pyramid traversal and Deform.
>>
>>
>>
>> On Saturday, 2 September 2017 00:52:13 UTC-5, Steve Piercy wrote:
>>>
>>> Wikis are crapware.  They're a headache to maintain.
>>>
>>> The Pylons Project contributors use GitHub repos and Read the
>>> Docs to produce user guides and other documentation.
>>>
>>> --steve
>>>
>>>
>>> On 9/1/17 at 8:01 PM, cct...@gmail.com (Sean Tan) pronounced:
>>>
>>> >Hi. I want to write a user guide for a client. I thought it is
>>> >better to host it online, so I don't have to periodically email
>>> >an updated version to my client. I wonder why Wiki engines do
>>> >you Pyramid folks use? Any suggestions?
>>> >
>>>
>>> 
>>> Steve Piercy, Soquel, CA
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to pylons-discuss+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pylons-discuss/25fadd39-8e3c-4ff9-bd8c-defc26606d97%40googlegroups.com
>> <https://groups.google.com/d/msgid/pylons-discuss/25fadd39-8e3c-4ff9-bd8c-defc26606d97%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUt%3DhiYaQSsyqaVO8Go9fpvNwCrj8W%2BT5keR9vsDMnYLfQ%40mail.gmail.com.


Re: [pylons-discuss] Recommendation for a Python-based wiki

2020-04-19 Thread Mikko Ohtamaa
Hi all,

Here is a "modern" option. Netlify CMS provides an online editor that
mimics static site generator workflow.

* You can edit pages and posts on their website
* Changes are pushed to Github document repo
* Netlify will automatically rebuild a static web site and host it

Netlify is free for hosting and in many ways easier and more powerful than
e.g. readthedocs or Github. However, their online editor + Github
integration is still very young.

Br,
Mikko

On Sun, 19 Apr 2020 at 21:07, Sydo Luciani  wrote:

> What do you think of :
>
> https://github.com/SystematicD/pyramid_wiki
>
> Flat file based documentation powered by Pyramid traversal and Deform.
>
>
>
> On Saturday, 2 September 2017 00:52:13 UTC-5, Steve Piercy wrote:
>>
>> Wikis are crapware.  They're a headache to maintain.
>>
>> The Pylons Project contributors use GitHub repos and Read the
>> Docs to produce user guides and other documentation.
>>
>> --steve
>>
>>
>> On 9/1/17 at 8:01 PM, cct...@gmail.com (Sean Tan) pronounced:
>>
>> >Hi. I want to write a user guide for a client. I thought it is
>> >better to host it online, so I don't have to periodically email
>> >an updated version to my client. I wonder why Wiki engines do
>> >you Pyramid folks use? Any suggestions?
>> >
>>
>> 
>> Steve Piercy, Soquel, CA
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/25fadd39-8e3c-4ff9-bd8c-defc26606d97%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUs9p1yLnyNbP0qb1OwSonJah4WMNFrZtyHa8%3DpzPxKj0A%40mail.gmail.com.


Re: [pylons-discuss] pyramid_tm - is there an acceptable way to unjoin the transaction and use explicit commits?

2020-02-07 Thread Mikko Ohtamaa
one of my apps uses pyramid_tm, but has reached a point where one (possibly
> two) views (out of dozens) need to make explicit commits with the
> SqlAlchemy session.
>

Because this does not fit well in the view/request model, I would usually
try to offload these tasks to a worker processes (Celery) where it is much
easier to have a explicit control over the transaction cycle. A request
would only serve as a trigger for the background process. It does not work
for all kind of use cases, though.

-Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUv3X0WNkKENzAH-nt7_tR34KLTeJde-jcfOs9r35xRyfw%40mail.gmail.com.


Re: [pylons-discuss] most performant way to run WSGI app as single process

2019-09-18 Thread Mikko Ohtamaa
- I also do 1 proc/Docker image, I would recommend to have a look on
> https://pythonspeed.com/docker/ for various things to keep in mind if you
> haven’t seen it already.
>

I am very familiar with the trade offs and tuning of process vs. threads.
Now, when this conversation is going on, would someone comment trade offs
between container vs. process? Is it radically more memory/CPU sensitive?
Are things like logging and external service API access harder to arrange?
What are the trade offs and benefits?

Br,
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUum%2BvHLxWMDqHiiLvHZxq%2BrQu-jAgL7AN6pW7%3DgbQq%2BHw%40mail.gmail.com.


Re: [pylons-discuss] most performant way to run WSGI app as single process

2019-09-12 Thread Mikko Ohtamaa
> * I've found a forking server like uwsgi / gunicorn to be the most
> performant strategy for most situations, as their "max_requests" settings
> to restart workers will eliminate most issues with process growth or memory
> leaks.  they both also offer numerous deployment and management benefits
>

You might be able to squeeze more juice out of uWSGI, but Gunicorn is pure
Python making it easier to deploy, manage and diagnose.

Also the performance depends on the load characteristics - the usual
bottleneck is SQL database performance. For static assets and such - they
should not be served from WSGI in the first place and you can nicely
offload this to CloudFlare or similar automatically. Real time like,
WebSockets, is a different beast and not relevant for WSGI.

Br,
Mikko



> and in addition to what Bert said...
>
> every deployment strategy has a pros and cons that are from tradeoffs in
> the design of the infrastructure. there is no overall "best option". your
> code could run blazingly fast on one stack with specific resources, and run
> terribly on another.
>
> while i have a handful of apps that could redeploy using a single-process
> strategy with no impact, moving my main app from a forked multi-process
> model to a series of single-process containers would greatly increase our
> cloud computing bills (we tested it a while back, and it would have
> required way more servers/resources).
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/4459efb5-7ba5-487d-8409-3089ad3c308b%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUt%3D8wX4cWvEM4BVJn2hPOZ2btm5Jv0sO4RfLtSr56K1%2Bw%40mail.gmail.com.


Re: [pylons-discuss] RotatingFileHandler and pserve --reload

2019-01-25 Thread Mikko Ohtamaa
On Fri, 25 Jan 2019 at 21:13, Marcus Mann  wrote:

> So what if I moved the logging stuff into the __init__.py and remove all
> the logging stuff from development.ini? Would that solve my issue?
>

Some ideas with lack of better information:

1) Not sure about pserve, but uWSGI had an event it fires after forking, so
could quite deterministically initialise post-fork stuff

2) Lazily configure loggers when they are first time referred within HTTP
request processing (not sure how either)

-Mikko


>
> On Friday, January 25, 2019 at 4:01:40 PM UTC-5, Michael Merickel wrote:
>>
>> The issue is that pserve configures logging *before* forking the
>> children, while in the monitor process, and then configures logging again
>> in the child subprocesses after forking. This is an issue and hasn't been
>> pointed out by anyone before. This means you always have two processes
>> opening those files.
>>
>> I recommend logging to stderr instead and handling file rotation and such
>> external to the processes themselves, however it doesn't mean this isn't a
>> bug.
>>
>> Possible solutions:
>>
>> 1) Do not configure logging in the parent process, or just do it using
>> basicConfig. Only use your logging config in the child process. This is
>> probably an acceptable solution but means that the logging coming from
>> hupper in the parent process would not use the logging formatters/handlers
>> that are in your config which is slightly surprising.
>>
>> 2) Keep doing what we're doing and say something about how it's not
>> supported.
>>
>> 3) ???
>>
>> - Michael
>>
>> On Fri, Jan 25, 2019 at 2:46 PM Marcus Mann  wrote:
>>
>>> Hello!
>>> I am trying to setup logging. I have run into a bug. If I
>>> use RotatingFileHandler and try to start my pyramid setup with pserve
>>> --reload development.ini, it throws an error similar to this when it tries
>>> to rotate the file:
>>>
>>> PermissionError: [WinError 32] The process cannot access the file
>>> because it is being used by another process: 'C:\\var\\log\\testing.log'
>>> -> 'C:\\var\\log\\testing.log.1'
>>>
>>> Here is the logging portion of my development.ini:
>>>
>>> [loggers]
>>> keys = root, companalysis
>>>
>>> [handlers]
>>> keys = console, filelog, debugfilelog
>>>
>>> [formatters]
>>> keys = generic
>>>
>>> [logger_root]
>>> level = DEBUG
>>> handlers = console, debugfilelog
>>>
>>> [logger_companalysis]
>>> level = DEBUG
>>> handlers = filelog
>>> qualname = companalysis
>>>
>>> [handler_console]
>>> class = StreamHandler
>>> args = (sys.stderr,)
>>> level = INFO
>>> formatter = generic
>>>
>>> [handler_filelog]
>>> class=handlers.RotatingFileHandler
>>> level=DEBUG
>>> args=('/var/log/testing.log','a',1000,100)
>>> formatter=generic
>>>
>>> [handler_debugfilelog]
>>> class=handlers.RotatingFileHandler
>>> level=NOTSET
>>> args=('/var/log/toolbox_debugging.log','a',1000,100)
>>> formatter=generic
>>>
>>> [formatter_generic]
>>> format = %(asctime)s %(levelname)-5.5s
>>> [%(name)s:%(lineno)s][%(threadName)s] %(message)s
>>>
>>> I am on Windows 10.
>>>
>>> If I start it without the --reload tag, it works as expected.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "pylons-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to pylons-discus...@googlegroups.com.
>>> To post to this group, send email to pylons-...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pylons-discuss/098b16e7-1955-4d21-9f4c-6a32d82fe103%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/7aca6559-568d-4ff6-8aa1-5af39abe9bc2%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvEYr3j246DiiRbbH_FKc9pcp7F-%3DrS0Fku%2BWyccRhwOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout

Re: [pylons-discuss] RotatingFileHandler and pserve --reload

2019-01-25 Thread Mikko Ohtamaa
Hi Marcus,


Hello!
> I am trying to setup logging. I have run into a bug. If I
> use RotatingFileHandler and try to start my pyramid setup with pserve
> --reload development.ini, it throws an error similar to this when it tries
> to rotate the file:
>

Maybe this
https://docs.python.org/3/library/logging.handlers.html#watchedfilehandler



>
> PermissionError: [WinError 32] The process cannot access the file because
> it is being used by another process: 'C:\\var\\log\\testing.log' ->
> 'C:\\var\\log\\testing.log.1'
>
> Here is the logging portion of my development.ini:
>
> [loggers]
> keys = root, companalysis
>
> [handlers]
> keys = console, filelog, debugfilelog
>
> [formatters]
> keys = generic
>
> [logger_root]
> level = DEBUG
> handlers = console, debugfilelog
>
> [logger_companalysis]
> level = DEBUG
> handlers = filelog
> qualname = companalysis
>
> [handler_console]
> class = StreamHandler
> args = (sys.stderr,)
> level = INFO
> formatter = generic
>
> [handler_filelog]
> class=handlers.RotatingFileHandler
> level=DEBUG
> args=('/var/log/testing.log','a',1000,100)
> formatter=generic
>
> [handler_debugfilelog]
> class=handlers.RotatingFileHandler
> level=NOTSET
> args=('/var/log/toolbox_debugging.log','a',1000,100)
> formatter=generic
>
> [formatter_generic]
> format = %(asctime)s %(levelname)-5.5s
> [%(name)s:%(lineno)s][%(threadName)s] %(message)s
>
> I am on Windows 10.
>
> If I start it without the --reload tag, it works as expected.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/098b16e7-1955-4d21-9f4c-6a32d82fe103%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtNhPbrwxn%3Dxg%2BMu42fC-vMxdxoHT-vx_7%3D5%2B0%3DLp94gA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] processing after responding to client

2018-11-12 Thread Mikko Ohtamaa
> My problem is that while 99% of the views make read-only requests to the
> database, and thus are very fast, the analytics event is a writing and can
> be slow occasionally.
>

You can do post commit actions with SQLAlchemy and zope.sqlaclhemy.

1. Response gets served
2. Database transaction get committed for this request
3. Post transaction actions

Example:

https://stackoverflow.com/questions/15593516/how-to-run-a-script-after-pyramids-transaction-manager-has-returned

Please not that thread local `transaction.manager` might be discouraged
nowadays, but not sure what is the best practice to get a transaction
manager for your request.

Br,
Mikko



> Would it be possible to somehow send the request to the client and still
> keep processing the view? Like a send() + end() method or something
> similar, without returning?
>
> // Adding to a tasks queue is not an option as it'd be an overkill and an
> overcomplicated solution, which wouldn't work for hundreds of thousands of
> events per day.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/c44e1af6-8c30-478e-9baf-d7fd8c93e0b5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtJnMXXTr99DCgP6LkMaCwwkAeLLqUQ5Xk_h_WjSd8XrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Understanding how to perform functional testing using transactions with pyramid + SQLAlchemy + pytest + webtest for views that use a postgreSQL database.

2018-11-05 Thread Mikko Ohtamaa
Hi dc3spp,

For inspiration, you can check out how Websauna doees it:

https://websauna.org/docs/narrative/testing/writing.html#basic-integration-testing-pattern

Pyramid does not provide you test fixtures or relevant plumping for
managing transaction lifecycle in functional testing. Your best shot is to
copy-paste fixtures from Websauna, but they come with a lot of tidbits like
INI driven configuration for development and tests alike.

-Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUs1RKRR9NJuqyDjKwYsgAw1qOtYAjjB824kom0fVM1YXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] How to send task-message after request.tm has committed?

2018-06-01 Thread Mikko Ohtamaa
Hi Jens,

You can also look here for inspiration:

https://websauna.org/docs/narrative/misc/task.html#delayed-tasks

On 1 June 2018 at 05:34,  wrote:

> Hi,
>
> Within a view function it becomes necessary to run an async task. Celery
> , Dramatiq , etc are
> frameworks to handle that. However, my async task needs to read db objects
> which have been created—and must be committed and persisted—by the view
> function that spawns the task. Thus, I need to delay spawning the task
> (i.e. sending the task’s message to the workers) until after the request’s
> db transaction has committed.
>
> The db transaction is a standard SQLAlchemy transaction. Using the commit
> veto hook
> 
> is too early. This SO answer
> 
> suggests using the repoze.tm.after_end()
>  callback, but the
> answer is about five years old now.
>
> How do I handle this scenario correctly, i.e. how do I schedule an async
> job after a request was successful? I guess I can pack up the task object,
> or a signature, and its parameters and attach them to the request from
> within the view function. But where is the right place to actually send the
> task message?
>
> Thanks!
> Jens
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/ef6bf67d-acec-4dae-b318-7749743add31%
> 40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvcOO0pYd%2Br_r20FfSsT6p_1edw7AfPrRXTqf5Z8dQUVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] How to handle DB transaction failures/request race conditions

2017-11-27 Thread Mikko Ohtamaa
Hi Jens,

You also might find some background information here:

https://websauna.org/docs/narrative/modelling/occ.html

Br,
Mikko

On 27 November 2017 at 11:00,  wrote:

> Hello,
>
> Looking at the SQLAlchemy cookie cutter
> <https://github.com/Pylons/pyramid-cookiecutter-alchemy>, a request gets
> its own transaction-backed db session, and on its way out a response
> commits that transaction and closes the session. There are activation
> <https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/#adding-an-activation-hook>
> and veto
> <https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/#adding-a-commit-veto-hook>
> hooks too.
>
> I'm trying to understand the details behind the request/response ↔ db
> session/transaction interaction.
>
> During ordinary operation, everything should work just fine and all
> modifications to ORM objects during a view functions commit with the
> response. But what happens when a transaction fails, for example because of
> a CHECK constraint?
>
> How exactly are race conditions handled: suppose two requests to the same
> endpoint at the same time, both create the same resource, one of which
> fails (well, should!) to commit. When and how is that handled?
>
> Thank you for pointers and tips and hints in advance 🤓
> Jens
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/2a39e5b2-d8fa-43be-891c-4b1cd48d465e%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/2a39e5b2-d8fa-43be-891c-4b1cd48d465e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUscUcSc-SpJ-neW2BrU7eqKr3-2uTgGPbMDv0JR_dkM0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Pyramid_tm reason for ROLLBACK

2017-10-06 Thread Mikko Ohtamaa
Hi Srikanth,

Are you using PostgreSQL? Does the transaction fail because of concurrent
transactions reading or writing same data?

Usually there should be something like this written in the logs:

sqlalchemy.exc.OperationalError: (raised as a result of Query-invoked
autoflush; consider using a session.no_autoflush block if this flush is
occurring prematurely)

(psycopg2.extensions.TransactionRollbackError) could not serialize access
due to read/write dependencies among transactions

-Mikko

On 6 October 2017 at 08:02, Srikanth Bemineni 
wrote:

> Hi,
>
> Whenever a sqlalchemy commit fails, the transaction will be automatically
> rolled back. When this does happen the pyramid_tm which commits the
> transaction should print the message with the reason for rollback.
>
> We get one simple message from sqlalchemy. Most of the times we need to
> guess the reason for the rollback.
>
> 2017-10-05 23:56:29,072 INFO  
> [sqlalchemy.engine.base.Engine:699][b'uWSGIWorker1Core0']
> ROLLBACK
>
> Is there way I can see the error , with the reason for roll back ?
>
> Srikanth B.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/2fc1209f-f677-4fbe-a572-05517c9e5462%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/2fc1209f-f677-4fbe-a572-05517c9e5462%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUs_BzGhe5%2B21nJORpqvUeBUHV6AbFwp%2B92%3DxAaJLdRtnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Porting a ZOPE (2.13) application into PYRAMID

2017-09-14 Thread Mikko Ohtamaa
Hi Roberty,

You are right; Pyramid is your best bet. Pyramid community knows ho to
interact with ZODB and Chameleon is prettty close to ZPT.  I would suggest
continuous migration approach, where you start moving views to a Pyramid
server URL by URL, using some kind URL map on the front end web server
(nginx?)

-Mikko

On 14 September 2017 at 19:12,  wrote:

> Hello to everybody,
> I have an alive application running in (on) ZOPE 2.13.
> We are maintaining the application with linux virtual machines running
> python 2.7 and ZOPE 2.13.
>
> Here are a summary description of the objects present in ZODB:
> - 335 pages are written in *ZPT *(Zope Page Template)
> - 230 pages are still written in *DTML *=> we are (slowly) rewriting them
> in *ZPT*
> - 123 javascript (*DTML *Document type) scripts
> - 919 python scripts
> - 421 *ZSQL *scripts => we are (slowly) moving SQL queries on server side
>
> Moreover, we use *ZOPE Extensions* to call *external *services that are
> - called through XML/RPC protocol
> - 80% provided by a python business application server
> - 20% provided by a java-tomcat business application server
>
> Since ZOPE is dead, or so it seems (at least as own product),
> I'm looking for a little-painful-solution to run away from ZOPE.
>
> My idea was keeping the 2 business server python and java and porting only
> the ZOPE stuff in another python framework.
>
> I thought that PYRAMID could do the job, expecially if I could port easily
> the *ZPT *pages to CAMELEON.
>
> Can anybody give any suggestion?
>
> Thank you very much,
> Roberto Vivarelli
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/1483d157-bcca-4530-95e6-f886845d9e6f%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/1483d157-bcca-4530-95e6-f886845d9e6f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUv8okEsC7_YBBw8kceuzYCy6P7m7X8x2_soBKRy7ky-_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Recommendation for a Python-based wiki

2017-09-04 Thread Mikko Ohtamaa
> Hi. I want to write a user guide for a client. I thought it is better to
> host it online, so I don't have to periodically email an updated version to
> my client. I wonder why Wiki engines do you Pyramid folks use? Any
> suggestions?
>

Without knowing the details of the complexity of the guide, I'd say Google
Docs is sufficient for such purposes. No need to get Wiki to complicate
things.

-Mikko


-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtaAGwG5cpDQy5YZGFqqBLGEw7ojc%2BLTBFLoed4pZdpnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Implementing basic authentication with persistence

2017-08-31 Thread Mikko Ohtamaa
Hi Julian,

Websauna implements basic sign in and sign up for you using SQLAlchemy
persistency and Redis for sessions:

https://websauna.org/docs/narrative/user/index.html

It also supports Facebook, Twitter and Google OAuth and various others.

Best regards,
Mikko



On 31 August 2017 at 19:42, Julian Sanchez  wrote:

> I'm getting my feet wet with Pyramid and going through the different
> tutorials, applying the concepts to the project I'm working on.  At the
> present time I'm interested in having basic authentication and storing the
> username and (securely hashed) password on a database table.
>
> Is there something already 'pre-made' that I could reuse so I don't have
> to write all the code from scratch?  I saw the tutorial on SQLAlchemy
> <https://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/wiki2/authentication.html>
> showing the registration code but we will not be using SQLAlchemy.  The other
> tutorial
> <https://docs.pylonsproject.org/projects/pyramid/en/latest/quick_tutorial/authentication.html>
> gives a flavor for checking the validity of a password but doesn't seem to
> work with a repository of any kind (particularly a user registering into a
> site).  I've seen packages like Authomatic but they seem to provide OAuth
> stuff.  Maybe someone has made an extension to Authomatic for basic
> authentication?  How are you guys implementing authentication?
>
> Thanks,
> Julian
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/59dd2c83-b286-4d85-a506-beeaca013322%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/59dd2c83-b286-4d85-a506-beeaca013322%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsLbANkgLAEczaetK%3DGN9QCUj6TQ6Q0ECbnyfE3N3Av5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] gevent/sqlalchemy/psycopg2/gunicorn setup?

2017-08-31 Thread Mikko Ohtamaa
Hi,


On 31 August 2017 at 17:19, Zsolt Ero  wrote:

> After reading zzzeek's great blog post: http://techspot.zzzeek.
> org/2015/02/15/asynchronous-python-and-databases/ and SO answer:
> https://stackoverflow.com/a/16503103/518169 I would like to use gevent /
> sqlalchemy / psycopg2 / gunicorn in a new application.
>

I had a project using SQLAlchemy, Pyramid and gevent
(gevent.monkey.patch_all()).

Before engaging to this interesting experience, I suggest you prebook a bed
in an asylum. That is the level of problems you need to debug with Python
interpreter, stdlib, web server threading, etc. All of those had subtle but
hard to debug threading issues that took days and days to debug when you no
longer can trust that lower levels of your stack (web server, database
connections, etc.) correctly behaving under asyncio. It's especially fun if
the problems only appear under a production load.

It was very happy moment when I could finally pip uninstall gevent and move
back to well proven threading model.

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUskLWJ%3DfAgUH7wzC1nQUVn0TX0n5nm%2BB_HhijdQQh61_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] pyramid and react working together?

2017-08-25 Thread Mikko Ohtamaa
>
> It makes also sense to separate them as IDE projects, as most IDEs do not
> understand the concept of a hybrid projects very well. Better to have one
> Pyramid project and one React project.
>
>
> Obviously I’m biased, but…PyCharm Professional (which embeds WebStorm)
> does a really good job on this front. I do hybrid projects frequently.
>

As a non-biased person, I can tell that PyCharm is worth of every Euro cent
when working with codebases that mix HTML, Python, JavaScript, CSS, JSX,
LESS, Stylus and few of more marginal technologies.

Here is an old tutorial for people who are looking to migrate from Sublime
Text to PyCharm:
https://opensourcehacker.com/2015/05/02/pycharm-vs-sublime-text/

Thank you for the good work, Paul and your team!
Mikko

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsk38aYOp9OBys%3DYdjrzJjb%3DCvgcBJhFKUTyDZMyG33Aw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] pyramid and react working together?

2017-08-25 Thread Mikko Ohtamaa
Hi Lukasz,


1. What I need is react bootstrap, to easily build the nice views.
>


> 2. react tables (filter, sort, export to csv)
> 3. Then throw in authentication and registration both on the web and app.
>
> Any suggestions or cookiecutter template that has some samples already
> setup?
>

There is not yet a cookiecutter template, but it is quite trivial to set up.

Some suggestions

* Front end and back end codebases can live in separate repositories, with
some third repository for integration tests if needed

* Use any React front end scaffold to set up your front application, e.g.
https://github.com/cafreeman/generator-mobx-react

* Communicate with the backend using REST, AJAX

* Backend views can be built e.g. in https://github.com/Cornices/cornice
https://github.com/striglia/pyramid_swagger
https://github.com/mikeckennedy/restful-services-in-pyramid

* You can use Colander to validate incoming REST data

* React does its own routing using history JavaScript API. Set URL spoofing
using Nginx.

* For sign up and authentication  - cookie authentication works fine

* For widgets use your favorite React + Bootstrap widget kit

Best regards,
Mikko



>
> or is toscawidgets http://www.toscawidgets.org/ still the recommended way
> to build a front end UI?
>



>
> Thank you
> Lucas
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/4cd429ed-ec75-403b-9f4b-cdb903eb8b91%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/4cd429ed-ec75-403b-9f4b-cdb903eb8b91%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsfrd5jbq05jvubyjds%3DQ0WZ2hE29-7Gkzn6Pa0u7jWtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Re: need guidance for Pyramid, Jinja2, deform combination

2017-06-19 Thread Mikko Ohtamaa
Hi,

This is how I do it:

https://websauna.org/docs/narrative/form/form.html#basic-form-life-cycle

On 19 June 2017 at 14:42,  wrote:

> When you say "it just works", do you mean create a variable containing the
> rendered form and insert it into the jinja template?
>
> On Sunday, November 22, 2015 at 3:34:50 PM UTC-7, Tres Seaver wrote:
>>
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA1
>>
>> On 11/22/2015 03:46 AM, Krishnakant Mane wrote:
>> > Thanks Jeff, Can you give me an example of how you do this?
>>
>> http://stackoverflow.com/questions/3206344/passing-html-to-
>> template-using-flask-jinja2
>>
>>
>> Tres.
>> - --
>> ===
>> Tres Seaver  +1 540-429-0999 <%28540%29%20429-0999>
>> tse...@palladion.com
>> Palladion Software   "Excellence by Design"http://palladion.com
>> -BEGIN PGP SIGNATURE-
>> Version: GnuPG v1
>>
>> iQIcBAEBAgAGBQJWUkLlAAoJEPKpaDSJE9HYBocP/2C+qW2dfnARj1W1ueCqqR16
>> WII0n+KsW2PHgIQ8/lncprz5V/ny7GfcJ4iVRbVVLBNAjlA93SuYIMW0vW6xPPs8
>> uDWtUOkFnzTnwduBNQ+ZV85XZ5IXXnxiQze23BSKKBI6Hc+/EWY4J0ySO+qo3ErP
>> GEe+IpjUArSU1aRGBcvsRuSFpeeIFVL8YzDB1saSFtBvwO8T6OXy5jfseICwmlnU
>> YKmnIP2ZSiPRApVMwegNU88Ij9W60Dt2TC8ktRV4dBHiW0LbMTI0Ks4YDEqWhjsA
>> kYQ8sUg/gU24WgCWPumP/4p0ng/fV6uNNba8P2ToFeZ079sxcl4KNwm49ZgIdj7v
>> EZJAzD5oJgc71nK7vUR341sISCLn3b1CoQQcJOVe0k/AAODRBvqLWY8ojoeZHr69
>> f1hQbOO0hj4ZsdV2Je9Jra6JHcOdbzW347FoE3l9lJ2TTI4MIJd52zbn1glicM3v
>> x/YtjCOOL6zM5qYhsKrm8dckDaiEvB4NDjGYxzZrZp9AUqVYOWle4ebeuZqh6BI0
>> ogNnCB29d1M3zWbxWdIfCnG/1pOCiDWyrk5o0LAr6faxz78s8vqCNt267N9lQHbk
>> LvpLXJLFrpCOMv0KJF1+C7pnkDgw++o17xXGW2PE9IfZs+ZuJIy7yR+JFrsEtMkr
>> xk+zdDt7EABJPG8mVEmP
>> =5/To
>> -END PGP SIGNATURE-
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/17dac5bd-e08c-40cf-bd16-c599377b33ca%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/17dac5bd-e08c-40cf-bd16-c599377b33ca%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtnoC19-QOWuS5X5ZOQ55ufYK%3DRLy7DUqcNYf53xRX7gA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Background process

2017-04-14 Thread Mikko Ohtamaa
Hi Srikanth,

Many people use Celery for background tasks (delayed or scheduled):

Raw barebone Celery integration: https://github.com/sontek/pyramid_celery

More in-depth: https://websauna.org/docs/narrative/misc/task.html

Celery has procedures for launching background worker processes, managing
schedules and interprocess communications.

-Mikko

On 14 April 2017 at 06:32, Srikanth Bemineni 
wrote:

> Hi,
>
> Is there a way I can start a background process in pyramid, where a
> certain non-important work can be pushed to this process. I don't need to
> wait for this to complete to return my request.  This can be implemented in
> a different way, but just checking if there is already a convenient way to
> do this in pyramid.
>
> The background process needs to be started as soon as the first instance
> of the app is started. Other instances of the app just check if the
> background process is already started and does nothing. If the background
> process has crashed or stopped, it will start an instance again.
>
>
>

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvP599ugLL0ngzO9jqUQ_M_9ASLkmCJTSTo5U6dcPF4bQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] On PUT-Request respond with updated resource-data - commit(), transaction manager

2017-04-03 Thread Mikko Ohtamaa
Hi Christian,

I'm working on a project where I use Pyramid together with Cornice to
> provide a REST-API. When I do a PUT-request, I would like to return the
> updated resource in the Response. But as the COMMIT only happens after
> returning the Response and request.dbession.commit() is not allowed in the
> default configuration (SQLAlchemy-scaffold - "Transaction must be committed
> using the transaction manager"), I'm wondering how I could return the
> resource with the latest DB-State after updating it with the PUT-payload.
> Using a GET right after a successful PUT is my current solutions, but that
> feels like an unclean workaround.
>
> Is there a way to do this without replacing the whole
> transaction-mechanism, which seems complex?
>

If I read this correctly this is not complex at all.

Run:

request.dbsession.flush()

And SQLAlchemy will sync all in-memory objects from the database.

http://docs.sqlalchemy.org/en/latest/orm/session_api.html?highlight=flush#sqlalchemy.orm.session.Session.flush


>
> Kind regards,
> Christian
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/bf41d803-9375-445e-a903-a767d507bab9%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/bf41d803-9375-445e-a903-a767d507bab9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuom8vaZOMYq_Kd14y8cMGGt3sxD4RD7i4c0Cu2KJTeFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Iterating through the views of a resource

2017-03-07 Thread Mikko Ohtamaa
Hi Theron,

Can you share your art when you figure out it? E.g. a link to Gist on
Github. I feel this would be beneficial to record it down in cookbook for
everbody.

Best regards,
Mikko

On 7 March 2017 at 09:00, Theron Luhn  wrote:

> Thanks!  That pushed me in the right direction, I think I have it figured
> out now.
>
> — Theron
>
>
>
> On Feb 23, 2017, at 12:13 AM, Mikko Ohtamaa 
> wrote:
>
> Hey Theron,
>
>
>> One thing I can't figure out is how to extract the view callables from
>> Pyramid (since I need them for the docstrings).  Is there someway I can get
>> a list of the view callables and the associated resource?  Or perhaps given
>> a resource, iterate through all associated view callables?
>>
>
> I am not sure if this helps, but I recursively traverse all site resources
> and views for a sitemap:
>
> https://github.com/websauna/websauna/blob/master/websauna/
> system/core/sitemap.py#L316
>
> It's easy to get views for a given resource context object. You can
> probably query all views for any context object directly from the
> underlying Zope component registry.
>
>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to pylons-discuss+unsubscr...@googlegroups.com.
>> To post to this group, send email to pylons-discuss@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/pylons-discuss/916cf024-e60e-4463-9d91-a791701c9c0d%40go
>> oglegroups.com
>> <https://groups.google.com/d/msgid/pylons-discuss/916cf024-e60e-4463-9d91-a791701c9c0d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Mikko Ohtamaa
> http://opensourcehacker.com
> http://twitter.com/moo9000
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "pylons-discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/pylons-discuss/PokpluvF688/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/CAK8RCUtWcORQm2BJoa-bB4ZNXkousezutM4xFLY7Yoq6hZyCd
> w%40mail.gmail.com
> <https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtWcORQm2BJoa-bB4ZNXkousezutM4xFLY7Yoq6hZyCdw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/FEC0E52A-A7AD-4274-8AF5-9D96441D5982%40luhn.com
> <https://groups.google.com/d/msgid/pylons-discuss/FEC0E52A-A7AD-4274-8AF5-9D96441D5982%40luhn.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvk%3DYbgXAb_iyC9YNyRji_s69jwDq2HUxu%2Bc3MPp6nYqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Re: a friendly warning about upcoming changes to pyramid_tm

2017-03-06 Thread Mikko Ohtamaa
> two comments:
>
> 1. have you considered marking `pyramid_tm` as end-of-life, and pushing
> for the new changes as `pyramid_transaction` or some other uniquely
> different name?
>

Whilst this could make your life easier, it would make the life of
maintainers a nightmare.

There are well known Python community best practices regarding version
numbering and how library authors and application authors interact. One of
them is using a pip freeze and requirements.txt to pin down your
application library versions and not to rely on the future unreleased
versions. Changing the library major version number is the socially
accepted signal that *things will break*. Changing the package name would
just clutter PyPi with pyramid_tm, pyramid_transaction, pyramid_yet_another
transaction.

More information about maintaining known good set of libraries for your
application

* https://www.kennethreitz.org/essays/a-better-pip-workflow

* https://ziade.org/2013/04/13/declaring-dependencies-in-python/

* http://nvie.com/posts/pin-your-packages/

> I've been bitten by large API changes like this before.  Not from
Pyramid, but other projects where some 3rd party library updates another
3rd party library to an incompatible version.  It's a giant pain.

Please see above for the best practices to maintain your application
dependencies.

Best regards,
-Mikko


>
> 2. it might make sense to have deployment advice recommend people install
> `pyramid_tm` etc as <2.0 and then <3.0 (or some other number) for future
> compatibility issues.
>
>
>


>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/9d2dba10-f67e-4ca4-a89c-808969fa4202%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/9d2dba10-f67e-4ca4-a89c-808969fa4202%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsoz-K0FO%3DpTEe%2BRyg6%2Bb9D0sOys5cSZpuX3yi0Dn_cEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Iterating through the views of a resource

2017-02-23 Thread Mikko Ohtamaa
Hey Theron,


> One thing I can't figure out is how to extract the view callables from
> Pyramid (since I need them for the docstrings).  Is there someway I can get
> a list of the view callables and the associated resource?  Or perhaps given
> a resource, iterate through all associated view callables?
>

I am not sure if this helps, but I recursively traverse all site resources
and views for a sitemap:

https://github.com/websauna/websauna/blob/master/websauna/system/core/sitemap.py#L316

It's easy to get views for a given resource context object. You can
probably query all views for any context object directly from the
underlying Zope component registry.


> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/916cf024-e60e-4463-9d91-a791701c9c0d%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/916cf024-e60e-4463-9d91-a791701c9c0d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtWcORQm2BJoa-bB4ZNXkousezutM4xFLY7Yoq6hZyCdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Deform 2.0.4 released

2017-02-11 Thread Mikko Ohtamaa
Here are the changes:

2.0.4 (2017-02-11)
--

- Added ability to pass a translator function to
`deform.renderer.configure_zpt_renderer`


Links

- Widget demos http://deformdemo.repoze.org/

- Documentation http://docs.pylonsproject.org/projects/deform/en/master/

- Github https://github.com/pylons/deform

- PyPi https://pypi.python.org/pypi/deform/

Enjoy, and please report any issues you find to the issue tracker at
https://github.com/Pylons/deform/issues

Thanks!

- Deform developers

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsKMGD7G2n1BQ%2BsipEGbf5qFmikDCm6QmXksCw_iGxnCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] does anyone have a server-side session library other than pyramid_redis_sessions ?

2017-02-06 Thread Mikko Ohtamaa
this isn't an issue for normal usage, but i got hit by a spider the other
> day that ignored cookies and created over 30k stale sessions.  this will
> pose a problem for me in the future and i'd like to address it (pagecount
> is growing, session and database-cache are in redis running LRU mode).
>

30k sessions should not be an issue yet. I had 400k sessions and no issues
there. Redis should be very high amount of keys easily.

My suggestion is that

* Have 24 hours or less expiration time for anonymous sessions

* Upgrade the session expiration time when the user logs in, so that logged
in sessions are not forgotten

Also I am pretty sure one can configure pyramid_redis_session not create
session until you save something there. Though not 100% sure here. However
I am saving some stats per user when they come to the site for the first
time (affiliate, etc.)

My 2c (Euro),
Mikko


-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuk%3D1hWXUhdD%2BQfeiD4O47CBjdZAPQ%3Dn3UvUcJ9qSjcjQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] More Deform retail rendering examples

2017-01-30 Thread Mikko Ohtamaa
Hi Pete,

> That's looking great. Did you noticed, that internationalization (also
with
TinyMCE) is broken on the deform2 demo site?

Can you give heads up here? I am not sure what all goes in there since I
started to maintain the project.

-M

On 30 January 2017 at 23:18, Hans-Peter Jansen  wrote:

> On Montag, 30. Januar 2017 19:27:47 Mikko Ohtamaa wrote:
> > Hi all,
> >
> > As per popular request, now Deform comes with retail rendering demo
> > examples.
> >
> > See:
> >
> > http://deformdemo.repoze.org/popup/
>
>
> Cheers,
> Pete
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/3178781.axbuCpvYIC%40xrated.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvqcovzQqKk9FuidVO1mHEnVudOLk-%3D%3DSgHt-GvHNyT-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] More Deform retail rendering examples

2017-01-30 Thread Mikko Ohtamaa
Hi all,

As per popular request, now Deform comes with retail rendering demo
examples.

See:

http://deformdemo.repoze.org/popup/

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtEC45UfbYbSGi6NeUA1_ACZpSMz3CGyJAnG6oDeBS8_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] functional test in pyramid using pytest

2017-01-25 Thread Mikko Ohtamaa
> personnaly I use request.addfinalizer to rollback the transaction :
>
> https://github.com/CroissanceCommune/autonomie/
> blob/master/autonomie/tests/conftest.py#L300
>
>
This does work in full weight functional testing, as you need to run a web
server in a separate thread from unit test main thread. Transactions are
not shared between threads, so you need to commit transactions to the
database in order to Selenium or other test client to see them.

Instead, the cycle is

* Do database set up

* Commit transactions

* Connect to the test web server using a browser

* Manipulate web page

* Read data back from the database

* Check that database matches expected values

* Drop database at the end of the test (or more usual, at the beginning of
the next test)

Cheers,
Mikko



> Hope this help
>
> Regards
>
> --
>
> Gaston Tjebbes
>
> http://majerti.fr
>
>
> Le 24/01/2017 à 20:52, Jaime Sangcap a écrit :
> > Hi everyone! Im trying to learn python and getting my hands dirty with
> > pyramid.
> >
> > I would really appreciate it if there is anyone willing to give me a
> > kickstart on how to do functional test?
> > Lets say I posted a data to a url and I want to test that the data has
> > been saved to the persistent store or fake store.
> > How should I do it?
> >
> > I have this test class:
> >
> > class TestCatalogView:
> > def test_it_loads_catalog_add_page(self, testapp):
> > testapp.get('/catalog/add', status=200)
> >
> > def test_it_adds_the_course_on_the_catalog(self, testapp):
> > response = testapp.post('/catalog/add', status='30*')
> > assert 'Course has been added' in response.body
> > # here I want to assert that the data has been persisted
> >
> > the testapp is a fixture with the following details:
> >
> > @fixture(scope='session')
> > def pyramid_test_setup():
> > yield testing.setUp()
> > testing.tearDown()
> >
> >
> > @fixture(scope='session')
> > def testapp(pyramid_test_setup):
> > from tgpweb import main
> > from pyramid.paster import get_appsettings
> > settings = get_appsettings('testing.ini', 'main')
> > app = main(global_config=None, **settings)
> > return webtest.TestApp(app)
> >
> >
> > What are the things needed to test this? Im thinking of making a
> > Repository Class which uses SqlAlchemy, and another one as Fake
> > repository so that in case I dont want to hit a real database I can
> > swap the implementation
> >
> >
> > If Im doing it wrong please guide me on how to make it right. maybe I
> > have the wrong mindset in testing.
> >
> >
> > Thank you in advance!
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "pylons-discuss" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to pylons-discuss+unsubscr...@googlegroups.com
> > <mailto:pylons-discuss+unsubscr...@googlegroups.com>.
> > To post to this group, send email to pylons-discuss@googlegroups.com
> > <mailto:pylons-discuss@googlegroups.com>.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/pylons-discuss/db009b1b-
> 51c2-493a-809a-2582c6e85d9a%40googlegroups.com
> > <https://groups.google.com/d/msgid/pylons-discuss/db009b1b-
> 51c2-493a-809a-2582c6e85d9a%40googlegroups.com?utm_medium=
> email&utm_source=footer>.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/e43d7678-0e26-082c-ab6f-a9445f223027%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtK1YRfzM5SfKoPwrOXNR%3DgbCaSFMkjH-3O248RsPP03g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] functional test in pyramid using pytest

2017-01-25 Thread Mikko Ohtamaa
For py.test and Splinter (over Selenium) based testing you might look for
the inspiration here:

https://websauna.org/docs/narrative/testing/writing.html#testing-patterns

It also comes with patterns how to ramp up WebTest based web server for
Selenium.

Using py.test and Splinter allows you to write much more cleaner test
scripts that one would do with vanilla unittest2 and raw Selenium.

Thanks,
Mikko

On 25 January 2017 at 10:58, Jaime Sangcap  wrote:

> I guess I missed a lot, I have to do the tutorial again and get back.
> quick tutorial is not that quick at all ;)
>
> Thanks a lot.
>
> On Wednesday, January 25, 2017 at 1:50:55 AM UTC+4, Steve Piercy wrote:
>>
>> Take a look at this step in the SQLAlchemy + URL Dispatch wiki tutorial.
>> http://docs.pylonsproject.org/projects/pyramid/en/latest/tut
>> orials/wiki2/tests.html
>>
>> --steve
>>
>>
>> On 1/24/17 at 11:52 AM, jaime@gmail.com (Jaime Sangcap) pronounced:
>>
>> > Hi everyone! Im trying to learn python and getting my hands dirty with
>> > pyramid.
>> >
>> > I would really appreciate it if there is anyone willing to give me a
>> > kickstart on how to do functional test?
>> > Lets say I posted a data to a url and I want to test that the data has
>> been
>> > saved to the persistent store or fake store.
>> > How should I do it?
>> >
>> > I have this test class:
>> >
>> > class TestCatalogView:
>> > def test_it_loads_catalog_add_page(self, testapp):
>> > testapp.get('/catalog/add', status=200)
>> >
>> > def test_it_adds_the_course_on_the_catalog(self, testapp):
>> > response = testapp.post('/catalog/add', status='30*')
>> > assert 'Course has been added' in response.body
>> >
>> > # here I want to assert that the data has been persisted
>> >
>> >
>> > the testapp is a fixture with the following details:
>> >
>> > @fixture(scope='session')
>> > def pyramid_test_setup():
>> > yield testing.setUp()
>> > testing.tearDown()
>> >
>> >
>> > @fixture(scope='session')
>> > def testapp(pyramid_test_setup):
>> > from tgpweb import main
>> > from pyramid.paster import get_appsettings
>> > settings = get_appsettings('testing.ini', 'main')
>> > app = main(global_config=None, **settings)
>> > return webtest.TestApp(app)
>> >
>> >
>> >
>> > What are the things needed to test this? Im thinking of making a
>> Repository
>> > Class which uses SqlAlchemy, and another one as Fake repository so that
>> in
>> > case I dont want to hit a real database I can swap the implementation
>> >
>> >
>> > If Im doing it wrong please guide me on how to make it right. maybe I
>> have
>> > the wrong mindset in testing.
>> >
>> >
>> > Thank you in advance!
>> >
>>
>> 
>> Steve Piercy, Soquel, CA
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/a6af3a81-0e28-4718-8ac3-1bae60a90cd3%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/a6af3a81-0e28-4718-8ac3-1bae60a90cd3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuVoUn08mdLvKg-kTGjw8dbwPoK5Fo5mQ%2BfLmHO57_4jQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] [ANN] pyramid_notebook 0.2

2016-12-06 Thread Mikko Ohtamaa
*What is it?*

pyramid_notebook embeds IPython Notebook shell on your Pyramid web site.
Start a powerful through-the-browser Python shell with a single click.

IPython Notebook <http://ipython.org/notebook.html> is the de facto tool
for researches, data analysts and software developers to perform visual and
batch oriented tasks. *pyramid_notebook* puts the power of IPython Notebook
inside of a Pyramid website <http://trypyramid.com>.

*Links*

https://github.com/websauna/pyramid_notebook

*Changelog*

- Upgraded to IPython 5.1 / Jupyter

- Better error messages in various situtations

- Add custom shutdown command by customizing IPython toolbar menu



[image: Inline images 2]

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUs70Ye95Dn-Rgeaeqh9c-GNnTiBgJwz%3D3%2B90iRXH8ChAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Pyramid with SQLAlchemy

2016-12-02 Thread Mikko Ohtamaa
Hi Silviu,

The old pattern is not broken if you don't change anything. However it
assumes 1 request = 1 dbsession = 1 thread pattern which is conceptually
not correct. Occurences where this may fail include

* Multiple dbsessions (e.g. one read-only for faster dbsession access)

* Async io web servers

* Celery task queues that run multiple tasks under a same worker thread

* Unit testing: multiple tests under the same thread

Thread locals are not very welcome pattern by many senior developers.
Overusing it results to harder to maintain, harder to test, code. It is
adviced to explicitly pass dbsession around when needed, or encapsulating
your code to classes that take the current dbsession as a constructor
argument.

Cheers,
Mikko

On 2 December 2016 at 02:58, Silviu Dicu  wrote:

> For older versions of pyramid the setup for sqlalchemy session was done
> with scooped_session similar to this
>
> DBSession = scoped_session(
> sessionmaker(
> autoflush=True,
> expire_on_commit=False,
> extension=zope.sqlalchemy.ZopeTransactionExtension()
> )
>
> However I see that newer tutorials as well the pyramid docs
> <http://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/wiki2/basiclayout.html#content-models-with-the-models-package>
>  'promotes'
> sqlalchemy with no threadlocals where the DBSession is attached to the
> request object.
>
> Is the 'old' way broken and what is the advantage of the no threadlocals ?
> thanks!
>
> ps: posted as well http://stackoverflow.com/questions/40922933/pyramid-
> with-sqlalchemy
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/4413dd47-971b-41af-9fda-f82574c2d62f%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/4413dd47-971b-41af-9fda-f82574c2d62f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsrYihM%3Dpcp8jgigO4buigdH3kgN%2BXUdUO21nRVbrGrhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] [off-topic] The Case Against Python 3

2016-11-24 Thread Mikko Ohtamaa
u are subscribed to the Google
>>> Groups "pylons-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to pylons-discuss+unsubscr...@googlegroups.com.
>>> To post to this group, send email to pylons-discuss@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/pylons-discuss/CAPX_VWAnt%3DGuuS2Vnyh_mybhXb-pscyQqXX9mc
>>> J4ANGfzsShdQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/pylons-discuss/CAPX_VWAnt%3DGuuS2Vnyh_mybhXb-pscyQqXX9mcJ4ANGfzsShdQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to pylons-discuss+unsubscr...@googlegroups.com.
>> To post to this group, send email to pylons-discuss@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/pylons-discuss/CAGZ7LV8Cow5%3DFvKU3BR2kgpsKqraxzy_P%2Bga
>> q7W11Zg1QH0s%2BA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/pylons-discuss/CAGZ7LV8Cow5%3DFvKU3BR2kgpsKqraxzy_P%2Bgaq7W11Zg1QH0s%2BA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/CAOdFaDXS193WC8y93G%2BT%3DBLa5ATh-aBgqBsusd9obdF%3D%
> 3D1CgiA%40mail.gmail.com
> <https://groups.google.com/d/msgid/pylons-discuss/CAOdFaDXS193WC8y93G%2BT%3DBLa5ATh-aBgqBsusd9obdF%3D%3D1CgiA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/421E2BF7-4C58-4143-933B-CE4ACA125D06%40pyfidelity.com
> <https://groups.google.com/d/msgid/pylons-discuss/421E2BF7-4C58-4143-933B-CE4ACA125D06%40pyfidelity.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUs4sX27xjAcTDZ2hp0kOcXC2vddzmSYM0s2wzf3wknYGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] [off-topic] The Case Against Python 3

2016-11-24 Thread Mikko Ohtamaa
Bullshit. All new works I have been working are Python 3 based and Python 3
is much better language to work with.

Due to natural change resistance in human beings, a very well studied
psychological effect, you always find people who go to great lengths to
resist a change. There will be always pain in a change. People try to
justify their viewpoint by cherrypicking arguments against the change,
without seeing what good it would bring for them.

However, this being said, Python 3 transition was a mess and in hindsight
everybody can tell it could be handled better. JavaScript community has not
made the same mistake with ES2016 and co. But the change has happened and
if you are still complaining, it's like 10 years too late.

-M



On 24 November 2016 at 13:03, Vinicius Assef  wrote:

> Hey guys.
>
> As Pyramid was the first framework supporting Python 3, what do you
> think about this position?
>
> https://learnpythonthehardway.org/book/nopython3.html
>
> What are your experiences regarding Python 3 as broken?
>
> --
> Vinicius Assef
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/CAFmXjSDn72hbPuF50ppbjL5z8VKm6
> 1o10TiG8khAMrF-40pc%2Bw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvP%2B80aRnKLfnd1JTGZOA7gNwFqTV8bxAWJ0isozweDPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Deform 2.0.3 released

2016-11-19 Thread Mikko Ohtamaa
Deform 2.0.3 has been released.

Maintenance debt (PR, issues) has been reduced. A lot of PRs from various
people got merged.

Here are the changes:

- Added accordions to MappingWidget:
http://deformdemo.repoze.org/mapping_accordion/

- Added CSS class ``deform-form-buttons`` to style form button group:
https://github.com/Pylons/deform/pull/308

- Add more options to ``TextAreaCSVWidget``:
https://github.com/Pylons/deform/pull/309

- Always render an item with a default CSS class:
https://github.com/Pylons/deform/pull/306

- Updated pickdate.js library used for the date picker:
https://github.com/Pylons/deform/pull/248

- Widget Selenium test suite runs both under Python 2 and 3. Lots of
Selenium testing headache fixed with some implicit wait support.

.. note ::

Currently Python 3 file upload widget may have compatibility issues
Please see deformdemo/test.py for details.


Links

- Widget demos http://deformdemo.repoze.org/

- Documentation http://docs.pylonsproject.org/projects/deform/en/master/

- Github https://github.com/pylons/deform

- PyPi https://pypi.python.org/pypi/deform/

Enjoy, and please report any issues you find to the issue tracker at
https://github.com/Pylons/deform/issues

Thanks!

- Deform developers

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUspGvKEQwP35n-TLHWK2NoVn_kdT6FYxXR1MU0cyaBcvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] announce: beta release of pyramid_forksafe, feedback requested

2016-11-15 Thread Mikko Ohtamaa
Hi

> I recently had to update our production deployment to address a forking
issue with mongodb, and realized that our "post fork" cleanup routine was
built directly against the uWSGI API -- creating some technical debt.

The problem I was facing (there might be others) that you cannot fork
process after SQLAlchemy pool is set up.

Instead of relying post fork hooks to deal with this, I made sure that the
pool is created lazily.

- Nothing gets created import time (Websauna boasts zero globals
http://websauna.org/docs/ )

- You access SQLAlchemy through request.dbsession reified method

- When you access request.dbsession for the first time it sets up the pool,
basically a normal reified lazy initialization pattern. This happens always
after post-fork as it happens when HTTP request hits the server process for
the first time.

Cheers,
Mikko



On 15 November 2016 at 21:42, Jonathan Vanasco  wrote:

>
> The solution was a new library that I'd appreciate feedback on:
> `pyramid_forksafe`
>
> The library allows you to write a postfork routine against the generic
> event `pyramid_forksafe.events.ApplicationPostFork` -- which is invoked
> with the application's current `registry`.  Changing between containers can
> then be addressed within the deployment configuration, so you don't need to
> touch the application code.
>
> It appears to work fine with uWSGI and gunicorn so far.  I'm not quite
> sure how to handle the tests or other servers, so PRs/comments are welcome.
>
> https://github.com/jvanasco/pyramid_forksafe
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/ef8d9b12-8ebf-4a42-95a5-7a608a851049%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/ef8d9b12-8ebf-4a42-95a5-7a608a851049%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvLbn9eFt7r%3DDJuT%3DTN4A7rPeBnCFWDsaeEiMxfYvv4GQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Deform 2.0.2 released

2016-11-14 Thread Mikko Ohtamaa
Deform 2.X.X has been released.

Here are the changes:

- Fix regression of  widget default values not honoured

- Updated Select2 widget JavaScript

Links

- Widget demos http://deformdemo.repoze.org/

- Documentation http://docs.pylonsproject.org/projects/deform/en/master/

- Github https://github.com/pylons/deform

- PyPi https://pypi.python.org/pypi/deform/

Enjoy, and please report any issues you find to the issue tracker at
https://github.com/Pylons/deform/issues

Thanks!

- Deform core developers

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuoTLxHPEeTWB3UvVm6kB_DfbvyDgoccRmU4NbmdWJ1qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Checking if a route is allowed

2016-11-12 Thread Mikko Ohtamaa
; all these are separate is to keep some independence between the URL
>>> structure, the view callables, the role concepts, and the permissions:
>>> so you can design each one autonomously to its best structure, and you
>>> can change one (within limits) without affecting the others.
>>>
>>> So the answer to your question is, what determines which menu items
>>> should be displayed? Not the routes, the *roles* (principles). The
>>> roles imply permissions, and r'equest.has_permission'  tells whether
>>> the user has that permission (i.e., can execute the views that require
>>> that permission). However, there's no formal listing of which routes
>>> go with which permissions; that's all tied up in the complex view
>>> confugrations. But you should know which permission each page
>>> requires. So you should do a (in Mako syntax which I'm more familiar
>>> with) '% if request.has_permission("foo_permission"): >> href="${request.route_url('foo_route')}">text % endif'. I have one
>>> application with permissions and I use 'pyramid_layout', so I define
>>> several boolean attributes in the layout object ('can_do_this',
>>> 'can_do_that'), and use those to decide which menu items to display in
>>> the site template. For links in individual pages, the view sets
>>> similar booleans. Actually, I don't always use booleans because I like
>>> to generate the URLs outside the templates, so I use None to indicate
>>> no URL (no link), or I give a list of permitted URLs that doesn't
>>> include the unpermitted ones.
>>>
>>> If you need to do something dynamically (e.g., user-defined URLs and
>>> permissions that the developer doesn't know about), then studying
>>> Kotti might be useful, because it allows site admins to define users
>>> and roles and pages and link them together.
>>>
>>> So I don't think you'll need to ask whether a route is permitted to a
>>> user; that concept belongs in the principles and ACLs. But there may
>>> be something I'm missing. As for 'view_execution_permitted', I've
>>> never used that and I'm not sure it's useful for application
>>> developers, especially in a URL Dispatch application. It may be
>>> something Pyramid uses more internally. The fact that it requires a
>>> view name is a red flag. Routes kind of replace view names in URL
>>> Dispatch. Traversal uses view names extensively to choose between
>>> multiple views for a resource. URL Dispatch uses mostly the route name
>>> to choose a view, and specifying a view name could accidentally make
>>> the view configuration not match the request.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/648eb04e-4036-4161-985a-c7317e8cd653%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/648eb04e-4036-4161-985a-c7317e8cd653%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtXpLfn7ejR1yWuEubK9P5yQai8esGchXLK7RfMpBnT1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Checking if a route is allowed

2016-11-10 Thread Mikko Ohtamaa
On 11 November 2016 at 00:53, Zsolt Ero  wrote:

> Thanks a lot! I'm thinking about it, since I'm quite close (in Budapest).


See you with the dragons, then! :)

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuTVrRBv5ihTnwwxObDhuYon0aChKD%2B92cRHeU4wPKTAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Checking if a route is allowed

2016-11-10 Thread Mikko Ohtamaa
> This might or might not work, but looks complicated enough for me not to
> know if there is a possible bug in it, that I'll just stick with
> has_permission and duplicated values in templates.
>
>
Fair. There is a Pyramid sprint coming in December:
https://dragonsprint.com/  If you want to get this resolved and participate
locally/remotely we might find tutors help to build
route_execution_permitted(request,
route_name)

Thanks!
Mikko

>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUuq%2BQXczJWm4eBjEDphym5x6g%2BR7s3v3A-Uc-uPjyA44A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Checking if a route is allowed

2016-11-10 Thread Mikko Ohtamaa
> And my views are defined like this:
> @view_config(route_name='admin_db_list', renderer='admin/db_list.jinja2',
> permission='superadmin')
> def db_list(request): ...
>
>
> So in this situation, my context is request.root (or request.context), is
> this right?
>
> If I try view_execution_permitted(request.root, request, name='
> admin_db_list'), I get an "TypeError: No registered view satisfies the
> constraints."
>

In @view_config() you don't specify name. This is interesting. I'd guess it
is function name "db_list" in this case. Can you try this?


>
> Do I understand correctly that the name should be a @view_config name
> _and_ this means using traversal, so I should just forget about using it?
>

In traversal:

route_name defines the traversal route name (e.g. "admin" for admin
interface traversal, "blog" for blog posts")
name defines view name as part of the path. E.g. "edit" for
/blog/my-fancy-kittens/edit

I just checked view_execution_permitted() and name argument is indeed view
name (traversal like)

I am not sure, so I let the other comments, whether
view_execution_permitted() can be used for non-traversal like views.


>
> => So in conclusion, I can only use request.has_permission and duplicate
> the permission values in template as well?
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Thursday, 10 November 2016 22:50:37 UTC+1, Mikko Ohtamaa wrote:
>>
>> And to elaborate the following:
>>
>> I simply check for the permission I know the target has using
>> request.has_permission():
>>
>> https://websauna.org/docs/narrative/user/permissions.html?
>> highlight=permissions#checking-permissions-in-templates
>>
>> - Define a Root object
>>
>> - In this root you have a dynamic __acl__() property that gives logged in
>> users permissions based on their user id or group id
>>
>> - In your view you have @view_config(permission="my_permission")
>>
>> Example of setting a custom root:
>>
>> https://websauna.org/docs/_modules/websauna/system.html#Init
>> ializer.configure_root
>>
>> Some examples of dynamic __acl__
>>
>> https://github.com/websauna/websauna.blog/blob/master/websau
>> na/blog/views.py#L45
>>
>> https://websauna.org/docs/narrative/crud/standalone.html?
>> highlight=contract#creating-crud-resources
>>
>> -M
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/b5dd965d-4d4b-48a1-b6c5-fe60eae13c57%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/b5dd965d-4d4b-48a1-b6c5-fe60eae13c57%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtu-gQbyVKQk9psg5atiX-f%2BTnA0-9R-9N46QDAPZ83oA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Checking if a route is allowed

2016-11-10 Thread Mikko Ohtamaa
And to elaborate the following:

I simply check for the permission I know the target has using
request.has_permission():

https://websauna.org/docs/narrative/user/permissions.
html?highlight=permissions#checking-permissions-in-templates

- Define a Root object

- In this root you have a dynamic __acl__() property that gives logged in
users permissions based on their user id or group id

- In your view you have @view_config(permission="my_permission")

Example of setting a custom root:

https://websauna.org/docs/_modules/websauna/system.html#Initializer.configure_root

Some examples of dynamic __acl__

https://github.com/websauna/websauna.blog/blob/master/websauna/blog/views.py#L45

https://websauna.org/docs/narrative/crud/standalone.html?highlight=contract#creating-crud-resources

-M

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsMHGskumUAWdVqmxAqvPHfBc%3DutmqVe4AoiB8vTdtr1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Checking if a route is allowed

2016-11-10 Thread Mikko Ohtamaa
>
> I'm looking for a function to fit in this usage:
>
> {% macro nav_item(request, route_name, text) -%}
>   {% if request.view_execution_permitted(route_name) %}
> 
>   {{ text }}
> 
>   {% endif %}
> {%- endmacro %}
>
>
> My problems are the following:
>
> 1. view_execution_permitted doesn't work like this, unlike other security
> functions, for example request.has_permission(). Why?
>

For this I don't have enough insight to answer.


>
> 2. Going the hard way and making a custom wrapper around 
> view_execution_permitted,
> and adding it to request via add_request_method, I'm still stuck in how
> to use view_execution_permitted, for the following reason:
>



>
> 2.1. It needs a context. What is a context? I never had to use any
> context in URL Dispatch with SessionAuthenticationPolicy, and it really
> isn't explained on the website. I tried Googling view_execution_permitted
> and grepping for code in Github, but I couldn't find anything, except a
> Github issue ticket saying: "view_execution_permitted does not work with
> URL dispatch", which didn't help me.
> https://github.com/Pylons/pyramid/issues/673
>

If you are using only URL dispatching the context is always Root object.
Root object defines site wide root __acl__. You can get this as
request.root
http://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html


>
> 2.2. It needs a name. Is this route_name? I hope so?
>

One route can point to multiple views due to predicates (method=POST, etc).
Thus, this is most likely the same name you give for add_view() and
view_config()


>
> Maybe I don't even need view_execution_permitted. I just want a simple
> request.is_allowed_route(route_name). How can I do it?
>

I simply check for the permission I know the target has using
request.has_permission():

https://websauna.org/docs/narrative/user/permissions.html?highlight=permissions#checking-permissions-in-templates


>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/a5285237-b1a5-44e5-bd5e-3fd0e4b11c44%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/a5285237-b1a5-44e5-bd5e-3fd0e4b11c44%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUt7de%3DGuJA-O7viusQ_c3ox-nsuHrPGh-L-433pnnf71A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Automatic sitemap generator

2016-10-30 Thread Mikko Ohtamaa
Hi,

I have implemented automatic sitemap generator for Pyramid:

https://websauna.org/docs/narrative/misc/sitemap.html#automatic-sitemap-generation

It uses Pyramid introspection API to automatically build Google sitemap.xml
for all your routes and traversable endpoints. Traversable endpoints are
recursed using Python dict.items() like protocol.

It handles permissions.

This code can be used standalone with Pyramid, but due to maintenance
overhead is not provided as a separate package at the moment.

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsLazOHZBDnU0NujoqpUpOO7r_YziToFuHafGpiG6Di3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Re: Announcing Deform 2.0 beta

2016-10-25 Thread Mikko Ohtamaa
Deform 2.0 has been released.

Discussion on Reddit
https://www.reddit.com/r/Python/comments/59dv5b/deform_20/ - upvotes
welcome.

https://pypi.python.org/pypi/deform/

-M

On 22 October 2016 at 17:07, Mikko Ohtamaa  wrote:

> Dear ladies and gentlemen,
>
> Plone Conference 2016 Pyramid sprint team is proud to announce Deform 2
> beta.
>
> Deform is a Python HTML form library independent of underlying web
> framework. Deform is ideal for complex server-side generated forms with
> JavaScript integration. More complex examples include nested forms where
> one can dynamically add and remove subform items. Date and time picking
> widgets and other rich widgets are supported out of the box.
>
> Deform comes with Chameleon templates
> <https://chameleon.readthedocs.io/en/latest/> for Bootstrap
> <http://getbootstrap.com> based widgets. It uses Colander
> <https://github.com/Pylons/colander> as for form schema and validation
> definitions. Deform integrates well with Pyramid web framework
> <https://trypyramid.com/> and several other web frameworks. Peppercorn
> library is used to convert flat HTML name value mapping form submissions to
> stream of name value mappings submissions, allowing building complex and
> nested form structure.
>
> Even if Deform uses Chameleon templates internally, you can embed rendered
> Deform forms into any template language.
> README: https://github.com/pylons/deform
>
> Widget demo is available at: http://54.162.46.236/
>
> I kindly ask the community to take a look around. Currently I and Martin
> Peeters are cleaning up Deform issue tracker and unfinished pull requests.
> These will be merged to 2.0 and upcoming 2.0.x releases. Then we start
> planning to Deform 3 that will contain little bit modernized JavaScript
> interaction what we have at the moment.
>
> --
> Mikko Ohtamaa
> http://opensourcehacker.com
> http://twitter.com/moo9000
>
>


-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtp4deSpOXZ%3Dh5da6ZgYvVDZVBwVzfcWYWGxczOUqMw%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Announcing Websauna

2016-10-23 Thread Mikko Ohtamaa
I'd like to especially spin off SQLAlchemy + deform integration to a
separate package.

On 23 October 2016 at 13:23, Mikko Ohtamaa  wrote:

>
>
>
>> +1 for offering a no-hassle offline documentation bundle. I wish some
>> other projects did that so you don't have to print a page at a time. I
>> just finished porting a a login-based application from Pylons to
>> Pyramid; if Sauna had existed earlier I might have used it. But it
>> looks easy enough to borrow ideas from its structure without drinking
>> the kool-aid.
>>
>
> Currently the package is monolithic. This is not by design, but for having
> less maintenance work for a single person. If you are borrowing or buying
> in, it makes sense to spin out some of the stuff to independent packages.
>
> I have already started to move some of this to upstream, namely Deform.
>
> -M
>
>
>>
>> --
>> Mike Orr 
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to pylons-discuss+unsubscr...@googlegroups.com.
>> To post to this group, send email to pylons-discuss@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/pylons-discuss/CAH9f%3DuqzTdtNH7FxwmRtXSv%2Bd7%2BkdbpT7A
>> siThS6Pe0wMvSz1w%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Mikko Ohtamaa
> http://opensourcehacker.com
> http://twitter.com/moo9000
>
>


-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsLgLnh7aeG7L-J1ppNS5JGp1kOvZ3QiBfo%2BsfvV9b6tg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Announcing Websauna

2016-10-23 Thread Mikko Ohtamaa
> +1 for offering a no-hassle offline documentation bundle. I wish some
> other projects did that so you don't have to print a page at a time. I
> just finished porting a a login-based application from Pylons to
> Pyramid; if Sauna had existed earlier I might have used it. But it
> looks easy enough to borrow ideas from its structure without drinking
> the kool-aid.
>

Currently the package is monolithic. This is not by design, but for having
less maintenance work for a single person. If you are borrowing or buying
in, it makes sense to spin out some of the stuff to independent packages.

I have already started to move some of this to upstream, namely Deform.

-M


>
> --
> Mike Orr 
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/CAH9f%3DuqzTdtNH7FxwmRtXSv%2Bd7%
> 2BkdbpT7AsiThS6Pe0wMvSz1w%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtYDHcT5JoGe3zB1x9rVi-3nrqQ%3DN4NBgAWNvTQDnqfsA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Enquiry: public sites using Deform?

2016-10-22 Thread Mikko Ohtamaa
Hi,

I'd like to find out if there are any public websites using Deform with
some Internet facing forms. I'd like to include these as an example in
Deform README.

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUsSZqHF-xbXE2b2wTZ7BmvMA_g9tou1QXv26d0VdAk%3DEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Announcing Deform 2.0 beta

2016-10-22 Thread Mikko Ohtamaa
Dear ladies and gentlemen,

Plone Conference 2016 Pyramid sprint team is proud to announce Deform 2
beta.

Deform is a Python HTML form library independent of underlying web
framework. Deform is ideal for complex server-side generated forms with
JavaScript integration. More complex examples include nested forms where
one can dynamically add and remove subform items. Date and time picking
widgets and other rich widgets are supported out of the box.

Deform comes with Chameleon templates
<https://chameleon.readthedocs.io/en/latest/> for Bootstrap
<http://getbootstrap.com> based widgets. It uses Colander
<https://github.com/Pylons/colander> as for form schema and validation
definitions. Deform integrates well with Pyramid web framework
<https://trypyramid.com/> and several other web frameworks. Peppercorn
library is used to convert flat HTML name value mapping form submissions to
stream of name value mappings submissions, allowing building complex and
nested form structure.

Even if Deform uses Chameleon templates internally, you can embed rendered
Deform forms into any template language.
README: https://github.com/pylons/deform

Widget demo is available at: http://54.162.46.236/

I kindly ask the community to take a look around. Currently I and Martin
Peeters are cleaning up Deform issue tracker and unfinished pull requests.
These will be merged to 2.0 and upcoming 2.0.x releases. Then we start
planning to Deform 3 that will contain little bit modernized JavaScript
interaction what we have at the moment.

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtMwoTg1D67izFSPjAYjVfsYnKvoek5F_aiaNamtvXcrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Announcing Websauna

2016-10-21 Thread Mikko Ohtamaa
Hi all,

Websauna is a new full stack framework built on the top of Pyramid.

Websauna is a Python package and application framework for developing
custom consumer and business web services. It emphasizes meeting business
requirements with reliable delivery times, responsiveness, consistency in
quality, security and high data integrity. A low learning curve, novice
friendliness and polished documentation help less seasoned developers to
get their first release out quickly.

See Websauna introduction presentation from Plone Conference 2016:

http://www.slideshare.net/miohtama/websauna-introduction-to-the-best-python-web-framework

More information:

https://websauna.org

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUv3StHTZ-ef7Xc7w016rbOiDrCXcZytQRqTzmZU%2B5iKYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] How to resolve the add_route URLs conflict

2016-09-21 Thread Mikko Ohtamaa
open http://localhost:6543/photos/all got 404 resource not found error.
>

You can also get 404 in the case you have are rendering a template and the
template cannot be found on file system.
-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUvHZLyp5DN%2B%2B%3D8WOFpYq%3DUoiUc8ZEAeXcnhK4EOFpVQXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Looking for a project based on Pyramid which gives JSON API to Oracle database.

2016-08-24 Thread Mikko Ohtamaa
Hi Piotr,

Usually you speak to any SQL database using SQLAlchemy which also offers
robust reflection capabilities. However there is usually some manual
integration work to map things between JSON and SQL as due do differences
in data formats there is no automatic 1:1 solutions.

For Pyramid + REST services Cornice is one of the more mature solutions out
there https://pypi.python.org/pypi/cornice

Also check out pyramid_swagger https://github.com/striglia/pyramid_swagger
- as a bonus you get the documentation tool and standard.

Another potential (Flask-based) project is Python EVE which offers it own
configuration language to expose MongoDB and SQL databases to web:
http://python-eve.org/

Cheers,
Mikko

On 24 August 2016 at 16:28, Piotr Dobrogost <
p...@2016.groups.google.dobrogost.net> wrote:

> Hi!
>
> I'm looking for a project based on Pyramid which would automatically
> (based on db reflection) give JSON API to Oracle database allowing for
> selecting, adding, updating and removing data.
>
> Thank you in advance.
>
> Regards,
> Piotr
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/dcc6a84d-1363-466b-83fd-3f5dffafb9c0%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/dcc6a84d-1363-466b-83fd-3f5dffafb9c0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUv_aR591ZCChHUpV_CPJ4CrtA9mz_MW6r9Bkx9O5CCN%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] New Pyramid Celery integration implementation

2016-08-21 Thread Mikko Ohtamaa
Hi all,

After struggling with this for few years I think I have finally nailed
Pyramid and Celery integration. The design goals include

* No global variables or import time side effects. Everything is set up
through Pyramid registry using venusian compatible @task decorator.

* Configured through INI settings

* Kick off delayed task on transaction commit

* Transaction retries in the case the task runs into database conflict
resolution

* Support for eager execution

* Support for scheduled (beat) tasks

* Celery 4.0+ compatible

Here: http://websauna.org/docs/narrative/misc/task.html

If there is market demand I might factor this out to a separate package

-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtapndGcdTpoH%3DmZORMVaPEBKZ-kiF187FAbOqAG9585Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] strategies for conversion from json to SQLalchemy model layer?

2016-06-07 Thread Mikko Ohtamaa
Hi,

What I have seen happening that many people use __json__(self, request)
method on SQLAlchemy models. I find this dirty, as web subsystem should not
relevant to data persistency subsystem and there is a bleeding of
separation of concerns.

I'd rather have one adapter per model which gives serialize/deserialize
process which permission support so that the same serializer could support
e.g. anonymous and authenticated use cases.

In my ideal world

- All data would be described as Colander

- (semi-automatic) adapters would provide serializing between SQLAlchemy
model instances and Colander JSON schema

- Python docstrings could be used do describe objects in Colander schema

- Open API (swagger) schema could be generated from Colander schemas, thus
providing support for automatic Swagger client generation, API discovery
and such

Some more related work

https://github.com/stefanofontanelli/ColanderAlchemy

http://websauna.org/docs/narrative/form/autoform.html (wrapper of above)

https://pythonhosted.org/dictalchemy/

https://github.com/striglia/pyramid_swagger




On 7 June 2016 at 10:08, Iain Duncan  wrote:

> Hi folks, I'm working on an internal framework using Pyramid, Colander,
> and SQLAlchemy, and it's for much more enterprisey apps than I have
> previously done. We're looking at having a full fledged service layer, and
> using the ZCA as a DI framework a fair bit. I'm hoping folks can share
> their opinions on what they've found the best place and way to convert from
> validated dicts (originating from JSON from angular.js) to SA mapped
> objects is. I'm using Colander to validate the incoming json, which might
> be nested two or three levels deep, so after Colander conversion I know the
> fields in the dicts are ok, but they are still just python dicts.
>
> In the past, I used formencode to do both validation and conversion, but
> in this case I'm hoping to keep SQLA logic and coupling to a business/model
> layer that is more insulated from the web request layer so it can be used
> without issue from non-web-request contexts (rabbitqm jobs, scripts, etc).
> So I'm imagining right now that outside this business/model layer the web
> controllers are dealing with json and validating with colander, inside the
> business/model we are dealing with either proxy objects to the model
> objects or direct model objects, and somewhere (?) we convert.
>
> Any suggestions on what people have found to be good strategies or tools
> (or reading!) for localizing and controlling the conversion from dicts to
> mapped objects with relationships would be much appreciated. Or suggestions
> that I'm just wrong and why.
>
> thanks.
> (apologies for cross post if you already read this on the SQLAlchemy list!)
> Iain
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/CAN9NcLzWeQRVEAZhU1OZMwrc0fDiahMxQw1W1f6QtjfJe4__LQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/pylons-discuss/CAN9NcLzWeQRVEAZhU1OZMwrc0fDiahMxQw1W1f6QtjfJe4__LQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUv-p9jJhS%2BABxauZw3dc5QoY-voLfNVF7DYN6U1_BFodA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] testing advice sought - external callback/hook

2016-06-06 Thread Mikko Ohtamaa
>
> On one specific test, after stepping through a form, I need to receive a
> web request from the LetsEncrypt test server.
>
> Does anyone know if it is possible to somehow bind an existing TestApp()
> instance to a port, or if there is a way to leverage webtest.http with an
> existing TestApp instance?
>


Here is an example how to create a test web server for WSGI app (Pyramid):

https://github.com/websauna/websauna/blob/master/websauna/tests/webserver.py#L14

Note that it works with Pyramid WSGI app, not TestApp. TestApp itself wraps
the underlying WSGI app.

-Mikko


> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/1d24d89a-ca55-4353-a0e1-1f9842e24016%40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/1d24d89a-ca55-4353-a0e1-1f9842e24016%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Mikko Ohtamaa
http://opensourcehacker.com
http://twitter.com/moo9000

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAK8RCUtZmO16Hs1Zq1OBKU1swY8ejb5LETxipT5Ctp%3DrdF7_5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.