Re: SQLAHelper 1.0 released, and a proposal

2011-12-30 Thread Laurent DAVERIO

Hi Mike,


I like 'SQLAHub'. There's a precent in Python web frameworks for 'hub'
as a database rendevous point, though it's been so many years I don't
remember where I saw it.


I think you're referring to SQLObject, which is/was used in TurboGears. 
I used it for a couple of years before switching to SQLAlchemy.


Laurent.

--
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.



Re: Serving Buildbot webpages via Pyramid ?

2012-07-19 Thread Laurent DAVERIO
Le 19/07/12 23:10, Jonathan Vanasco a écrit :
 4/ set up a solr-lucene instance , have a cronjob ( or a triggered
 task ) pull all the information from the various components and
 standardize into a common document.  use pyramid to front requests via
 pysolr , and then display.

He he, I hadn't thought of that one! But I'm afraid I'm not great friends
with Solr :-( Last time I tried to replace Xapian with Solr (because I
needed to avoid indexing conflicts), I ended up keeping Xapian and
implementing a Celery-based indexing tasklist...

Laurent.

-- 
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.



Re: recommend a wysiwyg editor for a pyramid project?

2012-11-09 Thread Laurent DAVERIO
 - As much as you can , don't allow consumer HTML
 - I really suggest forcing everything into Markdown or similar in the
 backend, then generating into HTML as needed.  

I humbly disagree. In many companies, you'll see people elaborate
rich-text content in MS Word, and then copy and paste it into a content
management system (I develop and maintain a couple of Zope/CMF/Plone
corporate intranet websites, and I see this happening all the time).

If you don't allow HTML and impose wiki-style formatting instead, many
non-technical people will complain about the change, and rightly so...

My 2 cents...

Laurent.

-- 
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.



Supervisord and Ascii encoding problem ?

2013-02-08 Thread Laurent DAVERIO
Hello list,

I have a very vague question about Supervisord.

Today, I managed to solve (or work around) an annoying Ascii encoding
problem that kept coming up several times in a Pylons app of mine.

The problem was occurring in a method trying to open files with
special characters in their filenames, the said filenames also being
stored in PostgreSQL. Although I thought I had handled everything
properly (UTF-8 strings cast to Unicode, etc.), the problem was still there.

Turns out it only occurs when Pylons is launched via Supervisord. If I
use Daemontools instead, or just run paster serve from the command
line, the problem goes away.

Now, I vaguely remember that my Zope websites wouldn't run properly when
I tried to switch from Daemontools to Supervisord, that's why I had
stayed with the former. It was years ago, and I never investigated the
problem.

So, maybe, I should ask the question in a Supervisord-related mailing
list instead of here. But as it may be of interest to fellow Pyloners
(and Pyloneresses, as well as Pyramiders, Pyramideresses, etc.) and I
haven't found anything via Google, here it is :

Has anyone noticed similar encoding problems with Supervisord? I suspect
it has something to do with the way it handles the (encoding of the)
stdin/stdout/stderr of its child processes.

And it seems to have a definite incidence on all Python apps when run by
supervisord.

Thanks in advance,


Laurent DAVERIO.


-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Supervisord and Ascii encoding problem ?

2013-02-08 Thread Laurent DAVERIO
Thank you very much Jesaja,

I'll keep that in mind :-)

Laurent.


Le 08/02/13 17:15, Jesaja Everling a écrit :
 Hi Laurent,
 
 I definitely remember having the same problem with Supervisor. I can't
 remember exactly what I changed at the moment, but It might have been
 this:
 
 [supervisord]
 environment=LC_ALL='en_US.UTF-8',LANG='en_US.UTF-8'
 
 This is in my /etc/supervisor/supervisord.conf. If this is in there by
 default, I changed something else... ;)
 
 Best Regards,
 
 Jesaja Everling
 
 
 On Fri, Feb 8, 2013 at 5:09 PM, Laurent DAVERIO ldave...@gmail.com wrote:
 Hello list,

 I have a very vague question about Supervisord.

 Today, I managed to solve (or work around) an annoying Ascii encoding
 problem that kept coming up several times in a Pylons app of mine.

 The problem was occurring in a method trying to open files with
 special characters in their filenames, the said filenames also being
 stored in PostgreSQL. Although I thought I had handled everything
 properly (UTF-8 strings cast to Unicode, etc.), the problem was still there.

 Turns out it only occurs when Pylons is launched via Supervisord. If I
 use Daemontools instead, or just run paster serve from the command
 line, the problem goes away.

 Now, I vaguely remember that my Zope websites wouldn't run properly when
 I tried to switch from Daemontools to Supervisord, that's why I had
 stayed with the former. It was years ago, and I never investigated the
 problem.

 So, maybe, I should ask the question in a Supervisord-related mailing
 list instead of here. But as it may be of interest to fellow Pyloners
 (and Pyloneresses, as well as Pyramiders, Pyramideresses, etc.) and I
 haven't found anything via Google, here it is :

 Has anyone noticed similar encoding problems with Supervisord? I suspect
 it has something to do with the way it handles the (encoding of the)
 stdin/stdout/stderr of its child processes.

 And it seems to have a definite incidence on all Python apps when run by
 supervisord.

 Thanks in advance,


 Laurent DAVERIO.


 --
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.


 


-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: WebHelpers developments (paginate 0.4.0 released)

2013-02-12 Thread Laurent DAVERIO
Hello Christoph, hello list,

keeping in mind the warnings about the beta quality of the software, I
have tried integrating it in an existing Pyramid project.

Long story: I wanted to replace the Xapian indexer with Apache-Solr,
using the sunburnt module to interface Python with Solr.

With Xapian, I could retrieve all results of an index query, and feed
them into webhelpers.paginate.Page. Retrieving all the documents would
take 2 seconds on my old machine. Although inefficient, it was
acceptable for the users, and easy to program.

But with Solr, a query retrieving all documents takes much longer
(that's why Solr defaults to partial queries, I guess), so pagination
need to be integrated upstream. It can take place in Solr itself :

 si = SolrInterface( url = 'http://localhost:8080/solr',
 http_connection = httplib2.Http(cache='/tmp/solr_cache')
 )
 query = si.query(**search_args).paginate(start=10, rows=30)
 results = query.execute()

This works fine, but then you need to setup fake results if you want
to use the paginate module, something like :

 page = Page([], item_count=results.result.numFound)

Luckily, the sunbunrt query object provides a __getitem__ method, so I
can write :

 page = Page(query)

This is a very welcome change as compared with webhelpers.paginate,
where only SQLAlchemy query were allowed :-)

==

IMHO, the pager needs some more polish:

1/ I had to handle URL generation myself, here is how I did is (cleaner
solutions welcome :-))

 qsd = urlparse.parse_qs(request.query_string)
 qsd.update(page='$page')
 page_url = request.path_url + '?' + 
 urllib.urlencode(qsd,True).replace('%24page', '$page')

2/ Unicode characters such as « and » (angled double quotes) were
not accepted in symbol_previous and symbol_next, so I kept the defaults
( and ).

3/ The paginate module has lost webhelpers.paginate's ability to handle
partial page loads with AJAX (via the onclick argument).

Hope this helps,

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: WebHelpers developments (paginate 0.4.0 released)

2013-02-13 Thread Laurent DAVERIO
Hello again,

after due consideration, the removal of onclick is not such a problem,
it even allows for cleaner HTML code. I added the following Javascript
and it solved the problem for me:

 $('#${prefix}pager a').click(function () {
 var partial_url = this.href + (this.href.indexOf('?')==-1 ? '?' : 
 '') + 'partial=1';
 $('#results').load(partial_url);
 return false
 }

I think I'll add paginate to my toolbox permanently. Thanks for the
good work :-)

Laurent.





 IMHO, the pager needs some more polish:
 
 1/ I had to handle URL generation myself, here is how I did is (cleaner
 solutions welcome :-))
 
 qsd = urlparse.parse_qs(request.query_string)
 qsd.update(page='$page')
 page_url = request.path_url + '?' + 
 urllib.urlencode(qsd,True).replace('%24page', '$page')
 
 2/ Unicode characters such as « and » (angled double quotes) were
 not accepted in symbol_previous and symbol_next, so I kept the defaults
 ( and ).
 
 3/ The paginate module has lost webhelpers.paginate's ability to handle
 partial page loads with AJAX (via the onclick argument).
 
 Hope this helps,
 
 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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: WebHelpers developments (paginate 0.4.0 released)

2013-02-13 Thread Laurent DAVERIO
 2/ Unicode characters such as « and » (angled double quotes) were
 not accepted in symbol_previous and symbol_next, so I kept the defaults
 ( and ).

This one can be solved easily, too: in file paginate/__init__.py, change
line 541 from :

tag_string += '{0}/{1}'.format(text, tag)
to:
tag_string += u'{0}/{1}'.format(text, tag)

For good measure, you should probably apply the same change to lines 534
and 537.


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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help with SQLAlchemy

2013-04-13 Thread Laurent DAVERIO
Hi,

 I need help with SQLAlchemy. I am not sure if this is the right forum to
 ask the query but since we are using Pylons and SQLAlchemy is part of
 the same, I thought asking here:

No, it's probably not the right forum, as SQLAlchemy is a dependency,
not a part of Pylons (no more than Python, or Linux, are) :-)

 p is returning 1 (number of rows matching the query). There is also no
 exception thrown. But somehow the columns are not getting updated in the
 Database. I am not sure what is going wrong here.

Have you tried adding an explicit DBSession.commit()? Pyramid doesn't
require it - or, rather, doesn't allow for it, since it already uses an
transaction manager - but if I remember correctly, Pylons has no
automatic transaction manager.

 Would really appreciate if you could give me some pointers.

You could also activate SQL query logging (from the development.ini
file), so that you can make sure that  the query is effectively passed
to MySQL.

Best of luck,

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Should ✔ be truthy?

2013-04-18 Thread Laurent DAVERIO
 :) I'd imagine we all do, but that brings up an interesting point. This
 would obviously be most seen in .py files.  One can just imagine
 projects w/ various libraries from different third parties with
 different coding standards with check marks in some modules or even in
 some functions in the same modules and not in others. 

In that case, I expert the right place to define it would be either
Python itself (define 2 new boolean literals), or the ConfigParser
module in the standard library.

Easier said than done in both cases...

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Newbie question: physical file path from asset specification ?

2013-05-01 Thread Laurent DAVERIO
Hello list,

sorry for asking such a newbie question (and making you work on May Day
;-), but I can't seem to find the answer by myself... :-(


I have a Pyramid app defining a few static routes, e.g. :

 for d in ('css', 'img', 'js'):
 config.add_static_view('%s' % d, 'mypkg:static/%s' % d, 
 cache_max_age=3600)

This allows me to use static assets in my templates, e.g.:

 img src=${request.static_url('mypkg:static/img/%s' % img_filename} /


Now, I would like to test in my view if img_filename corresponds to an
existing file.

Is there an easy way to get the physical file path from the asset
specification ? Of course, I don't want to hardcode the image directory
path in my code, and I'd also like to avoid having to add a new setting
(image_dir=...) to my development.ini.

Many 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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Newbie question: physical file path from asset specification ?

2013-05-01 Thread Laurent DAVERIO

Le 01/05/13 19:28, Michael Merickel a écrit :

This is the purpose of the AssetResolver.

resolver = AssetResolver()
asset = resolver.resolve('mypkg:static/img/%s' % img_filename)
asset.abspath() # - /foo/bar/static/img/...

http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/api/path.html#pyramid.path.AssetResolver


Perfect! Thank you very much :-)

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Multiple questions about i18n / pluralization in Pyramid

2013-05-22 Thread Laurent DAVERIO

Hello list,

I'm in the process of internationalizing a Pyramid application, and I'm
currently stumbling on a few problems.

Basic setup as per the tutorial works fine: I can extract message
strings to catalog files using Babel+Lingua, fill-in the PO files,
compile them to MO files and display the result.

1/ After looking at the docs and the source code, I'm more and more
convinced that Babel can't handle pluralization. Do you have any hint on
the issue?

2/ Editing the PO/POT files manually to add pluralization is not
possible, because they are overwritten next time I extract the strings.

3/ Manually adding msgids/msgstrs to a PO file (for additional messages) 
fails for the same reason: if it's not in the source code, it is deleted 
from the PO file :-(


4/ A solution might be to use a separate PO file for additional
translations. This is the way I am exploring now. I've created an 
extra.po file and compiled it to extra.mo, but it's not taken into 
account. Yet.


5/ I've also to find out how to use multiple domains in my app (among 
other problems, how to localize deform widgets - the tutorial didn't 
work for me...)


Well, I think that's all for now ;-) Lot of questions, and I'd be very 
grateful for all answers/pointers/hints/suggestions :-)


Many 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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Namespace packages and scaffolds ?

2013-05-28 Thread Laurent DAVERIO
Hello list,

I'm trying to create a scaffold inside a namespace package. The
namespace package is created correctly, but pcreate -l can't find the
scaffold:

From a clean virtualenv (with only pyramid in it), I create a package foo:

pcreate -t starter foo

Then. I manually create a namespace package as follows:

foo.bar/
  foo/
bar/
  scaffolds/
__init__.py
foobar/
  __init__.py_tmpl
  __init__.py
__init__.py
  foo.bar.egg-info/
  setup.py


In order to make it foo.bar namespace package, foo.bar/foo/__init__.py
contains:

from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)


The scaffold is defined in foo.bar/setup.py :

  [pyramid.scaffold]
  foobar=foo.bar.scaffolds:FooBarTemplate


When I run pcreate -l, I get the following message:

 Warning: could not load entry point foobar (ImportError: No module named 
 bar.scaffolds)
 Available scaffolds:
   alchemy:  Pyramid SQLAlchemy project using url dispatch
   starter:  Pyramid starter project
   zodb: Pyramid ZODB project using traversal


Do you have any idea of what I'm doing wrong?

Many 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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Namespace packages and scaffolds ?

2013-05-28 Thread Laurent DAVERIO
 When I run pcreate -l, I get the following message:
 
 Warning: could not load entry point foobar (ImportError: No module named 
 bar.scaffolds)

To be more precise : pcreate is looking for the scaffold in the main
package (foo), not in the namespace package (foo.bar). It can be
verified if you create the appropriate directories inside package foo:

foo/
  foo/
bar/
  scaffolds/
  __init__.py
static/
templates/
...
  foo.egg-info/
  setup.py
  ...

A quick and dirty way for now could be to create a symlink:

foo/foo/bar - foo.bar/foo/bar

Whether you use a symlink or physically duplicate the bar/ directory,
a pcreate -l now returns:

 Available scaffolds:
   alchemy:  Pyramid SQLAlchemy project using url dispatch
   foobar:   foo.bar template
   starter:  Pyramid starter project
   zodb: Pyramid ZODB project using traversal


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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Multiple questions about i18n / pluralization in Pyramid

2013-05-29 Thread Laurent DAVERIO
Hello again,

this is a follow-up to my own post. I'm slowly working my way towards
the light ;-)


 1/ After looking at the docs and the source code, I'm more and more
 convinced that Babel can't handle pluralization. Do you have any hint on
 the issue?

All my apologies to Babel developers. Babel DOES handle pluralization
perfectly indeed.


The steps of the solution would be:

def aview(request):
_  = request.translate
_p = request.localizer.pluralize
print _(uHello, world)
print _p(uHello, ${n} world, uHello, ${n} worlds, 5,
domain=foo, mapping={'n': 5})


Then, extract messages using:

  python setup.py extract_messages -k _p

The -k _p option instructs Babel to also extract messages from _p()
calls, in addition to _() calls.


Now, what remains to be done is let Babel know how to handle the
parameters of _p(). So, I'm now turning my attention to

  babel/messages/extract.py

and:

  lingua/extractors/python.py



 4/ A solution might be to use a separate PO file for additional
 translations. This is the way I am exploring now. I've created an
 extra.po file and compiled it to extra.mo, but it's not taken into
 account. Yet.

That solution probably wouldn't work, because I understand the po.files
must be named after the translation domain (let's say, foo). So, the
right way would do to create a second locale directory beside the
first one, e.g. locale_extra, initialize it properly, and declare it
in Pyramid'a configurator using:

  config.add_translation_dirs('foo:locale/', 'foo:locale_extra/')



 5/ I've also to find out how to use multiple domains in my app (among
 other problems, how to localize deform widgets - the tutorial didn't
 work for me...)

I must have bee very tired when I wrote this. Two days later, colander
and deform translations suddenly started working :D


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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Multiple questions about i18n / pluralization in Pyramid [SOLVED]

2013-05-29 Thread Laurent DAVERIO
Hello again,

one final word, in case someone is interested (apart from me, I mean ;-))

 Then, extract messages using:
 
   python setup.py extract_messages -k _p

More precisely:

  python setup.py extract_messages -k _p:1,2

The argument _p:1,2 will tell Babel that arguments 1 and 2 of function
_p are translation strings.


 Now, what remains to be done is let Babel know how to handle the
 parameters of _p(). So, I'm now turning my attention to
 
   babel/messages/extract.py
 
 and:
 
   lingua/extractors/python.py

The python extractor in Lingua is hard-coded to consider arg1 as a
translation string, and arg2 as a default value (this is derived from
the signature of the TranslationString constructor).

I was able to work around the problem by subclassing the PythonExtractor
class, so that I'm using arg2 for plurals instead of default:

-

import tokenize
from lingua.extractors.python import PythonExtractor as BasePythonExtractor


class PythonExtractor(BasePythonExtractor):

def stateWaiting(self, ttype, tstring, lineno):
if ttype == tokenize.NAME and tstring in self.keywords:
self.state = self.stateKeywordSeen
self.msg = dict(lineno=lineno, func=tstring)

def addMessage(self, msg):
if not msg.get('label'):
return
default = msg.get('default')
if default:
messages = (u''.join(msg['label']), u''.join(default))
else:
messages = u''.join(msg['label'])
self.messages.append(
(msg['lineno'], msg['func'], messages, []))

extract_python = PythonExtractor()

-


As regards Mako, the default extractor handles pluralization out of the box.


As far as I'm concerned, all my localization problems are solved :-)


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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: pshell+sqlalchemy = ?

2013-05-30 Thread Laurent DAVERIO
Le 30/05/13 18:51, Rachid Belaid a écrit :
 I met the same is issues.
 
 I think that you can simply  do  `Session.commit()` base on my pshell
 history

In my experience, Session.commit() fails with an AssertionError exception:

AssertionError: Transaction must be committed using the transaction
manager

Mariano is right, you must use transaction.commit() instead.

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: pyramid+wtforms+i18n

2013-06-12 Thread Laurent DAVERIO
Hi,

your problem has nothing to do with wtforms (you would have the same
e.g. with Deform. It only has to do with the moment at your code is read
and executed by Python.

I guess your module is executed during Pyramid's startup phase, before
any request is even made. A that time, translating the messages into
the request's locale has no meaning whatsoever. Unless you want to
translate the strings to your site's default locale?

You should probable define your class inside a view, i.e. :

@view_config(...)
def my_View(request):

  _ = request.translate

  class SignupForm(Form):
...


Hope this helps,

Laurent.


Le 10/06/13 17:34, unknown...@gmail.com a écrit :
 Hello!
 
 I'm using i18n exactly as described
 in 
 http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/templates/mako_i18n.html,
 which works fine for views and templates (mako). But I can't get i18n to
 work in my forms (wtforms).
 
 forms.py:
 ---
 from wtforms import Form, ...
 from myproject.subscribers import tsf as _   # ???
 #from pyramid.i18n import TranslationString as _
 
 class SignupForm(Form):
 firstname = TextField(_(u'First name'),
 [validators.Required(message=_(u'This field is required.'))])
 lastname = TextField(_(u'Last name'),
 [validators.Required(message=_(u'This field is required.'))])
 email = EmailField(_(u'Email address'),
 [validators.Required(message=_(u'This field is required.')),
 validators.Email(message=_(u'Invalid email address.'))])
 
 The strings do appear in my locale/.po files, but they are not being
 used when rendering the form.
 I understand it has something to do with 'request', but don't know how
 to set _ = request.translate (as I do it in my views).
 
 
 I've also
 followed 
 http://wtforms.simplecodes.com/docs/1.0.4/i18n.html#translating-built-in-messages
 and made my custom translations object.
 
 forms.py:
 ---
 ...
 from pyramid.threadlocal import get_current_request
 
 class Translator(object):
 def __init__(self, request):
 self.translate = request.translate
 self.localizer = request.localizer
 
 def gettext(self, string):
 return self.translate(string)
 
 def ngettext(self, singular, plural, n):
 return self.localizer.pluralize(singular, plural, n)
 
 class ExtendedForm(Form):
 def _get_translations(self):
 request = get_current_request()
 return Translator(request)
 
 class SignupForm(ExtendedForm):
 firstname = TextField(_(u'First name'), [validators.Required()])
 
 But this only translates build-in strings (This field is required.)
 and not the labels (First name).
 
 
 How/What do I have to import to make i18n work with my forms?
 
 -- 
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  


-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: pyramid+wtforms+i18n

2013-06-12 Thread Laurent DAVERIO
 Right now I'm trying to send request.translate to SignupForm via:
 
 @view_config(...)
 def signup(request):
 customer = Customer()
 form = SignupForm(request.POST, customer, _=request.translate)
 ...

I guess this can't work either, for the same reason. But this gave me an
idea :-)

Basically, the problem is that the form definition is evaluated at
initialization time, but the translation proper must be done only during
each request.

So, I tried this, and it works for me (Deform + Mako): I created a
_lazy class, which is a replacement for _ :


from pyramid.threadlocal import get_current_request

class _lazy(object):

def __init__(self, msg):
self.msg = msg

def __str__(self):
request = get_current_request()
return request.translate(self.msg)


(Yes, I know, using get_current_request should be avoided as much as
possible ;-)
http://docs.pylonsproject.org/projects/pyramid/en/latest/api/threadlocal.html)


So, when my form is defined, each message is instantiated as a _lazy
object:


class SignupForm(Form):
firstname = TextField(_lazy(u'First name'),
[validators.Required(message=_lazy(u'This field is required.'))])
lastname = TextField(_lazy(u'Last name'),
[validators.Required(message=_lazy(u'This field is required.'))])


Then, I'm supposing that when the templating system renders the
TextFields into HTML, it will convert them to strings/unicode/...

That's why I do the actual translation in the __str__ method, using the
get_current_request() request.


Hope this helps,


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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Embedding Jade/Haml inside Mako?

2013-06-23 Thread Laurent DAVERIO
Hello list,

I'm currently trying to embed/include Jade code inside a Mako
template,via the pyjade module. My currently working solution is a bunch
of ugly hacks, so I'm wondering if there would be a cleaner way.

==

As per pyjade's documentation, I could define a .jade renderer inside
Pyramid and never use Mako directly:

  config.add_renrerer('.jade', PyjadeRenderer)

Pyjade define constructs which are translated as Mako tags (e.g.:
extends for %inherit,mixin for %def, etc.) But this solution is
not satisfactory, as all dependent rendering (e.g. the rendering of the
%def blocks defined in other Mako templates) is done
by Jade, and results in a syntax error.

==

A similar problem occurs if I use the render() function inside a view:


from pyramid.renderers import render

@view_config(route_name='...', renderer=page.mako)
def myView(request):

  fragment = render('fragment.jade', {}, request=request)
  return dict(fragment=fragment)


The original request object is modifier by the render() call, and tries
to render page.mako via pyjade's renderer...

==

In understand I could try to pass a clone of the original request, e.g.:

  fragment = render('fragment.jade', {}, request=request.copy())

Unfortunately request.copy() doesn't seem to include the required
information and Jade rendering fails again...

==

So, for the time being, I'm stuck at a lower level, i.e.:


from pyramid.pathimport AssetResolver
from mako.template   import Template
from pyjade.ext.mako import preprocessor as mako_preprocessor

ar = AssetResolver('myPackage')

@view_config( route_name='...', renderer='page.mako' )
def myView(request):

asset =myPackage:templates/fragment.jade
tp = Template( filename=ar.resolve(asset).abspath(),
   input_encoding='utf-8',
   preprocessor=mako_preprocessor
   )
fragment = tp.render(request = request, _ = request.translate)
return dict(fragment=fragment)


As I said, a bunch of ugly hacks... :-(


As usual, any suggestions welcome!

Many thanks,

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.




Accessing the app's settings when no request is available?

2013-06-26 Thread Laurent DAVERIO
Hello everybody,

my last questions to the list have all remained unanswered /
unacknowledged :'-(, but I want to give it another try. This one should
be simpler than the rest.

Basically, I have a data model in which an SQLAlchemy after_update
listener automatically reindexes object attributes in Apache Solr after
every update.

(To make an analogy with Zope CMF, you could see it as implementing
CatalogAware classes).

The URL to Solr is stored in the app's INI file.

This works fine as long as the objects are updated from the Pyramid app
itself. The listener can access the request via
pyramyd.threadlocal.get_current_request(). But when I run an
import/update script from the command line, no request is defined, and I
can't get the URL to Solr.

So, my question would be: what would be the best way to access the app's
settings (or the path to the app's INI file) when not in a request?

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Accessing the app's settings when no request is available?

2013-06-26 Thread Laurent DAVERIO
Thank you Michael,

in fact, my command-line script does use pyramid.paster.get_appsettings,
and I can read the setting just fine. My problem is with the SQLAlchemy
event listener in my model:

- The reindex_after_update function instantiates an IndexEngine object
- The IndexEngine attempts to read the settings using get_current_request

(see snippet below)

If the after_update event is fired from the Pyramid app itself,
get_current_request works. If it's fired from my command line script, it
fails.

I've also considered trying pyramid.testing.DummyRequest, but, if I
remember correctly, it doesn't contain the necessary info.



model.py


from my_indexationimport IndexEngine
from .metaimport Base
from sqlalchemy.event import listen

solr = IndexEngine()


class MyContentClass(Base):
...
...

# after_update Listener
def reindex_after_update(mapper, connection, target):
solr.indexObject(target)

listen(MyContentClass, after_update, reindex_after_update)


myIndexation.py
===

class IndexEngine(object):

def __init__(self, settings=None, request=None):

  if not settings:
  if not request:
  request = get_current_request()
  settings = request.registry.settings

# Read Solr URL
...




Le 26/06/13 09:28, Michael Merickel a écrit :
 You can create a request-like environment by using the bootstrap api
 which will allow you to use get_current_request if you like, among other
 things you would normally do in your app.
 
 Another option is to simply parse the settings from your ini file using
 p.paster.get_appsettings('foo.ini').
 
 http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/narr/commandline.html#writing-a-script
 http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/api/paster.html#pyramid.paster.get_appsettings
 
 
 On Wed, Jun 26, 2013 at 2:22 AM, Laurent DAVERIO ldave...@gmail.com
 mailto:ldave...@gmail.com wrote:
 
 Hello everybody,
 
 my last questions to the list have all remained unanswered /
 unacknowledged :'-(, but I want to give it another try. This one should
 be simpler than the rest.
 
 Basically, I have a data model in which an SQLAlchemy after_update
 listener automatically reindexes object attributes in Apache Solr after
 every update.
 
 (To make an analogy with Zope CMF, you could see it as implementing
 CatalogAware classes).
 
 The URL to Solr is stored in the app's INI file.
 
 This works fine as long as the objects are updated from the Pyramid app
 itself. The listener can access the request via
 pyramyd.threadlocal.get_current_request(). But when I run an
 import/update script from the command line, no request is defined, and I
 can't get the URL to Solr.
 
 So, my question would be: what would be the best way to access the app's
 settings (or the path to the app's INI file) when not in a request?
 
 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
 mailto:pylons-discuss%2bunsubscr...@googlegroups.com.
 To post to this group, send email to pylons-discuss@googlegroups.com
 mailto:pylons-discuss@googlegroups.com.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 -- 
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  


-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Accessing the app's settings when no request is available?

2013-06-28 Thread Laurent DAVERIO
Thank you Jonathan, thank you Andy,

I finally chose the includeme path to solve the problem :-)

As regards elasticsearch and rivers, I haven't had the time to give
them an in-depth look yet, but it is high on my to-do list.

Laurent.


Le 26/06/13 21:55, Jonathan Vanasco a écrit :
 Can you do this without a request?
 
 It sounds like you just need to get to registry.settings ; I'm on mobile
 , but I recall there were some (not recommended, but might still work)
 ways to get at those without being tied to a request.
 
 you could also run some routine to register your app settings on init
 into a package/namespace.  IIRC, the whole request.registry was once
 explained to me to handle situations to ensure the right info where
 there are multiple pyramid apps.
 
 -- 
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.




Re: unable to use deform_bootstrap

2013-07-31 Thread Laurent DAVERIO
Le 31/07/13 08:16, Abdul Wahid a écrit :
 But i am unable to see all static file in my project such .css, .js files.
 And unable to place any bootstrap class on any element.

Hi,

if I remember correctly, you must

1/ manually create a static route pointing to directory
deform_bootstrap:static, and then

2/ manually include the required css and js resources in your templates.

I agree the doc is not very clear about that, but it makes sense,
there's no magic here (deform's magic lies in other areas...)


I'm currently managing my css/js resources with Fanstatic
(http://www.fanstatic.org/en/latest), so I no longer handle manual
inclusions, that's why I'm not sure of the right way to do it...

Good luck,

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.




Re: deform_bootstrap: 404 Not Found glyphicons-halflings-white.png

2013-08-01 Thread Laurent DAVERIO
This file is one of Bootstrap's two icon files. It lives in the img/
subdirectory relative to the path of the bootstrap-*.css files.

But apparently, deform_bootstrap doesn't include the complete bootstrap
package. You must provide the files yourself:

bootstrap-min.css
bootstrap-responsive-min.css (if you use responsive layout)
img/glyphicons-halflings-white.png   (white icons)
img/glyphicons-halflings.png (black icons)

Laurent.



Le 01/08/13 11:35, Abdul Wahid a écrit :
 Inline image 1
 
 Unable to load glyphicons-halflings-white.png. :(
 
 Need Help.
 
 Thanks,
 Regards,
 Abdul Wahid
 
 -- 
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  


-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.




Re: deform_bootstrap: 404 Not Found glyphicons-halflings-white.png

2013-08-01 Thread Laurent DAVERIO
Le 01/08/13 12:08, Abdul Wahid a écrit :
 I did the same but no use, Still gives error. :(

The URL is not right anyway, it should be something like:

http://localhost:6543/static/bootstrap/css/img/glyphicons-halflings-white.png

and not:

http://localhost:6543/img/glyphicons-halflings-white.png

How is it generated in your template?

Laurent.

 
 
 On Thu, Aug 1, 2013 at 3:20 PM, Laurent DAVERIO ldave...@gmail.com
 mailto:ldave...@gmail.com wrote:
 
 This file is one of Bootstrap's two icon files. It lives in the img/
 subdirectory relative to the path of the bootstrap-*.css files.
 
 But apparently, deform_bootstrap doesn't include the complete bootstrap
 package. You must provide the files yourself:
 
 bootstrap-min.css
 bootstrap-responsive-min.css (if you use responsive layout)
 img/glyphicons-halflings-white.png   (white icons)
 img/glyphicons-halflings.png (black icons)
 
 Laurent.
 
 
 
 Le 01/08/13 11:35, Abdul Wahid a écrit :
  Inline image 1
 
  Unable to load glyphicons-halflings-white.png. :(
 
  Need Help.
 
  Thanks,
  Regards,
  Abdul Wahid
 
  --
  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%2bunsubscr...@googlegroups.com.
  To post to this group, send email to pylons-discuss@googlegroups.com
 mailto:pylons-discuss@googlegroups.com.
  Visit this group at http://groups.google.com/group/pylons-discuss.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 
 --
 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%2bunsubscr...@googlegroups.com.
 To post to this group, send email to pylons-discuss@googlegroups.com
 mailto:pylons-discuss@googlegroups.com.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 -- 
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  


-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.




[pylons-discuss] Strange behaviour: transactions not committed automatically

2013-10-05 Thread Laurent DAVERIO
Hello list,

I'm trying to understand what's going on here:

- 2 Pyramid development servers, running almost identical versions of OS
and software (only minor versions may differ, e.g. FreeBSD 9.1 vs 9.2,
PostgreSQL 9.2 vs 9.3, etc.)

- Same Pyramid app deployed on both servers

- On server #1, database COMMITs are emitted automatically inside views,
which is normal, but not on server #2.

- On server #2, if I add a transaction.commit() at the end of a view,
transactions are emitted (I thought it was supposed to raise an exception??)

I'm rather baffled, to say the least. Would you have any hint as to what
may be happening?

Many 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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [pylons-discuss] Strange behaviour: transactions not committed automatically

2013-10-06 Thread Laurent DAVERIO
Thank you for the suggestion, Vincent :-)

But I have exactly the same development.ini file on both sides, and it
includes pyramid_tm...

I have the same versions of the important modules on both sides (Pyramid
1.4.3, pyramid-tm 0.7, transaction 1.4.1, zope.sqlalchemy 0.7.3,
sqlalchemy 0.8.2, psycopg2 2.5.1, etc.)

The mystery remain... (for now)

Laurent.


Le 06/10/13 01:56, Vincent Catalano a écrit :
 In your developement.ini (or whichever .ini file you are using) are you
 making sure to include the pyramid_tm package as part of the
 pyramid.includes directive?
 
 [app:main]
 ...
 pyramid.includes =
 pyramid_tm
 ...
 
 -Vincent
 
 
 On Sat, Oct 5, 2013 at 8:40 AM, Laurent DAVERIO ldave...@gmail.com
 mailto:ldave...@gmail.com wrote:
 
 Hello list,
 
 I'm trying to understand what's going on here:
 
 - 2 Pyramid development servers, running almost identical versions of OS
 and software (only minor versions may differ, e.g. FreeBSD 9.1 vs 9.2,
 PostgreSQL 9.2 vs 9.3, etc.)
 
 - Same Pyramid app deployed on both servers
 
 - On server #1, database COMMITs are emitted automatically inside views,
 which is normal, but not on server #2.
 
 - On server #2, if I add a transaction.commit() at the end of a view,
 transactions are emitted (I thought it was supposed to raise an
 exception??)
 
 I'm rather baffled, to say the least. Would you have any hint as to what
 may be happening?
 
 Many 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
 mailto:pylons-discuss%2bunsubscr...@googlegroups.com.
 To post to this group, send email to pylons-discuss@googlegroups.com
 mailto:pylons-discuss@googlegroups.com.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 
 -- 
 Vincent Catalano
 Software Engineer and Web Ninja,
 (520).603.8944
 
 -- 
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [pylons-discuss] check if mako template exists

2013-10-17 Thread Laurent DAVERIO
Le 17/10/13 09:34, cropr a écrit :
 Does anybody know how one can check in Pyramid  if a mako template
 exists without rendering it, assuming that the mako.directiories is
 correctly set up?

I think you need this:

http://pyramid.readthedocs.org/en/latest/api/path.html?highlight=assetresolver#pyramid.path.AssetResolver

import os
from pyramid.path import AssetResolver

ar = AssetResolver()

path = ar.resolve('mypackage:templates/mytemplate.mako').abspath()

if os.path.exists():
  ...


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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [pylons-discuss] check if mako template exists

2013-10-17 Thread Laurent DAVERIO
 if os.path.exists():

Oops, I meant:

if os.path.exists(path):

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [pylons-discuss] Re: nginx + gunicorn + pyramid -- .sock no such file or directory

2013-11-02 Thread Laurent DAVERIO
Le 02/11/13 17:33, Mazzaroth M. a écrit :
 Which begs the question.. how does one set up multiple virtual hosts on
 a single machine/vm where different domain names forward to different
 pyramid instances?

Each Pyramid instance creates its own app.sock file, so it's just a
matter of pointing each vhost to the right one :-)

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [pylons-discuss] Pyramid theme package

2014-01-22 Thread Laurent DAVERIO
Hi,

I'm afraid you cannot compare Plone with Pyramid:

- Plone is a ready-to-use web content management application with a
themeable interface

- Pyramid is a web development framework with no standard, built-in user
interface.

So, the notion of theme has no meaning in the context Pyramid.

That being said, nothing prevents you (it may even be a good idea!) to
split your Pyramid applicatin into multiple namespace packages.

Hope this helps,

Laurent.



 I come from the Plone world where the theme and app package are usually
 separate packages (mypackage.theme and mypackage.app).
 Is this possible in pyramid? How ?
 
 Thanks.
 
 -- 
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [pylons-discuss] passing an image to a template in pylons dynamically

2014-09-07 Thread Laurent DAVERIO
Le 07/09/2014 17:42, 'gazza' via pylons-discuss a écrit :
 Hello,
  
 I would like to pass an image to a template dynamically to avoid any
 file writes. I convert the image to a StringIO and get the value. I
 wanted to pass that into a context object and simply display it like below:
  
 image src='$c.imageobject'/

Shouldn't the src attribute receive an URL rather than the actual
content? Maybe this is what you need:

http://www.websiteoptimization.com/speed/tweak/inline-images/

more specifically:

data:[mediatype][;base64],data

Not sure if it's a good idea for larger images, though.

Hope this helps,

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] passing a context object to css

2014-10-20 Thread Laurent DAVERIO
Hello,

I would probably prefer to keep all my CSS files as purely static files,
for performance reasons (actually, I would create Sass files, and have
Fanstatic automatically compile and minify them for me, but that's
another story)

Mako can be used for creating CSS templates, but then these CSS files
won't have the same path as the static ones (they will live with your
HTML templates), so you'll need to remember which is which when you
include them in your HTML code. That's probably the way you must go. In
that case, I would keep the dynamic CSS to a minimum, i.e. a single,
short file overloading a static CSS file.

Hope this helps,

Laurent.


Le 21/10/2014 00:31, 'gazza' via pylons-discuss a écrit :
 Hello,
 
 Normally I would pass my context object to a template. However I would
 like to
 pass this to a css class.
 
  i.e c.color=red
 
 Is this possible? or do I have to add a style statement in html on the
 template.
 
 Thanks,
 Gary C
 
 -- 
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Strange overlaps in independent Pyramid projects

2014-10-30 Thread Laurent DAVERIO

Hello list,

I don't know exactly how to report 2 related overlap problems I've 
recently encountered, and maybe it's not even the right list to report 
them. But even then, it's relevant to Pyramid.


These problems started to appear when I created a second Pyramid project 
under an existing virtualenv. The two Pyramid projects are called foo 
and bar. Each or them uses SQLAlchemy table inheritance, on two 
distinct PostgreSQL databases, i.e. :


- A common e-commerce module provides a base class Article, attached 
to a table. This represents a generic article in the catalogue.


- The foo module provides a class FooArticle, which inherits from 
Article. This creates to 2  linked tables, article and 
foo_article, in Pg database foo.


- Similarly, the bar module provides a class BarArticle which also 
inherits from Article. This creates 2 tables, article and 
bar_article, in Pg database bar.


- To make code more legible, the two classes FooArticle and 
BarArticle are always used under the alias Article in their 
respective projects (the parent class Article is never used directly), 
i.e.:


  from foo.models import FooArticle as Article

or:

  from bar.models import BarArticle as Article

=

Overlap #1: SQLAlchemy maps the wrong class to the returned data :

I assume this is because the classes bear the same names (or aliases) in 
the two distinct projects :


$ cd foo
$ pshell development.ini

In [1]: from foo.models import *

In [2]: Article
Out[2]: foo.models.article.FooArticle

In [3]: print Session.query(Article)
SELECT [...]
FROM article JOIN foo_article ON article.id = foo_article.id

In [4]: a = Session.query(Article).first()

In [5]: a
Out[5]: BarArticle id=19844


In that example, Article is an alias of FooArticle, which is 
confirmed by [2]. The generated SQL query interrogates the right tables, 
as shown by [3]. But the object returned by [4] should be an instance of 
FooArticle, not BarArticle [5]!



=

Overlap #2: Supervisord picks the wrong gunicorn_paster script

It happens even when the two projects are moved to separate virtualenvs. 
I've been obliged to replace it with daemontools, temporarily or 
permanently.


For instance, with the line below:

command = /projects/venv2/bin/gunicorn -w 4 --paste 
/projects/venv2/bar/bar/production.ini


supervisord incorrectly launches /projects/venv1/bin/gunicorn...

This is totally illogical... :(


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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Re: Announcement: Ringo a high level application framework

2015-01-03 Thread Laurent DAVERIO
Hi,

I gave it a try, too. MacOS X 10.10, Python 2.7.9 from MacPorts.
Everything worked fine.

  pcreate -t ringo foo

The doc says pcreate -t ringo Foo (Foo with a capital F).

You have to remember that the filesystem on a Mac is case-insensitive
(but case-remembering). So, foo-admin and Foo-admin would be the
same on a Mac, but foo-admin wouldn't exist on e.g. Ubuntu Linux.

I believe the initial instructions were created on a Mac, because I saw
Omnigraffle files (a Mac-specific drawing app) when I did the hg clone
yesterday.

  ImportError:
 /home/xxx/.local/lib/python2.7/site-packages/lxml/etree.so: undefined
 symbol: PyUnicodeUCS4_DecodeLatin1

I believe it depends on whether Python was compiled with UCS2 or UCS4
Unicode strings. In that particular case, I suppose UCS2 was chosen. I
compiled lxml a number of times (on FreeBSD, Linuxes and OS X, and never
came across that error)

Anyway, anything went fine for me, I was able to launch the app, and
from there I didn't know where to go... :D

Laurent.

PS: I have my own development environment too, but I'm afraid it's not
ready for prime time...

-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Routes matching problem

2015-01-14 Thread Laurent DAVERIO
[SOLVED]

Hmm, looks like an incorrectly defined static view was intercepting all
URLs...

Sorry for the trouble, but I had been stumbling on this problem on and
off for quite some time. Maybe just writing the email did the trick?

Laurent.



Le 14/01/2015 19:50, Laurent DAVERIO a écrit :
 Hello list,
 
 I'm stumbling on a routes problem, and I'm not sure how to characterize it.
 
 I have a Pyramid application built as a stack of 3 layers.
 
 - foo : basic application template, defining routes, views, etc.
 - foo.bar : additional configurations, extending foo (config.include, as
 per the doc)
 - myApp   : my application, extending foo.bar
 
 Now, I'm not sure what's happening because 'proutes' sees all the routes
 correctly, but none of them is found when I run the app with 'pserve'.
 All URLs are mapped to a '__/' route, and the browser displays a '404
 Not found error...
 
 2015-01-14 19:46:49,378 DEBUG [ntiq][Dummy-2] route matched for url 
 http://neo:6555/; route_name: '__/', path_info: u'/', pattern: '/*subpath', 
 matchdict: {'subpath': ()}, predicates: ''
 
 I suspect this has to do with my stack of apps, but beyond that, I have
 no idea. Has anyone come across that problem?
 
 Thanks,
 
 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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Routes matching problem

2015-01-14 Thread Laurent DAVERIO
Hello list,

I'm stumbling on a routes problem, and I'm not sure how to characterize it.

I have a Pyramid application built as a stack of 3 layers.

- foo : basic application template, defining routes, views, etc.
- foo.bar : additional configurations, extending foo (config.include, as
per the doc)
- myApp   : my application, extending foo.bar

Now, I'm not sure what's happening because 'proutes' sees all the routes
correctly, but none of them is found when I run the app with 'pserve'.
All URLs are mapped to a '__/' route, and the browser displays a '404
Not found error...

 2015-01-14 19:46:49,378 DEBUG [ntiq][Dummy-2] route matched for url 
 http://neo:6555/; route_name: '__/', path_info: u'/', pattern: '/*subpath', 
 matchdict: {'subpath': ()}, predicates: ''

I suspect this has to do with my stack of apps, but beyond that, I have
no idea. Has anyone come across that problem?

Thanks,

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Re: Announcement: Ringo a high level application framework

2015-01-04 Thread Laurent DAVERIO
  Great! Thanks for your feedback and congratulation, you are the first
 official MacOS user of Ringo :) If there is anyone else who want to be
 the first one on other OS too then go for it. There are plenty options
 left ;)

OK, first on FreeBSD too, then ;)
More precisely, FreeBSD 9.3-RELEASE for amd64, and python 2.7.9.

 I believe the initial instructions were created on a Mac, because I saw
 Omnigraffle files (a Mac-specific drawing app) when I did the hg clone
 yesterday.
  
 No. It was some Linux System. Which files do you mean?

I'm not 100% sure, but I think I noticed one *.graffle file during the
hg clone. But maybe it was in the develop phase, and I saw it in
another module...

 Ah again thanks for helping here out! Unfortunately lxml is a dependency
 of iirc py3o.template which I need for a nice printing feature in ringo.
 A planed to replace it as the xml part does not seems to be that
 difficult. But as always: There is simply to much work for too less
 time. But this dependency is actually somewhat annoying.

Personally I use lxml very often, either directly (especially the xpath
function) or indirectly (e.g. via BeautifulSoup), and I like it :) It's
supposed to rely on the libxml2 C++ libraries, which provide
high-quality, high-performance processing of XML and HTML files :)

 That's fine. Did you follow the instructions on the webpage or the ones
 from Steve?

From the webpage, http://ringo-dev.intevation.de/

 Did the creation of the modul work for you? There is currently a issue
 with that which i noticed in the instructions.) Do you seethe created
 module entry on the header menu of your application after logging.

No particular issue, meaning creation worked, and the app still runs,
but I can't see the bar module. So it seems it didn't work after all...
(just tested on FreeBSD).

 The next step is to add fields to the module to actually save something
 useful and build a nice form for it. This is described in the documentation:
 
  
 http://ringo.readthedocs.org/en/latest/development.html#adding-new-fields-to-the-model

Thanks, I'll have a look at it :)

 PS: I have my own development environment too, but I'm afraid it's not
 ready for prime time...

 :) Release often and release early. That the slogan often related to
 FOSS. But I can understand you :) I was, and I am also afraid to make it
 public.

I tried to integrate different services, as in other dev environments:

- Users, groups and permissions, of course (loosely based on the tutorial)
- Bootstrap CSS/JS,
- Utility languages - Sass stylesheets, Jade templates (thanks to
Fanstatic)
- localisation (via Babel/Lingua), including in Jade templates
- Lots of dogpile caching (python code, rendered HTML, SQLAlchemy
queries, etc.)
- Through-the-web editable content
- Form generation/validation (Colander, Deform)
- Solr indexing (not light, but nothing beats it, I suppose)
- Static resources handled by Fanstatic (providing bundling,
precompilers, minification, etc.)
- An e-commerce module provides the basis for building e-shops

Currently I'm runing into a few issues, among which :

- Some of my localisation modules are not compatible with Pyramid 1.5,
I'm stuck with 1.4 for the moment.
- The platform is dependent on PostgreSQL, because I used some advanced
data types such as Arrays and Hstores (for extended attributes indexed
by Solr). I'd like to have a lite version able to run e.g. on a
Raspberry Pi with SQLite, and without Solr...

Hopefully I'll find time to fix these issues in the coming months...

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] AttributeError: 'module' object has no attribute 'Connection'

2015-05-02 Thread Laurent DAVERIO
Hi Robert,

this is not a Pyramid-related question. I have never user pymongo, but
if I look at the example (https://pypi.python.org/pypi/pymongo/2.8) and
the source code (https://github.com/mongodb/mongo-python-driver), it
appears you should probably be writing something like:

client = pymongo.MongoClient(localhost, 27017)

Hope this helps,

Laurent.


Le 02/05/2015 20:07, robertsolano...@gmail.com a écrit :
 I'm starting a new project with pyramid and mongodb. When I run the
 command: development.ini pserve shows the following error:
 
 File
 /home/robertsolano/workspace/projects/learn/pyramid-learn/my_blog/my_blog/__init__.py,
 line 24, in main
 
 MongoDB = pymongo.Connection
 
 AttributeError: 'module' object has no attribute 'Connection'
 
 Has anyone experienced 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
 mailto:pylons-discuss+unsubscr...@googlegroups.com.
 To post to this group, send email to pylons-discuss@googlegroups.com
 mailto:pylons-discuss@googlegroups.com.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Forms and Validation With Deform ???

2015-05-11 Thread Laurent DAVERIO

I use the exact same combination, and I fully concur :)

The only thing you want to avoid is the `deform_bootstrap` package, 
which was never ported to Bootstrap 3: 
https://pypi.python.org/pypi/deform_bootstrap


Laurent.


Kotti always uses the latest versions of all upstream packages, for that
matter: Bootstrap 3.3.4, deform 2.0a2 and colander 1.0. This combination
performs flawlessly out of the box for all the widgets Kotti uses.


--
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] manage.py equivalent?

2015-06-01 Thread Laurent DAVERIO

Le 01/06/2015 12:08, Chris Withers a écrit :

On 01/06/2015 08:11, Thierry Florac wrote:

Hi,
Do you want to create new management commands or do you just want to
get access to the shell?


Yes, I'm wondering if there's a framework for adding in new commands.


In that case, maybe you just want to look at this:

http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/commandline.html#writing-a-script

especially the lines:


from pyramid.paster import bootstrap
env = bootstrap('/path/to/my/development.ini')


From there you could/should add command-line arguments processing with 
Python's standard module argparse 
(https://docs.python.org/3.4/howto/argparse.html#id1)


And finally, as Veeti said, you should integrate your scripts with 
setuptools, i.e. declare them in your project's setup.py, so that the 
corresponding shellscripts are created.


You just need to do the work once, and reuse it for all subsequent scripts.

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] manage.py equivalent?

2015-06-01 Thread Laurent DAVERIO
PS: in particular, the INI file's path shouldn't be hardcoded, but 
should be read from the command line, as is the case with pserve, 
pshell, etc.



from pyramid.paster import bootstrap
env = bootstrap('/path/to/my/development.ini')


 From there you could/should add command-line arguments processing with
Python's standard module argparse
(https://docs.python.org/3.4/howto/argparse.html#id1)


--
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] manage.py equivalent?

2015-06-01 Thread Laurent DAVERIO
Hi Chris,

the pyramid shell is described here:
http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/commandline.html#the-interactive-shell

Basically, it's an (i)python shell with the application environment
(database connection, etc.) enabled. But I'm not sure it does what you
want, I've no experience of Django.

Hope this helps,

Laurent.


Le 01/06/2015 08:56, Chris Withers a écrit :
 Hi All,
 
 Trying to get back into Pyramid, got a number of projects I want to use
 it for, so expect plenty of silly questions, please feel free to punt me
 at urls...
 
 First up: does Pyramid have a management command framework like
 Django's manage.py?
 
 I couldn't see anything in a quick scan of the PDF docs, but I'm sure I
 remember there being a pyramid shell. Where should I be looking for
 docs on that?
 
 cheers,
 
 Chris
 

-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Re: tweepy streaming api interferes with pserve?

2015-08-01 Thread Laurent DAVERIO
Hello,

have you tried addressing the Insecure Platform Warning problem, as
indicated in the error message?

https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] noob questions

2015-07-15 Thread Laurent DAVERIO
Hi Davide,

 when i try to start my project on 0.0.0.0:6543 doesnt work, but if i
 type localhost:6543 i get into the pyramid start page and i also can
 check the debug. 

0.0.0.0 is not a valid address for a host. It is used in the INI file
to mean listen on any IP address, but you can't use it to connect to
your Pyramid instance. That's normal :)

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] noob questions

2015-07-15 Thread Laurent DAVERIO
OK, I stand corrected, it works :)

But please note that Wikipedia says (https://en.wikipedia.org/wiki/0.0.0.0):


In the Internet Protocol Version 4, the address 0.0.0.0 is a
non-routable meta-address used to designate an invalid, unknown or
non-applicable target. To give a special meaning to an otherwise invalid
piece of data is an application of in-band signaling.

In the context of servers, 0.0.0.0 means all IPv4 addresses on the
local machine. If a host has two ip addresses, 192.168.1.1 and
10.1.2.1, and a server running on the host listens on 0.0.0.0, it will
be reachable at both of those IPs.


i.e. I was not totally wrong when I stated 0.0.0.0 was not a valid
host address.

Laurent.





Le 15/07/2015 22:52, Bert JW Regeer a écrit :
 
 On Jul 15, 2015, at 14:48, Laurent DAVERIO ldave...@gmail.com
 mailto:ldave...@gmail.com wrote:

 That’s not true on OS X/Linux/FreeBSD where it can be used to connect
 to it without issues. This is an issue on Windows only.

 Hmm, I doubt that:

 $uname -a
 Darwin Aki.local 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28
 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
 $ping 0.0.0.0
 PING 0.0.0.0 (0.0.0.0): 56 data bytes
 ping: sendto: No route to host
 ping: sendto: No route to host
 Request timeout for icmp_seq 0
 ^C
 --- 0.0.0.0 ping statistics ---
 2 packets transmitted, 0 packets received, 100.0% packet loss

 
 Pop open Safari or Firefox.
 
 
 
 

 -- 
 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.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 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
 mailto:pylons-discuss+unsubscr...@googlegroups.com.
 To post to this group, send email to pylons-discuss@googlegroups.com
 mailto:pylons-discuss@googlegroups.com.
 Visit this group at http://groups.google.com/group/pylons-discuss.
 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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] noob questions

2015-07-15 Thread Laurent DAVERIO
 That’s not true on OS X/Linux/FreeBSD where it can be used to connect to it 
 without issues. This is an issue on Windows only.

Hmm, I doubt that:

 $uname -a
 Darwin Aki.local 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 
 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
 $ping 0.0.0.0
 PING 0.0.0.0 (0.0.0.0): 56 data bytes
 ping: sendto: No route to host
 ping: sendto: No route to host
 Request timeout for icmp_seq 0
 ^C
 --- 0.0.0.0 ping statistics ---
 2 packets transmitted, 0 packets received, 100.0% packet loss


-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


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

2015-11-22 Thread Laurent DAVERIO
Hi Krishnakant,

as Jeff pointed out, there's nothing special to do, it just works. Just
include the rendered form in your Jinja2 template.

Laurent.


Le 22/11/2015 09:46, Krishnakant Mane a écrit :
> Thanks Jeff,
> Can you give me an example of how you do this?
> Happy hacking.
> Krishnakant.
> 
> On 21/11/2015, Jeff Dairiki  wrote:
>> On Fri, Nov 13, 2015 at 4:40 AM, kk  wrote:
>>
>>> I guess I said all in my subject line.
>>> I would love if I can have templates in jinja2 and use deform library
>>> together with Pyramid.
>>
>>
>> I do this. It "just works."  The stock templates which come with deform are
>> Chameleon, not Jinja2, but it doesn't matter.  Deform, using its chameleon
>> templates, produces HTML markup for the form.  This can be interpolated
>> into a Jinja2 template without issue.
>>
> 

-- 
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.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Finally, Real-Time Django Is Here: Get Started with Django Channels | Heroku

2016-03-24 Thread Laurent DAVERIO
Hello list,

I was just reading this article about Django Channels, and I was
wondering if we had anything similar avaibable for Pyramid?

https://blog.heroku.com/archives/2016/3/17/in_deep_with_django_channels_the_future_of_real_time_apps_in_django

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 post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] config.include issues with a namespace package

2017-01-23 Thread Laurent DAVERIO
Hello list,

after upgrading to Pyramid 1.8 and removing all my __pycache__/
directories (running Python 3.5.2 on macOS), I came across a problem I
had never encountered before, and I don't know how to fix.

NB: this is not a bug of Pyramid 1.8, as downgrading to 1.7 doesn't
eliminate the problem.

I have two packages, called ldc and ldc.shop. Both are Pyramid projects,
the latter being a namespace package which extends the former.


/ldc
  /ldc
__init__.py (1)


/ldc.shop
  /ldc
__ init__.py (2)
/shop
  __init__.py (3)


File (3) contains a "config.include('ldc')" statement, which should
refer to file (1). But instead, it now refers to file (2), which of
course contains no includeme() function.

I've used that layout for several years without any problem (other than
having to symlink directory "shop/" under ldc/ldc), so I have no idea of
what is happening now.

Any help appreciated, 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 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/17192211-04e2-442d-e707-3988a052a986%40cri.ensmp.fr.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] config.include issues with a namespace package

2017-01-25 Thread Laurent DAVERIO
Thank you Michael,

the fact is, I started with Python 2.7 some 4-5 years ago, and migrated
to 3.x around mid-2015. The incriminated __init__.py contains only the
following lines, as per instructions I had found somewhere (can't
remember where):

> # this is a namespace package
> from pkgutil import extend_path
> __path__ = extend_path(__path__, __name__)

I'll try to get rid of it entirely, as I don't wish to maintain Python
2.x compatibility. I like to burn my bridges sometimes ;)

Thanks again,

Laurent.





> If the package has code in its `__init__.py` then it is no longer a real
> namespace package and I think you've been getting "lucky" for this long
> probably due to the order in which the packages were installed. A
> namespace package is a grouping of submodules/subpackages, but the
> top-level module in the package should always be empty and / or
> identical to the module in every separately-distributed copy of that
> file. Normally this means the file would just include a namespace
> declaration required to make setuptools work, although in py3 you can
> apparently get rid of the file entirely (meaning you shouldn't assume
> you can put code in there).

-- 
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/427a7faa-812e-4d54-3e2f-1c1a88e9563a%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] config.include issues with a namespace package

2017-01-25 Thread Laurent DAVERIO
> I'll try to get rid of it entirely, as I don't wish to maintain Python
> 2.x compatibility. I like to burn my bridges sometimes ;)

OK, it works, provided I reinstate the symlink:

ldc/ldc/shop --> ldc.shop/ldc/shop

Python namespace packages are really kludgy, it's a disappointment.
Python is usually smarter...

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 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/8977b21c-83c0-05cb-7a84-0fbb290d2156%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Pyramid 1.8 released

2017-01-22 Thread Laurent DAVERIO
Great work everybody! :)

> Special thanks go to Carlos De La Guardia for all of his work rewriting
> the official Pyramid scaffolds into cookiecutters.

I only have one regret regarding to this: creating projects from
cookiecutter "scaffolds" now requires an Internet connection, and
depends on a commercial service (GitHub). Unless, of course, you
remembered to clone pyramid-cookiecutter-* before hitting the road...

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 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/9564807e-dcaf-cf83-dc18-c04f68e41ff6%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] about pserve --stop-daemon --pid-file

2017-04-24 Thread Laurent DAVERIO
Maybe gunicorn could be used too. It is compatible with Python 3, and it
seems to have a daemon mode.

One trap I recently fell into, is that it's not compatible with:

> [server:main]
> use = egg:waitress#main
> listen = 127.0.0.1:6543 [::1]:6543

you have to use the old syntax, ie:

> [server:main]
> use = egg:waitress#main
> host = 0.0.0.0
> port = 6543

Hope this helps,

Laurent.



Le 24/04/2017 à 07:07, Michael Merickel a écrit :
> I sympathize that no one has given an option that works on windows with
> python 3. I only know of a few solutions:
> 
> 1) Just stop trying to use a process manager inside your process
> manager. Use the windows service as is to start/stop things as it is
> intended to do.
> 
> 2) Use python 2 to run supervisor. It can be used to run a python 3 process.
> 
> 3) Maybe look at using gearbox[1] which is a version of pserve written
> by the turbogears folks. It still has the daemonization options in it
> and it is very likely it can be used to run pyramid apps.
> 
> [1] https://pypi.python.org/pypi/gearbox/
> 
> 
> - Michael
> 
> 
> On Sun, Apr 23, 2017 at 9:53 PM, Guohuang Chen  > wrote:
> 
> $ pip install supervisor
> Collecting supervisor
>   Downloading supervisor-3.3.1.tar.gz (415kB)
> Complete output from command python setup.py egg_info:
> Supervisor requires Python 2.4 or later but does not work on any
> version of Python 3.  You are using version 3.6.0
> (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit
> (AMD64)].  Please install using a supported version.
> 
> 
> supervisor does not support python3 ?
> 
> 在 2017年4月24日星期一 UTC+8上午8:11:33,Guohuang Chen写道:
> 
> i find it. i will do after this to try it ,thank you.
> 
> http://stackoverflow.com/questions/7629813/is-there-windows-analog-to-supervisord
> 
> 
> 
> 在 2017年4月22日星期六 UTC+8上午12:20:05,Bert JW Regeer写道:
> 
> Hello,
> 
> We have removed all daemonization code from pserve. We
> recommend using a process manager like supervisord or
> systemd for managing the lifetime of the process. 
> 
> Bert JW Regeer
> 
>> On Apr 20, 2017, at 19:14, Guohuang Chen
>>  wrote:
>>
>> can pyramid 1.8.3(pyhton36) add the --stop-daemon
>> --pid-file params again?
>> i use winSW wrap pyramid as service, i want to stop the
>> service not by kill the task in the tasklist.
>>
>>
>> -- 
>> 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/c1076828-6035-4164-a762-ff33abf98610%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/c54ad61a-c7da-484f-a88a-d5302c904f75%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
> 

[pylons-discuss] Remove the stargate package from Pyramid's add-on list?

2017-04-30 Thread Laurent DAVERIO
Hello list,

I've been trying to use the stargate module, listed here:

https://trypyramid.com/resources-extending-pyramid.html

"""
Stargate
Stargate is a package for adding WebSockets support to Pyramid
applications using the excellent eventlet library for long running
connections.
Maintainers: boothead
PyPI VCS docs
"""

This was all very promising, but PyPI says the current version, 0.4 was
last updated in 2011, and the provided example
(http://stargate.readthedocs.io/en/latest/index.html) is broken. My
Firefox 52 seems to be sending different header values from what
Stargate expects, and the websocket communication never happens. The
websocket protocol has probably evolved in 6 years...

Incidentally, several months ago, a colleague of mine had been
suggesting Autobahn (http://autobahn.readthedocs.io/en/latest/), but
Stargate looked much simpler to implement, thanks to the Pyramid
integration. Any recommendations welcome :)

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 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/76153082-acea-2445-359f-a725fc3d8906%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Remove the stargate package from Pyramid's add-on list?

2017-05-03 Thread Laurent DAVERIO
Thanks for the reply, Steve! I've noted the info, and I'll still keep an
eye on that project, because it's the kind of function I'd like to add
to some of my sites some day.

Thanks and regards,

Laurent.


Le 30/04/2017 à 20:21, Steve Piercy a écrit :
> I don't know of an alternative, but other folks might.
> 
> Sometimes forks get maintained, but it looks like that has not happened
> in this case.
> https://github.com/boothead/stargate/network/members
> 
> As far as listings of add-on on trypyramid.com, there are three statuses:
> 
> Pylons Project
> Community
> Unsupported
> 
> We move add-ons to "Unsupported" when either the maintainer declares it
> so or after contact has been attempted through its support channels and
> there is no response after a sufficient period of time.
> 
> Whenever an update is needed anywhere on https://trypyramid.com/, submit
> an issue:
> https://github.com/pylons/trypyramid.com
> 
> --steve
> 
> 
> On 4/30/17 at 3:55 PM, ldave...@gmail.com (Laurent DAVERIO) pronounced:
> 
>> Hello list,
>>
>> I've been trying to use the stargate module, listed here:
>>
>> https://trypyramid.com/resources-extending-pyramid.html
>>
>> """
>> Stargate
>> Stargate is a package for adding WebSockets support to Pyramid
>> applications using the excellent eventlet library for long running
>> connections.
>> Maintainers: boothead
>> PyPI VCS docs
>> """
>>
>> This was all very promising, but PyPI says the current version, 0.4 was
>> last updated in 2011, and the provided example
>> (http://stargate.readthedocs.io/en/latest/index.html) is broken. My
>> Firefox 52 seems to be sending different header values from what
>> Stargate expects, and the websocket communication never happens. The
>> websocket protocol has probably evolved in 6 years...
>>
>> Incidentally, several months ago, a colleague of mine had been
>> suggesting Autobahn (http://autobahn.readthedocs.io/en/latest/), but
>> Stargate looked much simpler to implement, thanks to the Pyramid
>> integration. Any recommendations welcome :)
>>
>> Laurent.
>>
> 
> 
> 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/b66c4bf2-fd8a-bf8a-6b86-dce950e5d59c%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


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

2017-08-25 Thread Laurent DAVERIO
> And if you prefer Angular, you have Ionic which does something similar.
Hmm, don't get me starting with Ionic :/ I have been struggling with it
for a few month, it seems to be framework with a very unstable
development path.

AngularJS 2 was in beta for months, it evolved a lot during that time
(in my book, it should be called "alpha", not "beta", then), and the
various tutorials which were written during that time are more or less
irrelevant now. Right after its release, Angular was renumbered from 2.0
so 4.0.

Similarly, Ionic 2 was in beta for months, waiting for Angular 2 to be
released. And similarly, after its release, it was renumbered from 2.0
to 3.0... Since July, It has gone through versions 3.6, 3.7, 3.9.0,
3.9.1, 3.9.2 (was there even a 3.8? The changelog on Github is stuck at
3.6). There were significant changes between them (significant enough to
stump a beginner), and no hints about it in the doc. Not all scaffolds
are up-to-date, for example "ionic generate component" will generate
non-functional code...

You have been warned ;)

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 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/6f16cd80-70d5-f202-a1c8-1a80a9de6cbf%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Cornice: define CORS policy in configuration?

2018-01-08 Thread Laurent DAVERIO
Hi Jens,

if you want to define the value in INI files, it will need to be read in
a function where either "config" or "settings" is available.

One way to do that would be to define CORS_POLICY as a global variable
in your app and initialize it using a config.include() call in your
__init__.py.

Hope this helps,

Laurent.


Le 08/01/2018 à 12:23, Jens W. Klein a écrit :
> I have a small application where I want to configure `cors_origins`
> different dependent on the server its running on (dev/ staging/ live)
> without allowing access cross those domains.
> 
> At the moment I have a policy defined in Python in a base.py, import it
> and use it in my classes with the enpoint like so:
> 
> CORS_POLICY = {
> 'origins': ('*.dev.myserver'.com,),
> #'origins': ('*.stage.customerserver.com',),
> #'origins': ('*.livedomain.com',),
> ...,
> }
> 
> ---
> 
> @resource(path='/api/menu', cors_policy=CORS_POLICY)
> class Menu(object):
> 
> def get(self):
>   ...
>   return menu_def
> ---
> 
> Question: is there a way to define the `cors_origin` in the INI-files?
> 
> TIA 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/b8f0c497-c8b4-5f02-ab9b-a47a1ed56d80%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[pylons-discuss] Reading a Zope ZODB from Pyramid?

2018-07-30 Thread Laurent DAVERIO
Hello list,

this may be a very silly question, and if so I apologize in advance, but
I'm not sure what to google.

Is it reasonable to try and read data from the ZODB of a Zope/CMF
instance directly from Pyramid, or should I write export routines in the
Zope app?

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 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/e29375c6-7f65-4544-dbac-eae666f6517d%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Reading a Zope ZODB from Pyramid?

2018-07-31 Thread Laurent DAVERIO
Thank you very much Gael,

I vaguely remembered about pickles, thanks for pointing that out. Unless
I'm mistaken, Python 2 and 3 use different pickling formats, so my
Pyramid app would also have be downgraded to Python 2...

Maybe I should try something else, after all.
Thanks for your help,

Laurent.


> ZODB use pickle to store your objects' instances. This mean that you'll need
> to make available all the classes (python code) used by Zope/CMF to
> deserialize objects in your pyramid app.
> 
> This maybe painfull but it seems doable since Zope/CMF are now available as
> packages on pypi.
> 
> The easy way to try this is probably to install pyramid in your current
> Zope/CMF venv, write a minimalistic pyramid app to access your ZODB, and
> start it from this venv.
> 
> Hope this help.
> 
>>
>> 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 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/e29375c6-7f65-4544-dbac-eae666f6517d%40gmail.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/78e17265-167e-ef26-209b-743e134e820f%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] Re: Reading a Zope ZODB from Pyramid?

2018-07-31 Thread Laurent DAVERIO
Thank you very much Tres,

I think I'll choose a safer/saner way, even if I would have loved being
able to access the ZODB data directly...

Thanks for your help,

Laurent.


> If you install all the Zope + CMF code such that it is importable from
> within your Pyramid app, then you could just load the objects normally
> (unpickling requires finding the class)
> 
> Reading pickle data (vs unpickling the instances) is a tricky problem, and
> not one I'd be excited to tackle.
> 
> 
> Tres.
> 


-- 
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/7ca9afc5-421a-ea39-3eb6-4f8ab288c3c9%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pylons-discuss] how does pyramid know what "create" , "view", "edit" etc is ?

2021-05-10 Thread Laurent Daverio
Hello,

you could have a look at the "Authorization" page of the SQLAlchemy +
URL dispatch wiki tutorial:

https://pyramid.readthedocs.io/en/latest/tutorials/wiki2/authorization.html

Basically : you define your permission as string via an ACL mechanism.
Your permissions may be global (e.g. all members of the "managers"
group get the "manage" permission), or defined via a route factory.
Route factories allow for policies such as: every authenticated user
can "view" a page, its author can "edit" it. They also allow you to
simplify the code of your views.

Hope this helps,

Laurent.

Le dim. 9 mai 2021 à 20:17, Thierry Florac  a écrit :
>
> Hi,
> Are you asking about the way to protect a view with a permission, or about 
> the way to grant this permission to a request?
> Best regards,
> Thierry
> --
>   https://www.ulthar.net -- http://pyams.readthedocs.io
>
>
> Le dim. 9 mai 2021 à 19:00, pzzcc  a écrit :
>>
>> Hi,
>>
>> I am trying to wrap my head around some pyramid concepts and I am trying to 
>> figure out how does a view config know what a permission like ( view , edit 
>> , create ) is ?
>>
>> does it rely on the pyramid_tm r or the routes or what  ?
>>
>> I know how to use them but I need to wrap my head againts some concepts.
>>
>> thanks.
>>
>> --
>> 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/2b676239-b805-40d6-9ae2-1e4c60a9a7dcn%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/CAPX_VWCYnWP_Rrbgk1ZBP1JBUN8KNztgj5%3DJ_Q_8%2B_uvAXAv_A%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/CAB7cU6xwgFG72ngmk8bw1CMfwjBRQOxZ21WB4BQHZWJjPpT7qA%40mail.gmail.com.


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

2021-05-20 Thread Laurent Daverio
Hello Jonathan,

thank you for your message, and sorry for my late answer, I'm seeing
it only now. I've understood the difference by now, having spent a
number of hours on the problem (I'm not a Python or Pyramid newbie,
but I admit I am (or was?) a CSRF newbie).

> The `session.get_csrf_token` method is really a helper function for Pyramid 
> and add-ons to have a standard interface for stashing a CSRF token in the 
> session.
> it might be worth changing those interface names to have leading underscores, 
> so the public doesn't rely on them.  Or maybe add a warning docstring that
> `pyramid.csrf.get_csrf_token` should be used by developers.

Actually, when I set out upgrading my code to make it compatible with
Pyramid 2.x, I started with one of the official tutorials (SQLAlchemy
+ URL dispatch wiki tutorial), which says
(https://docs.pylonsproject.org/projects/pyramid/en/2.0-branch/tutorials/wiki2/definingviews.html#csrf-protection):

- Use CookieCSRFStoragePolicy
- Add a hidden field with "get_csrf_token()" in your templates

So, I was led to believe it was the right way. Erroneously, apparently...

Thanks for the clarification,

Laurent.

Le jeu. 13 mai 2021 à 00:34, 'Jonathan Vanasco' via pylons-discuss
 a écrit :
>
> They're not the same at all.
>
> The difference is on purpose.
>
> Janzert is correct, though his description may not necessarily be clear.
>
> The following might make more sense:
>
> The two functions do the following:
>
>   pyramid.csrf.get_csrf_token(request)
> discern active ICSRFStoragePolicy
> invoke {ICSRFStoragePolicy.get_csrf_token()}
>
>   request.session.get_csrf_token()
> invoke {self.get_csrf_token()}
>
> Because of that difference, the following happens.
>
>   1. when using `LegacySessionCSRFStoragePolicy`, `SessionCSRFStoragePolicy`, 
> or `None` (which is one of those IIRC):
>   a) pyramid.csrf.get_csrf_token always uses the Session
>   b) request.session.get_csrf_token is just a shortcut to the above
>
>   2. when using `CookieCSRFStoragePolicy`:
>   a) pyramid.csrf.get_csrf_token always uses the dedicated Session 
> cookie, as you instructed it to.
>   b) request.session.get_csrf_token is referencing a csrf_token within 
> the session itself. Pyramid is not configured to ever look in the session for 
> a csrf, because you told it to use a dedicated session cookie.
>
> The `session.get_csrf_token` method is really a helper function for Pyramid 
> and add-ons to have a standard interface for stashing a CSRF token in the 
> session.  it might be worth changing those interface names to have leading 
> underscores, so the public doesn't rely on them.  Or maybe add a warning 
> docstring that `pyramid.csrf.get_csrf_token` should be used by developers.
>
> In any event, you are getting different results because you are telling 
> pyramid to use a cookie for the csrf token, then using one method that 
> queries that cookie (correct value!) and a second method that queries the 
> active session for a token -- which is not tied to the pyramid csrf system in 
> any way.
> On Sunday, May 2, 2021 at 6:14:47 PM UTC-4 Steve Piercy wrote:
>>
>> They are effectively the same.
>>
>> https://docs.pylonsproject.org/projects/pyramid/en/latest/_modules/pyramid/csrf.html#LegacySessionCSRFStoragePolicy.get_csrf_token
>>
>> In your code, you have configured two session factories. I assume you get 
>> the CSRF unique to each factory. ¯\_(ツ)_/¯
>>
>> --steve
>>
>>
>> On 5/2/21 10:25 AM, Laurent Daverio wrote:
>> > So, if I follow this line of reasoning, the way to get the same value
>> > as in the template is to use :
>> >
>> > from pyramid.csrf import get_csrf_token
>> > print get_csrf_token(request)
>> >
>> > and *not* :
>> >
>> > print request.session.get_csrf_token()
>> >
>> > Le dim. 2 mai 2021 à 19:11, Laurent Daverio  a écrit :
>> >>
>> >> OK, I've been able to nail it down on a simple example : depending on
>> >> the CSRF storage policy I use, "request.session.get_csrf_token()"
>> >> (called from python or a template) and "get_csrf_token()" (called from
>> >> a template) return the same value *or not*.
>> >>
>> >> - no storage policy => ok
>> >> - LegacySessionCSRFStoragePolicy => ok
>> >> - CookieCSRFStoragePolicy => ko
>> >>
>> >> I'm attaching my example, I called it "onefile.py", although I needed
>> >> two files actually (one python file + one mako template). Sorry ;)
>> >>
>> >> Le mer. 28 avr. 2021 à 22:32, Laurent 

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

2021-05-02 Thread Laurent Daverio
So, if I follow this line of reasoning, the way to get the same value
as in the template is to use :

from pyramid.csrf import get_csrf_token
print get_csrf_token(request)

and *not* :

print request.session.get_csrf_token()

Le dim. 2 mai 2021 à 19:11, Laurent Daverio  a écrit :
>
> OK, I've been able to nail it down on a simple example : depending on
> the CSRF storage policy I use, "request.session.get_csrf_token()"
> (called from python or a template) and "get_csrf_token()" (called from
> a template) return the same value *or not*.
>
> - no storage policy => ok
> - LegacySessionCSRFStoragePolicy => ok
> - CookieCSRFStoragePolicy => ko
>
> I'm attaching my example, I called it "onefile.py", although I needed
> two files actually (one python file + one mako template). Sorry ;)
>
> Le mer. 28 avr. 2021 à 22:32, Laurent Daverio  a écrit :
> >
> > Thank you Steve. I'll have to think about it, not that the code is
> > secret, just a matter of knowing what to post to be relevant.
> >
> > Le mer. 28 avr. 2021 à 22:10, Steve Piercy
> >  a écrit :
> > >
> > > It's difficult to say without your example.  I've been using CSRF as 
> > > shown in the Deform demo without any issues.
> > >
> > > --steve
> > >
> > >
> > > On 4/28/21 10:32 AM, Laurent Daverio wrote:
> > > > Hello List,
> > > >
> > > > I'd like to report a problem I've just encountered, occurring betwen
> > > > Pyramid's CSRF protection and Deform.
> > > >
> > > > Basically, I have a Pyramid 2.0 web app configured along the lines of
> > > > the "URL dispatch wiki tutorial"
> > > > (https://docs.pylonsproject.org/projects/pyramid/en/2.0-branch/tutorials/wiki2/authentication.html),
> > > > with some Deform forms in it.
> > > >
> > > > 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.
> > > >
> > > > As I don't have the time/energy to fully investigate the problem right
> > > > now, I think I will just use a workaround: as I'm using Diazo as a
> > > > theming engine (awesome tech, btw), I think I will add a rule to
> > > > inject the token into every form. Should work.
> > > >
> > > > Still, I wanted to take the time to report the problem, in case it
> > > > could be useful.
> > > >
> > > > 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/44979a98-12ae-239e-8478-c2323aecfaf1%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/CAB7cU6yg58oXZgQZT_ynrqrMhVzpJ80RSQmeZN9MBFT9HVUGjA%40mail.gmail.com.


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

2021-05-02 Thread Laurent Daverio
OK, I've been able to nail it down on a simple example : depending on
the CSRF storage policy I use, "request.session.get_csrf_token()"
(called from python or a template) and "get_csrf_token()" (called from
a template) return the same value *or not*.

- no storage policy => ok
- LegacySessionCSRFStoragePolicy => ok
- CookieCSRFStoragePolicy => ko

I'm attaching my example, I called it "onefile.py", although I needed
two files actually (one python file + one mako template). Sorry ;)

Le mer. 28 avr. 2021 à 22:32, Laurent Daverio  a écrit :
>
> Thank you Steve. I'll have to think about it, not that the code is
> secret, just a matter of knowing what to post to be relevant.
>
> Le mer. 28 avr. 2021 à 22:10, Steve Piercy
>  a écrit :
> >
> > It's difficult to say without your example.  I've been using CSRF as shown 
> > in the Deform demo without any issues.
> >
> > --steve
> >
> >
> > On 4/28/21 10:32 AM, Laurent Daverio wrote:
> > > Hello List,
> > >
> > > I'd like to report a problem I've just encountered, occurring betwen
> > > Pyramid's CSRF protection and Deform.
> > >
> > > Basically, I have a Pyramid 2.0 web app configured along the lines of
> > > the "URL dispatch wiki tutorial"
> > > (https://docs.pylonsproject.org/projects/pyramid/en/2.0-branch/tutorials/wiki2/authentication.html),
> > > with some Deform forms in it.
> > >
> > > 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.
> > >
> > > As I don't have the time/energy to fully investigate the problem right
> > > now, I think I will just use a workaround: as I'm using Diazo as a
> > > theming engine (awesome tech, btw), I think I will add a rule to
> > > inject the token into every form. Should work.
> > >
> > > Still, I wanted to take the time to report the problem, in case it
> > > could be useful.
> > >
> > > 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/44979a98-12ae-239e-8478-c2323aecfaf1%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/CAB7cU6zNrhyPN%3DdQxkrTp3S%3DvkwYQ8%2BhottYXOSOHRKjz7078A%40mail.gmail.com.
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.csrf import CookieCSRFStoragePolicy, LegacySessionCSRFStoragePolicy
from pyramid.renderers import render_to_response
from pyramid.session import SignedCookieSessionFactory


def hello_world(request):
print(request.session.get_csrf_token())
return render_to_response('onefile.mako', {}, request)

if __name__ == '__main__':

my_session_factory = SignedCookieSessionFactory('itsaseekreet')

with Configurator() as config:
settings = config.get_settings()
config.set_session_factory(my_session_factory)
config.include('pyramid_mako')

# >>> Enable one storage policy below, or none <<<
#config.set_csrf_storage_policy(LegacySessionCSRFStoragePolicy())
config.set_csrf_storage_policy(CookieCSRFStoragePolicy())

config.set_default_csrf_options(require_csrf=True)

config.add_route('hello', '/')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()

server = make_server('0.0.0.0', 6543, app)
server.serve_forever()


onefile.mako
Description: Binary data


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

2021-05-02 Thread Laurent Daverio
No, I haven't configured two session factories, one of them is
commented out, so that I can test either.

If I use LegacySessionCSRFStoragePolicy, get_csrf_token(request) and
request.session.get_csrf_token() do return the same value. A look at
the source code shows they are implemented in the same way.

BUT it I use CookieCSRFStoragePolicy, they no longer return the same
value. That was my point.

As I was using the second policy in my code, as per the Pyramid
tutorial, I was always getting CSRF errors in my Deform forms. I've
solved the problem by using:

@colander.deferred
def deferred_csrf_default(node, kw):
request = kw.get('request')
return get_csrf_token(request)

instead of:

@colander.deferred
def deferred_csrf_default(node, kw):
request = kw.get('request')
return request.session.get_csrf_token()

Laurent.



Le lun. 3 mai 2021 à 00:14, Steve Piercy  a écrit :
>
> They are effectively the same.
>
> https://docs.pylonsproject.org/projects/pyramid/en/latest/_modules/pyramid/csrf.html#LegacySessionCSRFStoragePolicy.get_csrf_token
>
> In your code, you have configured two session factories.  I assume you get 
> the CSRF unique to each factory.  ¯\_(ツ)_/¯
>
> --steve
>
>
> On 5/2/21 10:25 AM, Laurent Daverio wrote:
> > So, if I follow this line of reasoning, the way to get the same value
> > as in the template is to use :
> >
> > from pyramid.csrf import get_csrf_token
> > print get_csrf_token(request)
> >
> > and *not* :
> >
> > print request.session.get_csrf_token()
> >
> > Le dim. 2 mai 2021 à 19:11, Laurent Daverio  a écrit :
> >>
> >> OK, I've been able to nail it down on a simple example : depending on
> >> the CSRF storage policy I use, "request.session.get_csrf_token()"
> >> (called from python or a template) and "get_csrf_token()" (called from
> >> a template) return the same value *or not*.
> >>
> >> - no storage policy => ok
> >> - LegacySessionCSRFStoragePolicy => ok
> >> - CookieCSRFStoragePolicy => ko
> >>
> >> I'm attaching my example, I called it "onefile.py", although I needed
> >> two files actually (one python file + one mako template). Sorry ;)
> >>
> >> Le mer. 28 avr. 2021 à 22:32, Laurent Daverio  a écrit 
> >> :
> >>>
> >>> Thank you Steve. I'll have to think about it, not that the code is
> >>> secret, just a matter of knowing what to post to be relevant.
> >>>
> >>> Le mer. 28 avr. 2021 à 22:10, Steve Piercy
> >>>  a écrit :
> >>>>
> >>>> It's difficult to say without your example.  I've been using CSRF as 
> >>>> shown in the Deform demo without any issues.
> >>>>
> >>>> --steve
> >>>>
> >>>>
> >>>> On 4/28/21 10:32 AM, Laurent Daverio wrote:
> >>>>> Hello List,
> >>>>>
> >>>>> I'd like to report a problem I've just encountered, occurring betwen
> >>>>> Pyramid's CSRF protection and Deform.
> >>>>>
> >>>>> Basically, I have a Pyramid 2.0 web app configured along the lines of
> >>>>> the "URL dispatch wiki tutorial"
> >>>>> (https://docs.pylonsproject.org/projects/pyramid/en/2.0-branch/tutorials/wiki2/authentication.html),
> >>>>> with some Deform forms in it.
> >>>>>
> >>>>> 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.
> >>>>>
> >>>>> As I don't have the time/energy to fully investigate the problem right
> >>>>> now, I think I will just use a workaround: as I'm using Diazo as a
> >>>>> theming engine (awesome tech, btw), I think I will add a rule to
> >>>>> inject the token into every form. Should work.
> >>>>>
> >>>>> Still, I wanted to take the time to report the problem, in case it
> >>>>> could be useful.
> >>>>>
> >>>>> 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/44979a98-12ae-239e-8478-c2323aecfaf1%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/CAB7cU6yTwAppxSD1kZ0ZF-3s6Te7pba0AkmL8tW1AS94QdzBXQ%40mail.gmail.com.


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

2021-04-28 Thread Laurent Daverio
Thank you Steve. I'll have to think about it, not that the code is
secret, just a matter of knowing what to post to be relevant.

Le mer. 28 avr. 2021 à 22:10, Steve Piercy
 a écrit :
>
> It's difficult to say without your example.  I've been using CSRF as shown in 
> the Deform demo without any issues.
>
> --steve
>
>
> On 4/28/21 10:32 AM, Laurent Daverio wrote:
> > Hello List,
> >
> > I'd like to report a problem I've just encountered, occurring betwen
> > Pyramid's CSRF protection and Deform.
> >
> > Basically, I have a Pyramid 2.0 web app configured along the lines of
> > the "URL dispatch wiki tutorial"
> > (https://docs.pylonsproject.org/projects/pyramid/en/2.0-branch/tutorials/wiki2/authentication.html),
> > with some Deform forms in it.
> >
> > 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.
> >
> > As I don't have the time/energy to fully investigate the problem right
> > now, I think I will just use a workaround: as I'm using Diazo as a
> > theming engine (awesome tech, btw), I think I will add a rule to
> > inject the token into every form. Should work.
> >
> > Still, I wanted to take the time to report the problem, in case it
> > could be useful.
> >
> > 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/44979a98-12ae-239e-8478-c2323aecfaf1%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/CAB7cU6zhk4yL9KCQtkKmb18cqsrf5bwiaqYwd%3D62GPDFroFKeg%40mail.gmail.com.


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

2021-04-28 Thread Laurent Daverio
Hi Mikko, thank you for your reply :)

I don't think I'm doing anything weird there. The problem happens in a
class-based view.
I can see the 'csrf_token' cookie qith the right value, I can display
the same value inside a template by calling get_csrf_token(), but the
value generated inside the deferred function is different, although
being passed (I think) the same request object...

Le mer. 28 avr. 2021 à 19:39, Mikko Ohtamaa  a écrit :
>
> 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.

-- 
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/CAB7cU6z%3DfZvYd-r9SV25gMwcaosUimJUMO-Snm2yv5uP01iENw%40mail.gmail.com.


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

2021-04-28 Thread Laurent Daverio
Hello List,

I'd like to report a problem I've just encountered, occurring betwen
Pyramid's CSRF protection and Deform.

Basically, I have a Pyramid 2.0 web app configured along the lines of
the "URL dispatch wiki tutorial"
(https://docs.pylonsproject.org/projects/pyramid/en/2.0-branch/tutorials/wiki2/authentication.html),
with some Deform forms in it.

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.

As I don't have the time/energy to fully investigate the problem right
now, I think I will just use a workaround: as I'm using Diazo as a
theming engine (awesome tech, btw), I think I will add a rule to
inject the token into every form. Should work.

Still, I wanted to take the time to report the problem, in case it
could be useful.

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/CAB7cU6xD%2B%2BKmdV7imR-w9kRjmNLdqTsoM1MVG0%2BrEpBsLgm94w%40mail.gmail.com.


Re: [pylons-discuss] pylonsproject.org and trypyramid.com updates

2022-02-13 Thread Laurent Daverio
Hello Steve,

I will give it a look. Why not jump directly to Bootstrap 5? Current
version is 5.1.3

Laurent.

Le lun. 14 févr. 2022 à 02:29, Steve Piercy
 a écrit :
>
> Does anyone care to update our marketing websites pylonsproject.org and 
> trypyramid.com to the latest packages, including Bootstrap 4?
>
> I gave it a shot, but entered a rabbit-hole of dependency and migration hell.
>
> https://github.com/Pylons/trypyramid.com/pull/320
> https://github.com/Pylons/pylonsproject.org/pull/103
>
> --steve
>
> --
> 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/b9079c50-0527-d815-3019-069b21dd12d5%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/CAB7cU6xow1u%2Buo1RY3yerZdGUjU3KeBFJToLmZG%3DJkSLAGLv9A%40mail.gmail.com.


Re: [pylons-discuss] pylonsproject.org and trypyramid.com updates

2022-02-18 Thread Laurent Daverio
Just added a "bootrstrap5" branch containing changes required to make
the front page work with Bootstrap 5.1.3

Le sam. 19 févr. 2022 à 01:51, Laurent Daverio  a écrit :
>
> Hello Steve,
>
> You can have a look at the current state of the works here:
> https://github.com/ldaverio/trypyramid.com/.
>
> Basically, I have upgraded all that I could upgrade:
> - Bootstrap 3 -> 4 (I'll try 5 later, I came across a compatibility
> problem, don't remember with what Node module)
> - Webpack 4 -> 5
> - Node-sass -> Sass
> ...
>
> (Note: highlight.js needs to remain at version 10, apparently,
> otherwise code expansion no longer works)
>
> I have adapted the main page to work with Bootstrap 4 (updated the
> navbar, updated the CSS), it's not 100% finished, or identical to the
> Bootstrap 3 version, but it can already be shown "as is". I haven't
> checked the other pages yet, or components like bootstrap-multiselect,
> so they might not work with Bootstrap 4.
>
> The commits are made so that the different steps of the upgrade are
> easier to follow, I did some commit squashing on the way to keep the
> log clean.
>
> I think that's all for now, let me know what you think, and what I
> should improve.
>
> Cheers,
> Laurent.
>
> Le lun. 14 févr. 2022 à 11:06, Laurent Daverio  a écrit :
> >
> > node-sass seems to be deprecated, and should be replaced with Dart
> > Sass (https://www.npmjs.com/package/node-sass).
> > If you do just that (yarn remove node-sass; yard add -D sass),
> > dependency problems just go away.
> >
> > I'm on a boat on Bosphorus, need to land soon, so the rest will have
> > to wait a little...
> >
> > > >> I gave it a shot, but entered a rabbit-hole of dependency and 
> > > >> migration hell.
> > > >>
> > > >> https://github.com/Pylons/trypyramid.com/pull/320
> > > >> https://github.com/Pylons/pylonsproject.org/pull/103

-- 
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/CAB7cU6xBtQKcikE0vA2rKJkquPLxaDXb-1JusFs1%2B3KVZ_voFg%40mail.gmail.com.


Re: [pylons-discuss] pylonsproject.org and trypyramid.com updates

2022-02-18 Thread Laurent Daverio
Hello Steve,

You can have a look at the current state of the works here:
https://github.com/ldaverio/trypyramid.com/.

Basically, I have upgraded all that I could upgrade:
- Bootstrap 3 -> 4 (I'll try 5 later, I came across a compatibility
problem, don't remember with what Node module)
- Webpack 4 -> 5
- Node-sass -> Sass
...

(Note: highlight.js needs to remain at version 10, apparently,
otherwise code expansion no longer works)

I have adapted the main page to work with Bootstrap 4 (updated the
navbar, updated the CSS), it's not 100% finished, or identical to the
Bootstrap 3 version, but it can already be shown "as is". I haven't
checked the other pages yet, or components like bootstrap-multiselect,
so they might not work with Bootstrap 4.

The commits are made so that the different steps of the upgrade are
easier to follow, I did some commit squashing on the way to keep the
log clean.

I think that's all for now, let me know what you think, and what I
should improve.

Cheers,
Laurent.

Le lun. 14 févr. 2022 à 11:06, Laurent Daverio  a écrit :
>
> node-sass seems to be deprecated, and should be replaced with Dart
> Sass (https://www.npmjs.com/package/node-sass).
> If you do just that (yarn remove node-sass; yard add -D sass),
> dependency problems just go away.
>
> I'm on a boat on Bosphorus, need to land soon, so the rest will have
> to wait a little...
>
> > >> I gave it a shot, but entered a rabbit-hole of dependency and migration 
> > >> hell.
> > >>
> > >> https://github.com/Pylons/trypyramid.com/pull/320
> > >> https://github.com/Pylons/pylonsproject.org/pull/103

-- 
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/CAB7cU6x3Ldj2Yd2Bjycn20C3t%3D-eq7pHGnKFnEy_h%2B3gsg%2BPzw%40mail.gmail.com.


Re: [pylons-discuss] pylonsproject.org and trypyramid.com updates

2022-02-19 Thread Laurent Daverio
> Would you please consider submitting a PR against pylons/trypyramid.com? Then 
> other people could more easily review and contribute.

Done :) Bootsrap 5 it is after all. But I realised at the very end
that `bootstrap-multiselect` was posing a problem... Not willing to
backtrack, I'll find a better solution.

https://github.com/Pylons/trypyramid.com/pull/324

Cheers,

Laurent.

Le sam. 19 févr. 2022 à 09:52, Steve Piercy
 a écrit :
>
> Hi Laurent,
>
> First, thank you for your work and volunteering to move this forward.
>
> Would you please consider submitting a PR against pylons/trypyramid.com? Then 
> other people could more easily review and contribute.
>
> I also want to try something: preview builds using Netlify under the Pylons 
> organization. On each commit in a PR against a specified branch, a preview of 
> the site can be built, deployed, and previewed by the public without cloning 
> and building locally. I've been doing this while working on Plone 6 
> Documentation, and it saves a lot of time during reviews.
>
> https://620ff8a3c2a27f00081bebf3--6-dev-docs-plone-org.netlify.app/glossary.html#term-fence
>
> --steve
>
>
> On 2/18/22 4:41 PM, Laurent Daverio wrote:
> > Just added a "bootrstrap5" branch containing changes required to make
> > the front page work with Bootstrap 5.1.3
> >
> > Le sam. 19 févr. 2022 à 01:51, Laurent Daverio  a écrit 
> > :
> >>
> >> Hello Steve,
> >>
> >> You can have a look at the current state of the works here:
> >> https://github.com/ldaverio/trypyramid.com/.
> >>
> >> Basically, I have upgraded all that I could upgrade:
> >> - Bootstrap 3 -> 4 (I'll try 5 later, I came across a compatibility
> >> problem, don't remember with what Node module)
> >> - Webpack 4 -> 5
> >> - Node-sass -> Sass
> >> ...
> >>
> >> (Note: highlight.js needs to remain at version 10, apparently,
> >> otherwise code expansion no longer works)
> >>
> >> I have adapted the main page to work with Bootstrap 4 (updated the
> >> navbar, updated the CSS), it's not 100% finished, or identical to the
> >> Bootstrap 3 version, but it can already be shown "as is". I haven't
> >> checked the other pages yet, or components like bootstrap-multiselect,
> >> so they might not work with Bootstrap 4.
> >>
> >> The commits are made so that the different steps of the upgrade are
> >> easier to follow, I did some commit squashing on the way to keep the
> >> log clean.
> >>
> >> I think that's all for now, let me know what you think, and what I
> >> should improve.
> >>
> >> Cheers,
> >> Laurent.
> >>
> >> Le lun. 14 févr. 2022 à 11:06, Laurent Daverio  a 
> >> écrit :
> >>>
> >>> node-sass seems to be deprecated, and should be replaced with Dart
> >>> Sass (https://www.npmjs.com/package/node-sass).
> >>> If you do just that (yarn remove node-sass; yard add -D sass),
> >>> dependency problems just go away.
> >>>
> >>> I'm on a boat on Bosphorus, need to land soon, so the rest will have
> >>> to wait a little...
> >>>
> >>>>>> I gave it a shot, but entered a rabbit-hole of dependency and 
> >>>>>> migration hell.
> >>>>>>
> >>>>>> https://github.com/Pylons/trypyramid.com/pull/320
> >>>>>> https://github.com/Pylons/pylonsproject.org/pull/103
> >
>
> --
> 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/d9317248-5e91-0bf8-6ebd-f6c241fec2a6%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/CAB7cU6xf4pv_zit4SFnycHAGzUG1zr6TguRFg1-q_MG%2BztuZNA%40mail.gmail.com.


Re: [pylons-discuss] pylonsproject.org and trypyramid.com updates

2022-02-18 Thread Laurent Daverio
Hi Steve,

sure, I was planning to do a PR, but I need to add a few finishing
touches to it first.

Most of the commits marked "WIP" (apart from the last one) are
probably not functional, because my attempts took me to many
directions in the same time, and I privileged the clarity of the
commit logs, so as to explain what I had done.

I spent the whole of 2021 working on a big site upgrade project, from
Plone 4.2 to 5.2. Now that this is over, I should start looking at
Plone 6, I guess :)

Le sam. 19 févr. 2022 à 09:52, Steve Piercy
 a écrit :
>
> Hi Laurent,
>
> First, thank you for your work and volunteering to move this forward.
>
> Would you please consider submitting a PR against pylons/trypyramid.com? Then 
> other people could more easily review and contribute.
>
> I also want to try something: preview builds using Netlify under the Pylons 
> organization. On each commit in a PR against a specified branch, a preview of 
> the site can be built, deployed, and previewed by the public without cloning 
> and building locally. I've been doing this while working on Plone 6 
> Documentation, and it saves a lot of time during reviews.
>
> https://620ff8a3c2a27f00081bebf3--6-dev-docs-plone-org.netlify.app/glossary.html#term-fence
>
> --steve
>
>
> On 2/18/22 4:41 PM, Laurent Daverio wrote:
> > Just added a "bootrstrap5" branch containing changes required to make
> > the front page work with Bootstrap 5.1.3
> >
> > Le sam. 19 févr. 2022 à 01:51, Laurent Daverio  a écrit 
> > :
> >>
> >> Hello Steve,
> >>
> >> You can have a look at the current state of the works here:
> >> https://github.com/ldaverio/trypyramid.com/.
> >>
> >> Basically, I have upgraded all that I could upgrade:
> >> - Bootstrap 3 -> 4 (I'll try 5 later, I came across a compatibility
> >> problem, don't remember with what Node module)
> >> - Webpack 4 -> 5
> >> - Node-sass -> Sass
> >> ...
> >>
> >> (Note: highlight.js needs to remain at version 10, apparently,
> >> otherwise code expansion no longer works)
> >>
> >> I have adapted the main page to work with Bootstrap 4 (updated the
> >> navbar, updated the CSS), it's not 100% finished, or identical to the
> >> Bootstrap 3 version, but it can already be shown "as is". I haven't
> >> checked the other pages yet, or components like bootstrap-multiselect,
> >> so they might not work with Bootstrap 4.
> >>
> >> The commits are made so that the different steps of the upgrade are
> >> easier to follow, I did some commit squashing on the way to keep the
> >> log clean.
> >>
> >> I think that's all for now, let me know what you think, and what I
> >> should improve.
> >>
> >> Cheers,
> >> Laurent.
> >>
> >> Le lun. 14 févr. 2022 à 11:06, Laurent Daverio  a 
> >> écrit :
> >>>
> >>> node-sass seems to be deprecated, and should be replaced with Dart
> >>> Sass (https://www.npmjs.com/package/node-sass).
> >>> If you do just that (yarn remove node-sass; yard add -D sass),
> >>> dependency problems just go away.
> >>>
> >>> I'm on a boat on Bosphorus, need to land soon, so the rest will have
> >>> to wait a little...
> >>>
> >>>>>> I gave it a shot, but entered a rabbit-hole of dependency and 
> >>>>>> migration hell.
> >>>>>>
> >>>>>> https://github.com/Pylons/trypyramid.com/pull/320
> >>>>>> https://github.com/Pylons/pylonsproject.org/pull/103
> >
>
> --
> 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/d9317248-5e91-0bf8-6ebd-f6c241fec2a6%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/CAB7cU6z2CZ8ZGRtVMGJiBGh4_oC1wfoPunCMwpFWS6YryPCK_A%40mail.gmail.com.


Re: [pylons-discuss] pylonsproject.org and trypyramid.com updates

2022-02-14 Thread Laurent Daverio
node-sass seems to be deprecated, and should be replaced with Dart
Sass (https://www.npmjs.com/package/node-sass).
If you do just that (yarn remove node-sass; yard add -D sass),
dependency problems just go away.

I'm on a boat on Bosphorus, need to land soon, so the rest will have
to wait a little...

> >> I gave it a shot, but entered a rabbit-hole of dependency and migration 
> >> hell.
> >>
> >> https://github.com/Pylons/trypyramid.com/pull/320
> >> https://github.com/Pylons/pylonsproject.org/pull/103

-- 
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/CAB7cU6yqaFd%3DF1qMQHcj0kgNhg3s8QdDRdF%2Be95RTfH7OsLuZg%40mail.gmail.com.


Re: [pylons-discuss] pylonsproject.org and trypyramid.com updates

2022-02-13 Thread Laurent Daverio
Well, I remained stuck at version 3 for a long time because of my
Pyramid projects, then 4 because that was the version offered by
react-bootstrap at the time (2019-2020). But 5 has been out for some
time now, so I guess it's both stable and supported. I made the switch
not too long ago, everything fine, nicer than 4, which was nicer than
3.

Laurent.

Le lun. 14 févr. 2022 à 08:55, Steve Piercy
 a écrit :
>
> 5 would be good, too. I tried 5 first, but hit a wall, so I assumed 4 would 
> have better support.
>
> The easiest route forward might be to start with a clean project, and build 
> up packages as needed.
>
> We use Hugo to generate the static sites.
>
> --steve
>
>
> On 2/13/22 9:09 PM, Laurent Daverio wrote:
> > Hello Steve,
> >
> > I will give it a look. Why not jump directly to Bootstrap 5? Current
> > version is 5.1.3
> >
> > Laurent.
> >
> > Le lun. 14 févr. 2022 à 02:29, Steve Piercy
> >  a écrit :
> >>
> >> Does anyone care to update our marketing websites pylonsproject.org and 
> >> trypyramid.com to the latest packages, including Bootstrap 4?
> >>
> >> I gave it a shot, but entered a rabbit-hole of dependency and migration 
> >> hell.
> >>
> >> https://github.com/Pylons/trypyramid.com/pull/320
> >> https://github.com/Pylons/pylonsproject.org/pull/103
> >>
> >> --steve
> >>
> >> --
> >> 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/b9079c50-0527-d815-3019-069b21dd12d5%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/c84ccc6e-e188-de80-ff59-ffa8bb0baf88%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/CAB7cU6wFqP-Eq7XH_LtdehoAAV%2BJtidDBH4Ldw65NYaB_ZnO3Q%40mail.gmail.com.


Re: [pylons-discuss] Hypatia alternative?

2022-04-17 Thread Laurent Daverio
Hi Thierry,

when I started using Pyramid (Pylons, actually), my first idea was to
integrate the Xapian library, written in C++. Coming from the Zope
world, I tried to adopt some ideas from the ZCatalog. Xapian worked
great, except for one problem: it's a library, not a server, thus it
doesn't handle concurrent updates gracefully (doesn't handle them at
all, actually...).

So, after a little while, I decided to switch to Solr, which is a
great indexing engine written in Java. It takes a little while to get
familiar with it, but it's worth the effort. I used `scorched` for
interfacing with Python. Please note that the PyPI release doesn't
work with Python 3.10, but the Github version does. Scorched doesn't
seem to be actively maintained, unfortunately, but it works fine. I'm
aware that ElasticSearch might be more popular than Solr these days
(they're both based on the ame Apache Lucene libraries), but I haven't
had the motivation to try it out.

I you're looking for a pure Python solution, Whoosh could be a choice,
but it doesn't seem to be actively maintained either. At some point, I
tried to integrate it with Pyramid, but I didn't have enough
motivation to finalise it (I'm happy with Solr, it's superfast, and if
you're doing frontend programming, you can process its JSON responses
directly).

Please note that both Solr/ElasticSearch and Woosh offer faceting, a
feature missing from the ZCatalog.

Hope this helps,

Laurent.

Le dim. 17 avr. 2022 à 13:14, Thierry Florac  a écrit :
>
> Hi,
>
> I'm actually using the Hypatia package for content indexing and I'm very 
> happy with it, but this package doesn't seem to be updated for a very long 
> time (2 years since last commit).
> Actually, my own packages unit tests are failing when using Python 3.10 with 
> Hypatia, so I was wondering if it is actually used and maintained, or is 
> there any alternative ?
>
> Best regards,
> Thierry
> --
>   https://www.ulthar.net -- http://pyams.readthedocs.io
>
> --
> 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/CAPX_VWBOptsdANDDQZiZGEaXqVnWfv2Oa4aFty4YHD2%2BT-60_Q%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/CAB7cU6xX51RLsgetgTbWsgzJfzHaF_t0RcZVi2cPWVOTi0tEtQ%40mail.gmail.com.


Re: [pylons-discuss] pylonsproject.org and trypyramid.com updates

2022-04-17 Thread Laurent Daverio
Hello list,

has anyone taken the time to look at the Bootstrap 5 port of the site?

Cheers,
Laurent.

Le ven. 18 févr. 2022 à 23:51, Laurent Daverio  a écrit :
>
> Hello Steve,
>
> You can have a look at the current state of the works here:
> https://github.com/ldaverio/trypyramid.com/.
>
> Basically, I have upgraded all that I could upgrade:
> - Bootstrap 3 -> 4 (I'll try 5 later, I came across a compatibility
> problem, don't remember with what Node module)
> - Webpack 4 -> 5
> - Node-sass -> Sass
> ...
>
> (Note: highlight.js needs to remain at version 10, apparently,
> otherwise code expansion no longer works)
>
> I have adapted the main page to work with Bootstrap 4 (updated the
> navbar, updated the CSS), it's not 100% finished, or identical to the
> Bootstrap 3 version, but it can already be shown "as is". I haven't
> checked the other pages yet, or components like bootstrap-multiselect,
> so they might not work with Bootstrap 4.
>
> The commits are made so that the different steps of the upgrade are
> easier to follow, I did some commit squashing on the way to keep the
> log clean.
>
> I think that's all for now, let me know what you think, and what I
> should improve.
>
> Cheers,
> Laurent.
>
> Le lun. 14 févr. 2022 à 11:06, Laurent Daverio  a écrit :
> >
> > node-sass seems to be deprecated, and should be replaced with Dart
> > Sass (https://www.npmjs.com/package/node-sass).
> > If you do just that (yarn remove node-sass; yard add -D sass),
> > dependency problems just go away.
> >
> > I'm on a boat on Bosphorus, need to land soon, so the rest will have
> > to wait a little...
> >
> > > >> I gave it a shot, but entered a rabbit-hole of dependency and 
> > > >> migration hell.
> > > >>
> > > >> https://github.com/Pylons/trypyramid.com/pull/320
> > > >> https://github.com/Pylons/pylonsproject.org/pull/103

-- 
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/CAB7cU6wf%3DcMQgc4YA%2Brf5HXoSkDJNZhpwoSUofEt5HeQ65o%3DeQ%40mail.gmail.com.


Re: [pylons-discuss] Hypatia alternative?

2022-04-17 Thread Laurent Daverio
Ah yes, that was my rationale for looking at Whoosh. I figured it
would be nice to have a self-contained solution which could run e.g.
on a Raspberry Pi, with SQLite instead of PostgreSQL, and Whoosh
instead of Solr. But I remember running into some interfacing problems
(Whoosh and Solr don't look quite the same from the outside), and the
work has been dormant for a couple of years.

Actually I'm not sure about the status of Whoosh - Just checked, the
last PyPI release was in 2016, but the last Github commit was only 3
months ago.

Le dim. 17 avr. 2022 à 17:11, Thierry Florac  a écrit :
>
> Hi Laurent,
>
> I'm actually using Elasticsearch, with a custom integration package to 
> include it in my framework!
> It works very well, but I'm also looking for a default alternative, 
> "internal" and lighter, as Hypatia does, which doesn't rely on an external 
> service to handle objects cataloging, and which is really sufficient to 
> handle indexing of small to medium websites...
> Maybe I'll try to fork and make a merge request; Python 3.10 is not my actual 
> target actually but it will probably be an option in the near future!
>
> Best regards,
> Thierry
> --
>   https://www.ulthar.net -- http://pyams.readthedocs.io
>
>
> Le dim. 17 avr. 2022 à 15:09, Laurent Daverio  a écrit :
>>
>> Hi Thierry,
>>
>> when I started using Pyramid (Pylons, actually), my first idea was to
>> integrate the Xapian library, written in C++. Coming from the Zope
>> world, I tried to adopt some ideas from the ZCatalog. Xapian worked
>> great, except for one problem: it's a library, not a server, thus it
>> doesn't handle concurrent updates gracefully (doesn't handle them at
>> all, actually...).
>>
>> So, after a little while, I decided to switch to Solr, which is a
>> great indexing engine written in Java. It takes a little while to get
>> familiar with it, but it's worth the effort. I used `scorched` for
>> interfacing with Python. Please note that the PyPI release doesn't
>> work with Python 3.10, but the Github version does. Scorched doesn't
>> seem to be actively maintained, unfortunately, but it works fine. I'm
>> aware that ElasticSearch might be more popular than Solr these days
>> (they're both based on the ame Apache Lucene libraries), but I haven't
>> had the motivation to try it out.
>>
>> I you're looking for a pure Python solution, Whoosh could be a choice,
>> but it doesn't seem to be actively maintained either. At some point, I
>> tried to integrate it with Pyramid, but I didn't have enough
>> motivation to finalise it (I'm happy with Solr, it's superfast, and if
>> you're doing frontend programming, you can process its JSON responses
>> directly).
>>
>> Please note that both Solr/ElasticSearch and Woosh offer faceting, a
>> feature missing from the ZCatalog.
>>
>> Hope this helps,
>>
>> Laurent.
>>
>> Le dim. 17 avr. 2022 à 13:14, Thierry Florac  a écrit :
>> >
>> > Hi,
>> >
>> > I'm actually using the Hypatia package for content indexing and I'm very 
>> > happy with it, but this package doesn't seem to be updated for a very long 
>> > time (2 years since last commit).
>> > Actually, my own packages unit tests are failing when using Python 3.10 
>> > with Hypatia, so I was wondering if it is actually used and maintained, or 
>> > is there any alternative ?
>> >
>> > Best regards,
>> > Thierry
>> > --
>> >   https://www.ulthar.net -- http://pyams.readthedocs.io
>> >
>> > --
>> > 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/CAPX_VWBOptsdANDDQZiZGEaXqVnWfv2Oa4aFty4YHD2%2BT-60_Q%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/CAB7cU6xX51RLsgetgTbWsgzJfzHaF_t0RcZVi2cPWVOTi0tEtQ%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 ema

Re: [pylons-discuss] Display query and result on the same page

2023-11-23 Thread Laurent Daverio
Hi Mike,

.filter() and .filter_by() are still both valid in SQLAlchemy 2.x. I think
.filter() is a synonym of .where().

Note : what is deprecated, but still available, is the "query syntax". I
even think it's no longer documented. Recommended syntaxes are here:

https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-orm-usage

It's a bit more verbose, but closer to SQL :)

Laurent.

Le jeu. 23 nov. 2023 à 20:08, Mike Orr  a écrit :

> On Thu, Nov 23, 2023 at 7:03 AM Oberdan Santos 
> wrote:
> > O codigo no formato acima não executou, apresentou erro, mas foi de
> grande valia,  muito obrigado). Fiz uma pequena alteração e deu certo.
> > Funcionou assim:
> > cpf = request.params["cpf"]
> >rows =
> request.dbsession.query(Paciente).filter(Paciente.cpf==cpf).all()
>
> I remembered that after I wrote the comment, that it's
> `filtey(Paciente.cpf==cpf)` and `filter_by(cpf=cpf)`. And `filter_by'
> may not be supported in SQLAlchemy 2.0? I'm still on 1.4/1.3.
>
> I'm afraid I don't know enough Portuguese to understand the rest of the
> message.
>
> --
> 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/CAH9f%3DupAGsreB_H48SxC0_5fRctbdKSxs7kn1dcOrfZRaycJbw%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/CAB7cU6zkW0WfNdsjtUd-iHPsTJy%2BYZsophLZRht1BSNRwjWo%3Dg%40mail.gmail.com.


Re: [pylons-discuss] Display query and result on the same page

2023-11-23 Thread Laurent Daverio
Well, to be honest, it's not a question about Pyramid, it's a question
about an absolutely basic pattern in web programming. I was doing that with
Perl CGI scripts 25 years ago, when Python was still in infancy, and
Pyramid didn't exist.

The problem is actually very simple : you use *one* view, not two, i.e. the
form must call its own URL (e.g. action="#")

The view tests if a non-null parameter "cpf" had been provided. If that's
the case, you compute the results (SQL query), and you send the two values
to the template (cpf, and the rows).

The template tests if it receives a "cpf" parameter. If so, it auto-fills
the form, and displays the rows (using a combination of {%if ...}, {%for
...} etc. as appropriate).

Again, it's not a Pyramid question, or a Pyramid solution, I would have
given you exactly the same answer with FastAPI, PHP, Rails, Flask, etc.

Le jeu. 23 nov. 2023 à 20:50, Oberdan Santos  a
écrit :

> You should note in the subject statement that in addition to the query, I
> have the problem of the result being published on another page.
> query page code
> # templates/pac_recepx.jinja2
>
> 
> 
> Consultar cadastro do
> paciente
> 
> http://localhost:6543/queryx; method="GET">
> Digite o CPF (11 números)
>  name="cpf" required maxlength="11" value=''>
>  type="submit">Consultar
> 
> 
>
> The result is going to...
> action="http://localhost:6543/queryx
>
> How do I take this result to the same page as the query
> (templates/pac_recepx.jinja2), that is, place it below the query?
>
> Thank you in advance for your support.
>
> Oberdan Costa
>
> Em quinta-feira, 23 de novembro de 2023 às 16:19:16 UTC-3, Laurent Daverio
> escreveu:
>
>> Hi Mike,
>>
>> .filter() and .filter_by() are still both valid in SQLAlchemy 2.x. I
>> think .filter() is a synonym of .where().
>>
>> Note : what is deprecated, but still available, is the "query syntax". I
>> even think it's no longer documented. Recommended syntaxes are here:
>>
>>
>> https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-orm-usage
>>
>> It's a bit more verbose, but closer to SQL :)
>>
>> Laurent.
>>
>> Le jeu. 23 nov. 2023 à 20:08, Mike Orr  a écrit :
>>
>>> On Thu, Nov 23, 2023 at 7:03 AM Oberdan Santos 
>>> wrote:
>>> > O codigo no formato acima não executou, apresentou erro, mas foi de
>>> grande valia,  muito obrigado). Fiz uma pequena alteração e deu certo.
>>> > Funcionou assim:
>>> > cpf = request.params["cpf"]
>>> >rows =
>>> request.dbsession.query(Paciente).filter(Paciente.cpf==cpf).all()
>>>
>>> I remembered that after I wrote the comment, that it's
>>> `filtey(Paciente.cpf==cpf)` and `filter_by(cpf=cpf)`. And `filter_by'
>>> may not be supported in SQLAlchemy 2.0? I'm still on 1.4/1.3.
>>>
>>> I'm afraid I don't know enough Portuguese to understand the rest of the
>>> message.
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pylons-discuss/CAH9f%3DupAGsreB_H48SxC0_5fRctbdKSxs7kn1dcOrfZRaycJbw%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/b800223f-dcb3-4a1a-9cd3-ef8c74255b6dn%40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/b800223f-dcb3-4a1a-9cd3-ef8c74255b6dn%40googlegroups.com?utm_medium=email_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/CAB7cU6zhNwdSpUgDJKDxiwa1Ri1b5HPg1XG-UHjo1M%3DTZtrogg%40mail.gmail.com.


Re: [pylons-discuss] request for help upgrading the cookiecutter to support sqlalchemy 2.0

2024-01-29 Thread Laurent Daverio
Hello list,

I think I could do that, unless someone has volunteered already (I have A
LOT to do these days, wouldn't want to duplicate someone else's work).

Laurent.


Le lun. 29 janv. 2024 à 07:51, Michael Merickel  a
écrit :

> Hey folks,
>
> I'd really appreciate it if someone was willing to take the time to
> upgrade the pyramid-cookiecutter-starter to use SQLAlchemy 2.0 best
> practices. Things like rewriting the queries away from Query to simple
> select(), and using the more modern declarative mapper that is typing
> friendly.
>
> https://github.com/Pylons/pyramid-cookiecutter-starter/tree/main
>
> Once we get that upgraded, we'd need to fix up the wiki2 tutorial to
> reference the updated files accurately - but first step is just getting the
> cookiecutter updated.
>
> https://github.com/Pylons/pyramid/tree/main/docs/tutorials/wiki2
>
> Thanks!
>
> - Michael
>
> --
> 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/54913600-1D9F-47E9-B991-136D0B5A73F3%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/CAB7cU6yRtEqr6Gy1BhuTZQ-csh%2BSacb9pnDNbVnWy7cF5bTKgw%40mail.gmail.com.


Re: [pylons-discuss] REF. Problem registering data in the bank

2023-11-16 Thread Laurent Daverio
Hello, don't you have, by any chance, a URL like this in your frontend?

   '/mod_plataforma/mod1_plataforma/recepx/${save_url}'

If so, you should replace the simple quotes with backticks:

  `/mod_plataforma/mod1_plataforma/recepx/${save_url}`

To me, it looks like a Javascript typo, not a Pyramid error.

Laurent.

Le jeu. 16 nov. 2023 à 14:52, Oberdan Santos  a écrit :
>
> Hello!! I am facing a problem when trying to post data to the database. When 
> asking to send the application data I receive the following: Squashed 
> pyramid.httpexceptions.HTTPNotFound at 
> http://localhost:6543/mod_plataforma/mod1_plataforma/recepx/$%7Bsave_url%7D
>
> . Below is information about my files.
>
> # piprdc/piprdc/routes.py
> def includeme(config):
>  config.add_static_view('static', 'static', cache_max_age=3600)
>  config.add_route('home', '/')
>  config.add_route('modulo_x', '/mod_plataforma')
>  config.add_route('modulo1', '/mod_plataforma/mod1_plataforma')
>  config.add_route('modulo2', '/mod_plataforma/mod2_plataforma')
>  config.add_route('modulo3', '/mod_plataforma/mod3_plataforma')
>  config.add_route('modulo4', '/mod_plataforma/mod4_plataforma')
>  config.add_route('modulo5', '/mod_plataforma/mod5_plataforma')
>  config.add_route('modulo6', '/mod_plataforma/mod6_plataforma')
>  config.add_route('abcx', '/mod_plataforma/mod1_plataforma/recepx')
>  config.add_route('add_reg', 
> '/mod_plataforma/mod1_plataforma/recepx/add_reg')
>  config.add_route('query', '/mod_plataforma/mod1_plataforma/recepx/query')
>
> ..
>
> #views/default.py
> from pyramid.view import view_config
> from pyramid.response import Response
> from sqlalchemy.exc import SQLAlchemyError, DBAPIError
> from pyramid.httpexceptions import HTTPFound
> from .. import models
> from ..models import Patient
> from ..models import get_tm_session
> dbsession = get_tm_session
>
> view_config(route_name='add_reg', renderer='piprdc:templates/reg_pacx.jinja2')
> def add_reg(request):
>  save_url = request.route_url('add_reg')
>  request.route_url('query')
>  print('RUN')
>  if request.params:
>  id=request.params['id']
>  name=request.params['name']
>  age=request.params['age']
>  birth_date=request.params['birth_date']
>  sex=request.params['sex']
>  race=request.params['race']
>  fone=request.params['fone']
>  address=request.params['address']
>  cpf=request.params['cpf']
>  cns=request.params['cns']
>  patients=Patient(id=id, name=name, age=age, date_birth=date_birth, 
> sex=sex,
> race=race, phone=phone, address=address, cpf=cpf, 
> cns=cns)
>  try:
>  dbsession.add_reg(patients)
>  return HTTPFound(location=request.route_url('query'))
>  except DBAPIError:
>  return Response("DB ERROR")
>  else:
>  print('DO NOT RUN')
>  return{'save_url': save_url, 'project': 'piprdc'}
>
> 
>
> #templates/reg_pacx.jinja2
> {% extends "basefull.jinja2" %}
> {% block container %}
> 
> 
> Patient registration
> 
> Patient Id:  
> Patient Name:  
> Age:  
> Date of birth:  
> Gender:  
> Race:  
> Phone:  
> Address:  
> CPF:  
> CNS:  
>  
> 
> 
> {% endblock container %}
>
> 
> #models/__init__.py
>
> from sqlalchemy import engine_from_config
> from sqlalchemy.orm import sessionmaker
> from sqlalchemy.orm import configure_mappers
> from sqlalchemy_continuum.plugins import Plugin
> import zope.sqlalchemy
>
> from .mymodel import Patient # flake8: noqa
>
> configure_mappers()
>
> def get_engine(settings, prefix='sqlalchemy.'):
>  return engine_from_config(settings, prefix)
>
> def get_session_factory(engine):
>  factory = sessionmaker()
>  factory.configure(bind=engine)
>  return factory
>
> def get_tm_session(session_factory, transaction_manager, request=None):
> dbsession = session_factory(info={"request": request})
>  zope.sqlalchemy.register(
>  dbsession, transaction_manager=transaction_manager
>  )
>  return dbsession
> def includeme(config):
>
>  settings = config.get_settings()
>  settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager'
>
>   config.include('pyramid_tm')
>
>  config.include('pyramid_retry')
>
>  # hook to share the dbengine fixture in testing
>  dbengine = settings.get('dbengine')
>  if not dbengine:
>  dbengine = get_engine(settings)
>
>  session_factory = get_session_factory(dbengine)
>  config.registry['dbsession_factory'] = session_factory
>
>  def dbsession(request):
>  dbsession = request.environ.get('app.dbsession')
>  if dbsession is None:
>   dbsession = get_tm_session(
>  session_factory, request.tm, 

Re: [pylons-discuss] REF. Problem registering data in the bank

2023-11-16 Thread Laurent Daverio
Maybe you should take the time to follow the official Pyramid tutorials,
they would answer many of your questions.

In common Pyramid apps (including yours, I suppose), SQL transactions are
controlled by HTTP "transactions", which is extremely convenient: if the
view fails, the SQL transaction is rolled back. If the view succeeds, the
SQL transaction is committed automatically. You never write
request.dbsession.commit().

Please, please, take the time to read the tutorials. I'm willing to help,
but I think this list is not the right place for debugging your app.

Le jeu. 16 nov. 2023 à 21:48, Oberdan Santos  a
écrit :

> The new structure advanced, but presented another error that I don't know
> where to start and resolve it.
>
> @view_config(route_name='add', request_method='POST')
> def add(request):
> id=request.POST['id']
> name=request.POST['name']
> idade=request.POST['idade']
> data_nascimento=request.POST['data_nascimento']
> sexo=request.POST['sexo']
> raca=request.POST['raca']
> fone=request.POST['fone']
> endereco=request.POST['endereco']
> cpf=request.POST['cpf']
> cns=request.POST['cns']
> pacientes=Paciente(id=id, name=name, idade=idade, data_nascimento=
> data_nascimento, sexo=sexo, raca=raca, fone=fone, endereco=endereco, cpf=
> cpf, cns=cns)
> request.dbsession.add(pacientes)
> request.dbsession.commit()
> return HTTPFound(location='http://localhost:6543/lista')
>
> ERRO:
>   File
> "C:\Users\oberd\proj_piprdc\oberd\Lib\site-packages\zope\sqlalchemy\datamanager.py",
> line 333, in before_commit
> or self.transaction_manager.get().status == ZopeStatus.COMMITTING
>^^
> AssertionError: Transaction must be committed using the transaction manager
>
>
> Em quinta-feira, 16 de novembro de 2023 às 17:11:35 UTC-3, Laurent Daverio
> escreveu:
>
>> I think you want to write "request.dbsession.add(...)" instead.
>>
>> Function dbsession is not meant to be used directly, only to create
>> "request.dbsession", via "config.add_request_method(dbsession,
>> reify=True)". This way, in your code, you never have to declare or import
>> "dbsession", just use "request.dbsession" directly.
>>
>> Laurent.
>>
>> Le jeu. 16 nov. 2023 à 20:25, Oberdan Santos  a
>> écrit :
>>
>>> Sua dica esta correta.  Fiz algumas alterações e percebi avanços. No
>>> entanto estou com o seguinte erro:
>>> File "C:\Users\oberd\proj_piprdc\piprdc\piprdc\views\default.py", line
>>> 87, in add
>>> dbsession.add(pacientes)
>>> ^
>>> AttributeError: 'function' object has no attribute 'add'
>>>
>>>
>>> #models/__init__.py
>>>
>>> from sqlalchemy import engine_from_config
>>> from sqlalchemy.orm import sessionmaker
>>> from sqlalchemy.orm import configure_mappers
>>> from sqlalchemy_continuum.plugins import Plugin
>>> import zope.sqlalchemy
>>>
>>> from .mymodel import Patient # flake8: noqa
>>>
>>> configure_mappers()
>>>
>>> def get_engine(settings, prefix='sqlalchemy.'):
>>>  return engine_from_config(settings, prefix)
>>>
>>> def get_session_factory(engine):
>>>  factory = sessionmaker()
>>>  factory.configure(bind=engine)
>>>  return factory
>>>
>>> def get_tm_session(session_factory, transaction_manager, request=None):
>>> dbsession = session_factory(info={"request": request})
>>>  zope.sqlalchemy.register(
>>>  dbsession, transaction_manager=transaction_manager
>>>  )
>>>  return dbsession
>>> def includeme(config):
>>>
>>>  settings = config.get_settings()
>>>  settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager'
>>>
>>>   config.include('pyramid_tm')
>>>
>>>  config.include('pyramid_retry')
>>>
>>>  # hook to share the dbengine fixture in testing
>>>  dbengine = settings.get('dbengine')
>>>  if not dbengine:
>>>  dbengine = get_engine(settings)
>>>
>>>  session_factory = get_session_factory(dbengine)
>>>  config.registry['dbsession_factory'] = session_factory
>>>
>>>  def dbsession(request):
>>>  dbsession = request.environ.get('app.dbsession')
>>>  if dbsession is None:
>>>   dbsession = get_tm_session(
>&g

Re: [pylons-discuss] REF. Problem registering data in the bank

2023-11-16 Thread Laurent Daverio
I think you want to write "request.dbsession.add(...)" instead.

Function dbsession is not meant to be used directly, only to create
"request.dbsession", via "config.add_request_method(dbsession,
reify=True)". This way, in your code, you never have to declare or import
"dbsession", just use "request.dbsession" directly.

Laurent.

Le jeu. 16 nov. 2023 à 20:25, Oberdan Santos  a
écrit :

> Sua dica esta correta.  Fiz algumas alterações e percebi avanços. No
> entanto estou com o seguinte erro:
> File "C:\Users\oberd\proj_piprdc\piprdc\piprdc\views\default.py", line 87,
> in add
> dbsession.add(pacientes)
> ^
> AttributeError: 'function' object has no attribute 'add'
>
>
> #models/__init__.py
>
> from sqlalchemy import engine_from_config
> from sqlalchemy.orm import sessionmaker
> from sqlalchemy.orm import configure_mappers
> from sqlalchemy_continuum.plugins import Plugin
> import zope.sqlalchemy
>
> from .mymodel import Patient # flake8: noqa
>
> configure_mappers()
>
> def get_engine(settings, prefix='sqlalchemy.'):
>  return engine_from_config(settings, prefix)
>
> def get_session_factory(engine):
>  factory = sessionmaker()
>  factory.configure(bind=engine)
>  return factory
>
> def get_tm_session(session_factory, transaction_manager, request=None):
> dbsession = session_factory(info={"request": request})
>  zope.sqlalchemy.register(
>  dbsession, transaction_manager=transaction_manager
>  )
>  return dbsession
> def includeme(config):
>
>  settings = config.get_settings()
>  settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager'
>
>   config.include('pyramid_tm')
>
>  config.include('pyramid_retry')
>
>  # hook to share the dbengine fixture in testing
>  dbengine = settings.get('dbengine')
>  if not dbengine:
>  dbengine = get_engine(settings)
>
>  session_factory = get_session_factory(dbengine)
>  config.registry['dbsession_factory'] = session_factory
>
>  def dbsession(request):
>  dbsession = request.environ.get('app.dbsession')
>  if dbsession is None:
>   dbsession = get_tm_session(
>  session_factory, request.tm, request=request
>   config.add_request_method(dbsession, reify=True)
>
> .
>
> #views/default.py
> from pyramid.view import view_config
> from pyramid.response import Response
> from sqlalchemy.exc import SQLAlchemyError
> from pyramid.httpexceptions import HTTPFound
> from ..models import Paciente
> from ..models import get_tm_session
> dbsession = get_tm_session
>
> @view_config(route_name='add', request_method='POST')
> def add(request):
> id=request.POST['id']
> name=request.POST['name']
> idade=request.POST['idade']
> data_nascimento=request.POST['data_nascimento']
> sexo=request.POST['sexo']
> raca=request.POST['raca']
> fone=request.POST['fone']
> endereco=request.POST['endereco']
> cpf=request.POST['cpf']
> cns=request.POST['cns']
> pacientes=Paciente(id=id, name=name, idade=idade, data_nascimento=
> data_nascimento, sexo=sexo,
>    raca=raca, fone=fone, endereco=endereco, cpf=
> cpf, cns=cns)
> dbsession.add(pacientes)
> dbsession.commit()
> return HTTPFound(location='http://localhost:6543/')
>
> Já fiz algumas alterações, mas sem sucesso.
> ..
> Em quinta-feira, 16 de novembro de 2023 às 12:00:38 UTC-3, Laurent Daverio
> escreveu:
>
>> Hello, don't you have, by any chance, a URL like this in your frontend?
>>
>> '/mod_plataforma/mod1_plataforma/recepx/${save_url}'
>>
>> If so, you should replace the simple quotes with backticks:
>>
>> `/mod_plataforma/mod1_plataforma/recepx/${save_url}`
>>
>> To me, it looks like a Javascript typo, not a Pyramid error.
>>
>> Laurent.
>>
>> Le jeu. 16 nov. 2023 à 14:52, Oberdan Santos  a
>> écrit :
>> >
>> > Hello!! I am facing a problem when trying to post data to the database.
>> When asking to send the application data I receive the following: Squashed
>> pyramid.httpexceptions.HTTPNotFound at
>> http://localhost:6543/mod_plataforma/mod1_plataforma/recepx/$%7Bsave_url%7D
>> >
>> > . Below is information about my files.
>> >
>> > # piprdc/piprdc/routes.py
>> > def includeme(config):
>> > config.add_static_view('static', 'static', cache_max_age=3600)
>> > config.add_route('home', '/')
>> > config.add_

Re: [pylons-discuss] REF. Problem registering data in the bank

2023-11-16 Thread Laurent Daverio
Yes, that's true. If you write a monolithic app with Jinja templates, you
will use {{ }}. If you use a Javascript frontend, you will find that `${}`
is very convenient :)

Le jeu. 16 nov. 2023 à 21:52, Florian Schulze  a
écrit :

> With Jinja Templates you have to use {{ save_url }} not ${save_url}. You
> can see from the URL the form is trying to POST to that it contains the $
> sign. You can also see such things from your Browser HTML Inspector.
>
> Regards,
> Florian Schulze
>
> On 16 Nov 2023, at 14:51, Oberdan Santos wrote:
>
> Hello!! I am facing a problem when trying to post data to the database.
> When asking to send the application data I receive the following: Squashed
> pyramid.httpexceptions.HTTPNotFound at
> http://localhost:6543/mod_plataforma/mod1_plataforma/recepx/$%7Bsave_url%7D
>
> . Below is information about my files.
>
> # piprdc/piprdc/routes.py
> def includeme(config):
>  config.add_static_view('static', 'static', cache_max_age=3600)
>  config.add_route('home', '/')
>  config.add_route('modulo_x', '/mod_plataforma')
>  config.add_route('modulo1', '/mod_plataforma/mod1_plataforma')
>  config.add_route('modulo2', '/mod_plataforma/mod2_plataforma')
>  config.add_route('modulo3', '/mod_plataforma/mod3_plataforma')
>  config.add_route('modulo4', '/mod_plataforma/mod4_plataforma')
>  config.add_route('modulo5', '/mod_plataforma/mod5_plataforma')
>  config.add_route('modulo6', '/mod_plataforma/mod6_plataforma')
>  config.add_route('abcx', '/mod_plataforma/mod1_plataforma/recepx')
>  config.add_route('add_reg',
> '/mod_plataforma/mod1_plataforma/recepx/add_reg')
>  config.add_route('query',
> '/mod_plataforma/mod1_plataforma/recepx/query')
>
> ..
>
> #views/default.py
> from pyramid.view import view_config
> from pyramid.response import Response
> from sqlalchemy.exc import SQLAlchemyError, DBAPIError
> from pyramid.httpexceptions import HTTPFound
> from .. import models
> from ..models import Patient
> from ..models import get_tm_session
> dbsession = get_tm_session
>
> view_config(route_name='add_reg',
> renderer='piprdc:templates/reg_pacx.jinja2')
> def add_reg(request):
>  save_url = request.route_url('add_reg')
>  request.route_url('query')
>  print('RUN')
>  if request.params:
>  id=request.params['id']
>  name=request.params['name']
>  age=request.params['age']
>  birth_date=request.params['birth_date']
>  sex=request.params['sex']
>  race=request.params['race']
>  fone=request.params['fone']
>  address=request.params['address']
>  cpf=request.params['cpf']
>  cns=request.params['cns']
>  patients=Patient(id=id, name=name, age=age,
> date_birth=date_birth, sex=sex,
> race=race, phone=phone, address=address,
> cpf=cpf, cns=cns)
>  try:
>  dbsession.add_reg(patients)
>  return HTTPFound(location=request.route_url('query'))
>  except DBAPIError:
>  return Response("DB ERROR")
>  else:
>  print('DO NOT RUN')
>  return{'save_url': save_url, 'project': 'piprdc'}
>
> 
>
> #templates/reg_pacx.jinja2
> {% extends "basefull.jinja2" %}
> {% block container %}
> 
> 
> Patient registration
> 
> Patient Id:  
> Patient Name:  
> Age:  
> Date of birth:  
> Gender:  
> Race:  
> Phone:  
> Address:  
> CPF:  
> CNS:  
>  
> 
> 
> {% endblock container %}
>
> 
> #models/__init__.py
>
> from sqlalchemy import engine_from_config
> from sqlalchemy.orm import sessionmaker
> from sqlalchemy.orm import configure_mappers
> from sqlalchemy_continuum.plugins import Plugin
> import zope.sqlalchemy
>
> from .mymodel import Patient # flake8: noqa
>
> configure_mappers()
>
> def get_engine(settings, prefix='sqlalchemy.'):
>  return engine_from_config(settings, prefix)
>
> def get_session_factory(engine):
>  factory = sessionmaker()
>  factory.configure(bind=engine)
>  return factory
>
> def get_tm_session(session_factory, transaction_manager, request=None):
> dbsession = session_factory(info={"request": request})
>  zope.sqlalchemy.register(
>  dbsession, transaction_manager=transaction_manager
>  )
>  return dbsession
> def includeme(config):
>
>  settings = config.get_settings()
>  settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager'
>
>   config.include('pyramid_tm')
>
>  config.include('pyramid_retry')
>
>  # hook to share the dbengine fixture in testing
>  dbengine = settings.get('dbengine')
>  if not dbengine:
>  dbengine = get_engine(settings)
>
>  session_factory = get_session_factory(dbengine)
>  config.registry['dbsession_factory'] = session_factory
>
>  def dbsession(request):
>  dbsession = 

[pylons-discuss] Problems when using Gunicorn and Postgresql together

2023-11-16 Thread Laurent Daverio
Hello list,

this page seems to describe perfectly a problem I've stumbled on:

https://stackoverflow.com/questions/64995178/decryption-failed-or-bad-record-mac-in-multiprocessing

Namely, if you deploy with Gunicorn a Pyramid + PostgreSQL app based on the
standard cookiecutter, you will run into problems, because the connection
to the DB can't be shared between the processes, so each process needs to
have its own connection to the DB.

Before I start trying to develop a workaround, has anybody encountered the
problem? How should I modify my app to make it compatible with both
Waitress and Gunicorn?

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/CAB7cU6z1DqHpEazrrJ1sPHmSPQvYtfkmeKfsJP_jLmsDyPA96w%40mail.gmail.com.


Re: [pylons-discuss] REF. FORMULARIOS E VALIDAÇÃO (PYRAMID)

2023-11-17 Thread Laurent Daverio
Hello,

Deform has a big problem, it generates widgets for Bootstrap 3. I had
patched mine it to make it compatible with Bootstrap 4, but now the
standard version is Bootstrap 5. And I've switched to React and Material UI
anyway. In retrospect, I think it's not a good idea to use a library which
binds validation and widgets.

As regards validation itself, I started with Colander, it was complicated
but worked. Then I used "schema" for a few months. Now I've seen the light
and I use Pydantic. I wonder why I used anything else in the past... Coming
from FastAPI, I believe you must be familiar with Pydantic.

In case you need frontend validation too, you can have a look at Yup, it"s
a bit like "schema", but for Javascript. Unfortunately, there is no
equivalent to Pydantic...

Laurent.

Le ven. 17 nov. 2023 à 16:13, Oberdan Santos  a
écrit :

> Olá!!   Gostaria de saber se todos têm adotado o DEFORM como biblioteca
> padrão para formulario e validação  ou outras bibliotecas de uso facil com
> o Pyramid ?
>
> Oberdan costa
>
>
> --
> 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/f86a52d6-171d-4097-b595-4e3718105d74n%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/CAB7cU6xPpeo_mUBjTC9obqZiRXcm40qhco%2Bk%2BnDSvCHmjn8eoQ%40mail.gmail.com.


Re: [pylons-discuss] REF. FORMULARIOS E VALIDAÇÃO (PYRAMID)

2023-11-17 Thread Laurent Daverio
You can't integrate react-hook-form and yup with Pyramid(*), these are
frontend components. If your goal is to write a simple Pyramid app to get
started, don't use them yet, stick to a classic architecture with the
Python / Pyramid ecosystem.



Le ven. 17 nov. 2023 à 22:41, Oberdan Santos  a
écrit :

> Vejo que ainda há algumas pendencias a  serem resolvidas no Deform. Vi que
> o  REACT HOOK FORM + YUP é um boa solução para formularios e validações. No
> entanto, estou receioso quanto ao processo de integração dessas
> bibliotecas. Para evitar problemas na aplicação PYRAMID devo instalar o
> NODES  para suporte a essas  bibliotecas ou há algum outro procedimento.
> Caso tenha algum link de tutotial ou qualquer outro apoio, por gentileza
> envie.
>
> Desde já agradeço
>
> Em sexta-feira, 17 de novembro de 2023 às 17:42:56 UTC-3, Steve Piercy
> escreveu:
>
>> Deform has had a flurry of activity over the last couple of weeks to
>> update the widgets to use Bootstrap 5.3. I hope to have time this weekend
>> to make an alpha release, 3.0.0a.
>>
>> https://github.com/Pylons/deform/pull/529
>>
>> --steve
>>
>>
>> On 11/17/23 7:31 AM, Laurent Daverio wrote:
>>
>> Hello,
>>
>> Deform has a big problem, it generates widgets for Bootstrap 3. I had
>> patched mine it to make it compatible with Bootstrap 4, but now the
>> standard version is Bootstrap 5. And I've switched to React and Material UI
>> anyway. In retrospect, I think it's not a good idea to use a library which
>> binds validation and widgets.
>>
>> As regards validation itself, I started with Colander, it was complicated
>> but worked. Then I used "schema" for a few months. Now I've seen the light
>> and I use Pydantic. I wonder why I used anything else in the past... Coming
>> from FastAPI, I believe you must be familiar with Pydantic.
>>
>> In case you need frontend validation too, you can have a look at Yup,
>> it"s a bit like "schema", but for Javascript. Unfortunately, there is no
>> equivalent to Pydantic...
>>
>> Laurent.
>>
>> Le ven. 17 nov. 2023 à 16:13, Oberdan Santos  a
>> écrit :
>>
>>> Olá!!   Gostaria de saber se todos têm adotado o DEFORM como biblioteca
>>> padrão para formulario e validação  ou outras bibliotecas de uso facil com
>>> o Pyramid ?
>>>
>>> Oberdan costa
>>>
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pylons-discuss/f86a52d6-171d-4097-b595-4e3718105d74n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/pylons-discuss/f86a52d6-171d-4097-b595-4e3718105d74n%40googlegroups.com?utm_medium=email_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-discus...@googlegroups.com.
>>
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pylons-discuss/CAB7cU6xPpeo_mUBjTC9obqZiRXcm40qhco%2Bk%2BnDSvCHmjn8eoQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/pylons-discuss/CAB7cU6xPpeo_mUBjTC9obqZiRXcm40qhco%2Bk%2BnDSvCHmjn8eoQ%40mail.gmail.com?utm_medium=email_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/1a475df5-b563-4ff1-afd2-f5a9de737460n%40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/1a475df5-b563-4ff1-afd2-f5a9de737460n%40googlegroups.com?utm_medium=email_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/CAB7cU6zOeuUhYJiq4ZUqapB1Os-Rog2wE8wfeim29tj5sw%2BU4Q%40mail.gmail.com.


Re: [pylons-discuss] Getting error when running inspect in python 3.11, win11

2023-11-14 Thread Laurent Daverio
Our messages crossed, my previous one contains the answer to your question:

https://github.com/Pylons/pastedeploy/blame/main/src/paste/deploy/util.py#L36

Le mar. 14 nov. 2023 à 21:13, Oberdan Santos  a écrit :
>
> Checking the literature on some sites, I see that I have two options ( 
> inspect.signature() or inspect.getfullargspec() to solve the problem. The 
> question is: How to use inspect.signature() or the other option, where to 
> change it ? .The following is the function that was throwing error.
>
> import inspect
> import sys
>
> try:
> import importlib.metadata as importlib_metadata  # noqa F401
> except ImportError:  # pragma: no cover
> # bw-compat shim for py37
> import importlib_metadata  # noqa F401
>
>
> def fix_type_error(exc_info, callable, varargs, kwargs):
> """
> Given an exception, this will test if the exception was due to a
> signature error, and annotate the error with better information if
> so.
>
> Usage::
>
>   try:
>   val = callable(*args, **kw)
>   except TypeError:
>   exc_info = fix_type_error(None, callable, args, kw)
>   raise exc_info[0], exc_info[1], exc_info[2]
> """
> if exc_info is None:
> exc_info = sys.exc_info()
> if (
> exc_info[0] != TypeError
> or str(exc_info[1]).find('arguments') == -1
> or getattr(exc_info[1], '_type_error_fixed', False)
> ):
> return exc_info
> exc_info[1]._type_error_fixed = True
> argspec = inspect.formatargspec(*inspect.getargspec(callable))
> args = ', '.join(map(_short_repr, varargs))
> if kwargs and args:
> args += ', '
> if kwargs:
> kwargs = sorted(kwargs.items())
> args += ', '.join(['%s=...' % n for n, v in kwargs])
> gotspec = '(%s)' % args
> msg = f'{exc_info[1]}; got {gotspec}, wanted {argspec}'
> exc_info[1].args = (msg,)
> return exc_info
>
>
>
> Desde já agradeço,
> ]
> Oberdan Costa
>
> Em terça-feira, 14 de novembro de 2023 às 16:15:50 UTC-3, Oberdan Santos 
> escreveu:
>>
>> Thanks again for your attention. I will provide a brief contextualization.
>> I have a script based on FASTAPI for predicting the risk of chronic 
>> non-communicable diseases to aid clinical decision making in primary health 
>> care (backend), for now I will leave it like that. it works perfectly.
>> On the frontend I use streamlit to obtain the results of up to 10 chronic 
>> diseases simultaneously. This ended up growing to include other modules 
>> (routing and intelligent management). At the moment I'm looking for a robust 
>> framework for this application purpose and the pyramid environment has 
>> allowed me to move in this direction (I'm based on cookiecutter) for my 
>> first experiences. I have a modular division already structured.
>> Now I'm trying to connect to my database structure and I'm encountering this 
>> error when I run my application. From the request: I need help to take this 
>> step and fix this problem.
>>
>> Em terça-feira, 14 de novembro de 2023 às 16:00:06 UTC-3, Laurent Daverio 
>> escreveu:
>>>
>>> > The application I am requesting support for is based on the Pyramd 
>>> > Cookiecutter application framework. In this sense, my question is 
>>> > pertinent.
>>>
>>> Oh, I see why you posted here, sorry then. For my defence, you
>>> provided no context, no traceback, nothing indicating you were indeed
>>> referring to Pyramid. You only wrote "When trying to run my code I am
>>> receiving an error", and your code was only standard Python.
>>>
>>> > Why does pyramid continue to carry this module in its base application 
>>> > structures, such as cookiecutter?
>>>
>>> Actually, I'm not sure what problem you encountered :
>>>
>>> - it could be in the cookiecutter module, which is not related to
>>> Pyramid at all. It's definitely not a "base application structure" of
>>> Pyramid. I don't use "cookiecutter" very often, but I'm pretty sure I
>>> have used it with Python 3.11, and had no problem.
>>>
>>> - it could be in the Pyramid scaffold you used, which is indirectly
>>> related to Pyramid. I haven't used the "official" scaffold in a while,
>>> but I fail to see why it would create a base application which
>>> includes the "inspect" module.
>>>
>>> - it could be in Pyramid itself. But I would rule out that choice, as
>>> I use Pyramid wit

Re: [pylons-discuss] Getting error when running inspect in python 3.11, win11

2023-11-14 Thread Laurent Daverio
> The application I am requesting support for is based on the Pyramd 
> Cookiecutter application framework. In this sense, my question is pertinent.

Oh, I see why you posted here, sorry then. For my defence, you
provided no context, no traceback, nothing indicating you were indeed
referring to Pyramid. You only wrote "When trying to run my code I am
receiving an error", and your code was only standard Python.

> Why does pyramid continue to carry this module in its base application 
> structures, such as cookiecutter?

Actually, I'm not sure what problem you encountered :

- it could be in the cookiecutter module, which is not related to
Pyramid at all. It's definitely not a "base application structure" of
Pyramid. I don't use "cookiecutter" very often, but I'm pretty sure I
have used it with Python 3.11, and had no problem.

- it could be in the Pyramid scaffold you used, which is indirectly
related to Pyramid. I haven't used the "official" scaffold in a while,
but I fail to see why it would create a base application which
includes the "inspect" module.

- it could be in Pyramid itself. But I would rule out that choice, as
I use Pyramid with Python 3.11 daily, and the problem doesn't exist
for me.

When does your problem happen? When you're trying to use cookiecutter,
or when you try to launch the generated app?

Laurent.

PS: just a clarification in what I wrote previously: standard module
"inspect" is not deprecated at all, only function "formatargspec" is.

>
> Em terça-feira, 14 de novembro de 2023 às 15:30:53 UTC-3, Laurent Daverio 
> escreveu:
>>
>> Hello,
>>
>> a couple of remarks before replying to your question :
>>
>> 1/ This list is dedicated to Pylons and Pyramid, so a general question
>> about the Python standard library is off-topic
>> 2/ You could have googled "inspect formatargspec" and found answers
>> 3/ You could have read the documentation of the standard library
>>
>> The documentation of "inspect" for Python 3.10
>> (https://docs.python.org/3.10/library/inspect.html) states :
>>
>> "Deprecated since version 3.5: Use signature() and Signature Object,
>> which provide a better introspecting API for callables."
>>
>> And indeed, if you switch to the Python 3.11 / 3.12 versions of the
>> docs, you'll find that the function has been removed. You certainly
>> had a deprecation warning in Python 3.9/3.10, which you ignored
>>
>> My $0.02,
>>
>> Laurent.
>>
>>
>> Le mar. 14 nov. 2023 à 19:17, Oberdan Santos  a écrit :
>> >
>> > Hello!!
>> > When trying to run my code I am receiving an error.
>> >
>> > import inspect
>> > import sys
>> >
>> > try:
>> > import importlib.metadata as importlib_metadata # noqa F401
>> > except ImportError: # pragma: no cover
>> > # bw-compat shim for py37
>> > import importlib_metadata # noqa F401
>> >
>> >
>> > def fix_type_error(exc_info, callable, varargs, kwargs):
>> > """
>> > Given an exception, this will test if the exception was due to a
>> > signature error, and annotate the error with better information if
>> > so.
>> >
>> > Usage::
>> >
>> > try:
>> > val = callable(*args, **kw)
>> > except TypeError:
>> > exc_info = fix_type_error(None, callable, args, kw)
>> > raise exc_info[0], exc_info[1], exc_info[2]
>> > """
>> > if exc_info is None:
>> > exc_info = sys.exc_info()
>> > if (
>> > exc_info[0] != TypeError
>> > or str(exc_info[1]).find('arguments') == -1
>> > or getattr(exc_info[1], '_type_error_fixed', False)
>> > ):
>> > return exc_info
>> > exc_info[1]._type_error_fixed = True
>> > argspec = inspect.formatargspec(*inspect.getargspec(callable))
>> > args = ', '.join(map(_short_repr, varargs))
>> > if kwargs and args:
>> > args += ', '
>> > if kwargs:
>> > kwargs = sorted(kwargs.items())
>> > args += ', '.join(['%s=...' % n for n, v in kwargs])
>> > gotspec = '(%s)' % args
>> > msg = f'{exc_info[1]}; got {gotspec}, wanted {argspec}'
>> > exc_info[1].args = (msg,)
>> > return exc_info
>> >
>> >
>> >
>> > ERRO:
>> > AttributeError: module 'inspect' has no attribute 'formatargspec'.
>> > Did you mean: 'formatargvalues'?
>> >
>> >
>> > I've tried some changes to the code line, but to no avail.
>> > argspec = inspect.formatargspec(*insp

Re: [pylons-discuss] Getting error when running inspect in python 3.11, win11

2023-11-14 Thread Laurent Daverio
Hello,

a couple of remarks before replying to your question :

1/ This list is dedicated to Pylons and Pyramid, so a general question
about the Python standard library is off-topic
2/ You could have googled "inspect formatargspec" and found answers
3/ You could have read the documentation of the standard library

The documentation of "inspect" for Python 3.10
(https://docs.python.org/3.10/library/inspect.html) states :

"Deprecated since version 3.5: Use signature() and Signature Object,
which provide a better introspecting API for callables."

And indeed, if you switch to the Python 3.11 / 3.12 versions of the
docs, you'll find that the function has been removed. You certainly
had a deprecation warning in Python 3.9/3.10, which you ignored

My $0.02,

Laurent.


Le mar. 14 nov. 2023 à 19:17, Oberdan Santos  a écrit :
>
> Hello!!
> When trying to run my code I am receiving an error.
>
> import inspect
> import sys
>
> try:
> import importlib.metadata as importlib_metadata  # noqa F401
> except ImportError:  # pragma: no cover
> # bw-compat shim for py37
> import importlib_metadata  # noqa F401
>
>
> def fix_type_error(exc_info, callable, varargs, kwargs):
> """
> Given an exception, this will test if the exception was due to a
> signature error, and annotate the error with better information if
> so.
>
> Usage::
>
>   try:
>   val = callable(*args, **kw)
>   except TypeError:
>   exc_info = fix_type_error(None, callable, args, kw)
>   raise exc_info[0], exc_info[1], exc_info[2]
> """
> if exc_info is None:
> exc_info = sys.exc_info()
> if (
> exc_info[0] != TypeError
> or str(exc_info[1]).find('arguments') == -1
> or getattr(exc_info[1], '_type_error_fixed', False)
> ):
> return exc_info
> exc_info[1]._type_error_fixed = True
> argspec = inspect.formatargspec(*inspect.getargspec(callable))
> args = ', '.join(map(_short_repr, varargs))
> if kwargs and args:
> args += ', '
> if kwargs:
> kwargs = sorted(kwargs.items())
> args += ', '.join(['%s=...' % n for n, v in kwargs])
> gotspec = '(%s)' % args
> msg = f'{exc_info[1]}; got {gotspec}, wanted {argspec}'
> exc_info[1].args = (msg,)
> return exc_info
>
>
>
> ERRO:
> AttributeError: module 'inspect' has no attribute 'formatargspec'.
> Did you mean: 'formatargvalues'?
>
>
> I've tried some changes to the code line, but to no avail.
> argspec = inspect.formatargspec(*inspect.getargspec(callable))
> Every help is welcome
>
>
>
> --
> 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/cab4b239-75df-44ba-9d39-4fea371e2b6dn%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/CAB7cU6zgRfxSEvNAG8h%3DVHjciggq9adxoUeucOvM7HnYcmrKBA%40mail.gmail.com.


Re: [pylons-discuss] Getting error when running inspect in python 3.11, win11

2023-11-14 Thread Laurent Daverio
Thanks for the explanations :)

After some grepping in the source code, I have found that the function
you quoted belongs to third-party module PasteDeploy. Pyramid depends
on plaster-pastedeploy, which in turn depends on PasteDeploy.

And PasteDeploy (my version is 3.0.1) contains your code in file
paste/deploy/util.py, lines 13 to 46. Please note that it should be
fixed soon, as an unreleased change was recorded in Github last week :

https://github.com/Pylons/pastedeploy/blame/main/src/paste/deploy/util.py#L36

At this point, I would suggest 2 possibilities :

1/ You patch PastDeploy manually, or
2/ You determine who is calling that function, and why. For that,  you
need to look at the traceback of the error.



Le mar. 14 nov. 2023 à 20:15, Oberdan Santos  a écrit :
>
> Thanks again for your attention. I will provide a brief contextualization.
> I have a script based on FASTAPI for predicting the risk of chronic 
> non-communicable diseases to aid clinical decision making in primary health 
> care (backend), for now I will leave it like that. it works perfectly.
> On the frontend I use streamlit to obtain the results of up to 10 chronic 
> diseases simultaneously. This ended up growing to include other modules 
> (routing and intelligent management). At the moment I'm looking for a robust 
> framework for this application purpose and the pyramid environment has 
> allowed me to move in this direction (I'm based on cookiecutter) for my first 
> experiences. I have a modular division already structured.
> Now I'm trying to connect to my database structure and I'm encountering this 
> error when I run my application. From the request: I need help to take this 
> step and fix this problem.
>
> Em terça-feira, 14 de novembro de 2023 às 16:00:06 UTC-3, Laurent Daverio 
> escreveu:
>>
>> > The application I am requesting support for is based on the Pyramd 
>> > Cookiecutter application framework. In this sense, my question is 
>> > pertinent.
>>
>> Oh, I see why you posted here, sorry then. For my defence, you
>> provided no context, no traceback, nothing indicating you were indeed
>> referring to Pyramid. You only wrote "When trying to run my code I am
>> receiving an error", and your code was only standard Python.
>>
>> > Why does pyramid continue to carry this module in its base application 
>> > structures, such as cookiecutter?
>>
>> Actually, I'm not sure what problem you encountered :
>>
>> - it could be in the cookiecutter module, which is not related to
>> Pyramid at all. It's definitely not a "base application structure" of
>> Pyramid. I don't use "cookiecutter" very often, but I'm pretty sure I
>> have used it with Python 3.11, and had no problem.
>>
>> - it could be in the Pyramid scaffold you used, which is indirectly
>> related to Pyramid. I haven't used the "official" scaffold in a while,
>> but I fail to see why it would create a base application which
>> includes the "inspect" module.
>>
>> - it could be in Pyramid itself. But I would rule out that choice, as
>> I use Pyramid with Python 3.11 daily, and the problem doesn't exist
>> for me.
>>
>> When does your problem happen? When you're trying to use cookiecutter,
>> or when you try to launch the generated app?
>>
>> Laurent.
>>
>> PS: just a clarification in what I wrote previously: standard module
>> "inspect" is not deprecated at all, only function "formatargspec" is.
>>
>> >
>> > Em terça-feira, 14 de novembro de 2023 às 15:30:53 UTC-3, Laurent Daverio 
>> > escreveu:
>> >>
>> >> Hello,
>> >>
>> >> a couple of remarks before replying to your question :
>> >>
>> >> 1/ This list is dedicated to Pylons and Pyramid, so a general question
>> >> about the Python standard library is off-topic
>> >> 2/ You could have googled "inspect formatargspec" and found answers
>> >> 3/ You could have read the documentation of the standard library
>> >>
>> >> The documentation of "inspect" for Python 3.10
>> >> (https://docs.python.org/3.10/library/inspect.html) states :
>> >>
>> >> "Deprecated since version 3.5: Use signature() and Signature Object,
>> >> which provide a better introspecting API for callables."
>> >>
>> >> And indeed, if you switch to the Python 3.11 / 3.12 versions of the
>> >> docs, you'll find that the function has been removed. You certainly
>> >> had a deprecation warning in Python 3.9/3.10, which you

Re: [pylons-discuss] Getting error when running inspect in python 3.11, win11

2023-11-14 Thread Laurent Daverio
Glad to hear that, and many thanks for offering :) I'll let you know if I need.

You just mentioned a database, and it may be totally
irrelevant/unrelated, but it occurs to me that SQLAlchemy also has an
"inspect" function, which you use for introspecting your database. I
do use it, unlike the standard "inspect" :)

All the best,

Laurent.

Le mar. 14 nov. 2023 à 22:29, Oberdan Santos  a écrit :
>
>
> Thanks for the support. The error is gone, now I can see communication with 
> the database.
> My specialty is developing prediction models (Machine learning). If you need 
> anything in this field, I am at your disposal.
> Em terça-feira, 14 de novembro de 2023 às 17:17:54 UTC-3, Laurent Daverio 
> escreveu:
>>
>> Our messages crossed, my previous one contains the answer to your question:
>>
>> https://github.com/Pylons/pastedeploy/blame/main/src/paste/deploy/util.py#L36
>>
>> Le mar. 14 nov. 2023 à 21:13, Oberdan Santos  a écrit :
>> >
>> > Checking the literature on some sites, I see that I have two options ( 
>> > inspect.signature() or inspect.getfullargspec() to solve the problem. The 
>> > question is: How to use inspect.signature() or the other option, where to 
>> > change it ? .The following is the function that was throwing error.
>> >
>> > import inspect
>> > import sys
>> >
>> > try:
>> > import importlib.metadata as importlib_metadata # noqa F401
>> > except ImportError: # pragma: no cover
>> > # bw-compat shim for py37
>> > import importlib_metadata # noqa F401
>> >
>> >
>> > def fix_type_error(exc_info, callable, varargs, kwargs):
>> > """
>> > Given an exception, this will test if the exception was due to a
>> > signature error, and annotate the error with better information if
>> > so.
>> >
>> > Usage::
>> >
>> > try:
>> > val = callable(*args, **kw)
>> > except TypeError:
>> > exc_info = fix_type_error(None, callable, args, kw)
>> > raise exc_info[0], exc_info[1], exc_info[2]
>> > """
>> > if exc_info is None:
>> > exc_info = sys.exc_info()
>> > if (
>> > exc_info[0] != TypeError
>> > or str(exc_info[1]).find('arguments') == -1
>> > or getattr(exc_info[1], '_type_error_fixed', False)
>> > ):
>> > return exc_info
>> > exc_info[1]._type_error_fixed = True
>> > argspec = inspect.formatargspec(*inspect.getargspec(callable))
>> > args = ', '.join(map(_short_repr, varargs))
>> > if kwargs and args:
>> > args += ', '
>> > if kwargs:
>> > kwargs = sorted(kwargs.items())
>> > args += ', '.join(['%s=...' % n for n, v in kwargs])
>> > gotspec = '(%s)' % args
>> > msg = f'{exc_info[1]}; got {gotspec}, wanted {argspec}'
>> > exc_info[1].args = (msg,)
>> > return exc_info
>> >
>> >
>> >
>> > Desde já agradeço,
>> > ]
>> > Oberdan Costa
>> >
>> > Em terça-feira, 14 de novembro de 2023 às 16:15:50 UTC-3, Oberdan Santos 
>> > escreveu:
>> >>
>> >> Thanks again for your attention. I will provide a brief contextualization.
>> >> I have a script based on FASTAPI for predicting the risk of chronic 
>> >> non-communicable diseases to aid clinical decision making in primary 
>> >> health care (backend), for now I will leave it like that. it works 
>> >> perfectly.
>> >> On the frontend I use streamlit to obtain the results of up to 10 chronic 
>> >> diseases simultaneously. This ended up growing to include other modules 
>> >> (routing and intelligent management). At the moment I'm looking for a 
>> >> robust framework for this application purpose and the pyramid environment 
>> >> has allowed me to move in this direction (I'm based on cookiecutter) for 
>> >> my first experiences. I have a modular division already structured.
>> >> Now I'm trying to connect to my database structure and I'm encountering 
>> >> this error when I run my application. From the request: I need help to 
>> >> take this step and fix this problem.
>> >>
>> >> Em terça-feira, 14 de novembro de 2023 às 16:00:06 UTC-3, Laurent Daverio 
>> >> escreveu:
>> >>>
>> >>> > The application I am requesting support for is based on the Pyramd 
>> >>> > Cookiecutter application framework. In this sense, my question is 
>> >>> > pertinent.
&

Re: [pylons-discuss] Question about creating routes

2024-03-14 Thread Laurent Daverio
Thank you so much Theron, this is spot-on!

So, it was lambda after all (although not Pyramid). You've solved my
problem, I can move on to the next 

Thanks again,

Laurent.

Le jeu. 14 mars 2024 à 06:57, Theron Luhn  a écrit :

> That’s a result of the lack of block scoping in Python.  `op` is going to
> resolve when the lambda first executes, which is always after the loop has
> finished, and scoped to the containing function so `op` will always be the
> final loop value.
>
> Easiest workaround is to just wrap the loop contents in a function, so you
> get a fresh scope for each permutation.
>
> def make_routes(config, cat, op):
> config.add_route…
>
> for cat in ('actes', 'constats'):
> for op in ('archive', 'unarchive’):
>make_routes(config, cat, op)
>
>
> — Theron
>
>
>
> On Mar 13, 2024, at 4:36 PM, Laurent Daverio  wrote:
>
> Thank you everybody, I'll try to set up a working example tomorrow.
>
> Actually you're right, my question was formulated incorrectly, it may not
> be a question of lambdas. Basically, I was trying to create a series of
> routes in a reasonably concise way, something like this : 2 types of
> objects (actes, constats), 2 operations (archive, unarchive), 2 variants
> (handle one object, or handle a list of ids):
>
> - /actes/{id}/archive
> - /actes/{id}/unarchive
> - /constats/{id}/archive
> - /constats/{id}/unarchive
> - /actes/-/archive_selection
> - /actes/-/unarchive_selection
> - /constats/-/archive_selection
> - /constats/-/unarchive_selection
>
> ```
>
>
> factories = {'actes':{'fact': acte_factory,
>   'rsrc': ActeResource},
>  'constats': {'fact': constat_factory,
>   'rsrc': ConstatResource}}
>
> functions = {'archive':   (_archive, _archive_multi),
>  'unarchive': (_unarchive, _unarchive_multi)}
>
> for cat in ('actes', 'constats'):
> for op in ('archive', 'unarchive'):
>
> route_name: str = f'api.{cat}.{op}'
>
> config.add_route(route_name, f'/{cat}/{{id}}/{op}', 
> factory=factories[cat]['fact'])
> config.add_view(functions[op][0], route_name=route_name, 
> request_method='GET', renderer='json')
>
> config.add_route(route_name + '_selection', 
> f'/{cat}/-/{op}_selection')
> config.add_view(
> lambda request: functions[op][1](request, factories[cat]['rsrc']),
> route_name=route_name + '_selection', request_method='POST', 
> renderer='json')
>
> ```
>
> The first 4 routes (those with "{id}" in them) worked fine, but last 4
> (those using lambdas) were all mapped to the same function
> (`_unarchive_multi`) in the end.
>
> In order to make them work, I had to unroll the loops and enumerate
> everything. Ugly :(
>
> ```
>
> config.add_route('api.actes.archive_selection', '/actes/-/archive_selection')
> config.add_route('api.constats.archive_selection', 
> '/constats/-/archive_selection')
> config.add_view(
> lambda request: _archive_multi(request, ActeResource),
> route_name='api.actes.archive_selection', request_method='POST', 
> renderer='json')
> config.add_view(
> lambda request: _archive_multi(request, ConstatResource),
> route_name='api.constats.archive_selection', request_method='POST', 
> renderer='json')
>
> config.add_route('api.actes.unarchive_selection', 
> '/actes/-/unarchive_selection')
> config.add_route('api.constats.unarchive_selection', 
> '/constats/-/unarchive_selection')
> config.add_view(
> lambda request: _unarchive_multi(request, ActeResource),
> route_name='api.actes.unarchive_selection', request_method='POST', 
> renderer='json')
> config.add_view(
> lambda request: _unarchive_multi(request, ConstatResource),
> route_name='api.constats.unarchive_selection', request_method='POST', 
> renderer='json')
>
> ```
>
> 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/CAB7cU6wqp1fSXJ_6ngOBqOw2RSSTxzjAZwGoyYsoDa58OdJkPg%40mail.gmail.com
> <https://groups.google.com/d/msgid/pylons-discuss/CAB7cU6wqp1fSXJ_6ngOBqOw2RSSTxzjAZwGoyYsoDa58OdJkPg%40mail.gmail.com?utm_medium=email_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 fr

[pylons-discuss] Test

2024-03-13 Thread Laurent Daverio


-- 
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/CAB7cU6zOiA45ByZvZCO1UHADp%3DZ%2BRmZtxx%3DGgeb9%3DjUE0zOYyw%40mail.gmail.com.


[pylons-discuss] Question about creating routes

2024-03-13 Thread Laurent Daverio
Hello list,

it seems that Google is allowing me to post on here again. A couple of
weeks ago, I was banned, both from emailing the list, AND from posting on
the web group 

I am trying to create a series of routes based on lambda functions,
something like:

```
config.add_route('doc1.delete_selection', '/doc1/-/delete_selection')
config.add_route('doc2.delete_selection', '/doc2/-/delete_selection')
config.add_view(
lambda request: _delete_multi(request, Doc1Resource),
route_name='doc1.delete_selection', request_method='POST',
renderer='json')
config.add_view(
lambda request: _delete_multi(request, Doc2Resource),
route_name='doc2.delete_selection', request_method='POST',
renderer='json')
```

(I also have `archive_selection` and `unarchive_selection` routes)

I'm under the impression that `config.add_view` can't take lambda functions
as arguments, as it tries to resolve their names ("maybe_dotted",
"maybe_resolve", etc.). All I can say it that the views seem to be calling
the wrong functions. This prevents me from using for loops and lambda for
generating the routes in a more concise way :/

Could anyone confirm if I'm correct?

Many thanks,

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/CAB7cU6y56gx3fDEGsdx3qFJKTVPOM5yN1maohu8tEESRnY2ygQ%40mail.gmail.com.


Re: [pylons-discuss] Question about creating routes

2024-03-13 Thread Laurent Daverio
Thank you everybody, I'll try to set up a working example tomorrow.

Actually you're right, my question was formulated incorrectly, it may not
be a question of lambdas. Basically, I was trying to create a series of
routes in a reasonably concise way, something like this : 2 types of
objects (actes, constats), 2 operations (archive, unarchive), 2 variants
(handle one object, or handle a list of ids):

- /actes/{id}/archive
- /actes/{id}/unarchive
- /constats/{id}/archive
- /constats/{id}/unarchive
- /actes/-/archive_selection
- /actes/-/unarchive_selection
- /constats/-/archive_selection
- /constats/-/unarchive_selection

```


factories = {'actes':{'fact': acte_factory,
  'rsrc': ActeResource},
 'constats': {'fact': constat_factory,
  'rsrc': ConstatResource}}

functions = {'archive':   (_archive, _archive_multi),
 'unarchive': (_unarchive, _unarchive_multi)}

for cat in ('actes', 'constats'):
for op in ('archive', 'unarchive'):

route_name: str = f'api.{cat}.{op}'

config.add_route(route_name, f'/{cat}/{{id}}/{op}',
factory=factories[cat]['fact'])
config.add_view(functions[op][0], route_name=route_name,
request_method='GET', renderer='json')

config.add_route(route_name + '_selection', f'/{cat}/-/{op}_selection')
config.add_view(
lambda request: functions[op][1](request, factories[cat]['rsrc']),
route_name=route_name + '_selection',
request_method='POST', renderer='json')

```

The first 4 routes (those with "{id}" in them) worked fine, but last 4
(those using lambdas) were all mapped to the same function
(`_unarchive_multi`) in the end.

In order to make them work, I had to unroll the loops and enumerate
everything. Ugly :(

```

config.add_route('api.actes.archive_selection', '/actes/-/archive_selection')
config.add_route('api.constats.archive_selection',
'/constats/-/archive_selection')
config.add_view(
lambda request: _archive_multi(request, ActeResource),
route_name='api.actes.archive_selection', request_method='POST',
renderer='json')
config.add_view(
lambda request: _archive_multi(request, ConstatResource),
route_name='api.constats.archive_selection',
request_method='POST', renderer='json')

config.add_route('api.actes.unarchive_selection',
'/actes/-/unarchive_selection')
config.add_route('api.constats.unarchive_selection',
'/constats/-/unarchive_selection')
config.add_view(
lambda request: _unarchive_multi(request, ActeResource),
route_name='api.actes.unarchive_selection', request_method='POST',
renderer='json')
config.add_view(
lambda request: _unarchive_multi(request, ConstatResource),
route_name='api.constats.unarchive_selection',
request_method='POST', renderer='json')

```

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/CAB7cU6wqp1fSXJ_6ngOBqOw2RSSTxzjAZwGoyYsoDa58OdJkPg%40mail.gmail.com.


  1   2   >