Re: [Zope-dev] Buildout - including per-user site-packages dir.

2013-06-26 Thread Alex Leach

Hi again,

I got the same error with zpasswd, so had to repeat the process with that  
section of buildout.cfg, too... Thought I'd explain the specifics, while I  
remember...



On Tue, 25 Jun 2013 19:44:48 +0100, Alex Leach albl...@york.ac.uk wrote:


The buildout configuration that seemed to fix this, was to add 'recipe =  
zc.recipe.egg:scripts' to my package's section, and  
'allowed-eggs-from-site-packages = peak' to the `[buildout]` section.


I found the documentation on these options, unsurprisingly on the  
zc.recipe.egg and z3c.recipe.scripts PyPi pages.  
('allowed-eggs-from-site-packages = peak' is not what I thought it was  
yesterday, so please ignore it).


I don't think I had edited the zpasswd section before yesterday, so it  
should have been exactly as it was, when initially generated by  
`grokproject`:


[zpasswd]
recipe = z3c.recipe.scripts
eggs =
my_package
zope.password
entry-points =
zpasswd=zope.password.zpasswd:main


I'm not entirely sure why zpasswd has to import every module in  
my_package, but it seems to try. So the above configuration causes zpasswd  
to fail, when a required package is installed into the user's  
site-packages folder.


It's worth mentioning, if you're unfamiliar with the user's site-packages  
folder, that it is supported by every Python build system I've tried:  
distutils, distutils2, numpy.distutils and setuptools. The following  
setup.py command, which works on all of these build systems, installs a  
package into the user's site-packages folder:-


$ python setup.py install --user



With the documentation in front of my, I added these options to zpasswd,  
but none of these add the user's site-packages folder to the search path:-


include-site-packages = true
exec-sitecustomize = true
relative-paths = true
extra-paths = ${buildout:directory}/eggs
interpreter = python-console


However, changing the recipe does:

recipe = zc.recipe.egg:script

So, my conclusion is that it's a feature / limitation / regression in  
z3c.recipe.scripts. I only say regression, because on the  
z3c.recipe.scripts PyPi page, I've just read:-


The script recipe installs eggs into a buildout eggs directory, exactly  
like zc.recipe.egg [...].


Well, not exactly... This is one difference. I'll continue to use  
zc.recipe.egg, as that works as desired in this situation, but it feels  
like I'm downgrading, which is never fun...


Hope that clarifies things, anyway.

Kind regards,
Alex
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Buildout - including per-user site-packages dir.

2013-06-25 Thread Alex Leach

Hi,

I'm trying to configure buildout.cfg so that paster looks for eggs in my
home folder's site packages directory, as per PEP 370[1].

In buildout.cfg, I have the line:

 include-site-packages = true

But packages I've installed in my home folder aren't found when my app is
run (with paster). Is there an extra buildout option, which will allow
searching of home folders?

Alternatively, I just noticed I have an empty sitecustomize.py file in
parts/etc/, but I have no 'sitecustomize.py.in' file in etc/. If I do add
a 'sitecustomize.py.in' file to etc/, what extra steps will be required,
for 'sitecustomize.py.in' to get copied over to 'parts/etc/'?

Cheers,
Alex

p.s. versions.cfg in use:
http://grok.zope.org/releaseinfo/1.5.5/versions.cfg


[1]: http://www.python.org/dev/peps/pep-0370/
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Buildout - including per-user site-packages dir.

2013-06-25 Thread Alex Leach

Hi,

I'm trying to configure buildout.cfg so that paster looks for eggs in my
home folder's site packages directory, as per PEP 370[1].

In buildout.cfg, I have the line:

 include-site-packages = true

But packages I've installed in my home folder aren't found when my app is
run (with paster). Is there an extra buildout option, which will allow
searching of home folders?

Alternatively, I just noticed I have an empty sitecustomize.py file in
parts/etc/, but I have no 'sitecustomize.py.in' file in etc/. If I do add
a 'sitecustomize.py.in' file to etc/, what extra steps will be required,
for 'sitecustomize.py.in' to get copied over to 'parts/etc/'?

Cheers,
Alex



[1]: http://www.python.org/dev/peps/pep-0370/

p.s. versions.cfg in use:
http://grok.zope.org/releaseinfo/1.5.5/versions.cfg
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Buildout - including per-user site-packages dir.

2013-06-25 Thread Alex Leach

Hi Johannes,

Thanks for the reply.

On Tue, 25 Jun 2013 19:13:15 +0100, Johannes Raggam raggam...@adm.at  
wrote:



AFAIK, you just need to create a .buildout directory in your home
directory, put the file default.cfg in it with this content:

[buildout]
eggs-directory = /home/YOURS/.buildout/eggs
download-cache = /home/YOURS/.buildout/downloads
extends-cache = /home/YOURS/.buildout/extends

and create the directories referenced here.


I saw that, but the packages I've installed into '~/.local/lib/python...'  
aren't (yet) on PyPi, so this isn't really what I need.


I've actually got it working now, without any new sitecustomize.py file..  
I think changing the package recipe in buildout.cfg fixed it, but it could  
have been something I did in configure.zcml.in, as I've been separating  
some things out into other namespace packages recently, and that was one  
file that needed tweaking.


The buildout configuration that seemed to fix this, was to add 'recipe =  
zc.recipe.egg:scripts' to my package's section, and  
'allowed-eggs-from-site-packages = peak' to the `[buildout]` section. That  
second one also helped resolve some dependency / conflict issues I was  
having with PasteScript - I also have it installed system-wide for some  
reason - and seems to reduce the need for duplicating some system  
packages. I like it :)



Thanks again,

Alex
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] WebSockets API

2012-11-28 Thread Alex Leach
Hi, just sending again to the list...

On Tuesday 27 Nov 2012 16:51:13 Andreas Jung wrote:
 Use the right tool for each problem. Zope is really not the right choice
 for implementing a websocket server. 

Why is it the wrong tool for the job? I read up a bit on asyncore, and see 
it's supposedly a single threaded server. Is that part of the problem?

The way I see it, zope's got its own web server and framework that handles 
HTTP requests; WebSockets initially connect over HTTP, before upgrading to a 
WebSocket connection. If the 'upgrade' request was recognised by zope, then 
couldn't it just forward the connection on to any WebSocket server? It 
wouldn't even need to do the handshake, but a compatible proxy would no doubt 
need to be implemented.


 There are dozens of better solutions for Python like
 
 http://autobahn.ws/

The dependencies of all other Python-based WebSocket implementations all 
require a completely different application stack. Twisted, which autobahn 
uses, looks very powerful for low-level networking and the such, but it's a 
beast and I've never used it before, in favour of making templated web apps 
with grok..

Also, wouldn't the front-end socket of autobahn conflict with any other 
running HTTP server? Sure, I could set it up on an alternative port, and use a 
front-end webserver to proxy requests appropriately, based on URL paths and 
patterns, like I do now with grok and Apache. But that adds another two 
complications, when it comes to initially setting up the server. Installation 
instructions for potential users would become even more off-putting than they 
already are.

The zope server already has a good system for URL parsing and dispatching. 
Would zope.proxy be any good at proxying WebSocket requests based on the URL?

 
 Don't try to misuse a framework for a purpose that it has not been
 invented for.

WebSockets hadn't been invented back then, but HTTP was always meant to be 
bidirectional. Get with the times :b  (jk)

So, I think I understand that zope might not be great for managing 
simultaneous bidirectional traffic, which is basically a requirement of a 
WebSocket server. Could it not be a good proxy either?

KR,
Alex
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] WebSockets API

2012-11-27 Thread Alex Leach
Hi,

Thanks for the reply.

On Tuesday 27 Nov 2012 09:04:11 Wolfgang Schnerring wrote:

 I'm not too familiar with WebSocket internals, but one thing that stuck
 with me is that you'll need to keep *lots* of open connections, which is
 only feasible with an eventloop-based server (which zope.server, for
 one, isn't).

Oh. That's an interesting point... I'm no expert either, but have seen them 
mentioned a lot recently, and started looking through the RFC the other day.

 
 Apart from that, I'm not sure what features remain, and where a proper
 home in the ZTK world would be.

As I use grok, I had a little dig in grok's dependencies, and thought that 
zope.publisher.ws could be an appropriate home. I branched zope.publisher from 
Launchpad / bazaar and started copying stuff over from zope.publisher.
[interfaces.]http. I thought that might be a nice way to start things going.

 
 At our company we've scheduled a project to integrate WebSockets into a
 large Zope3-based application for early next year, so we'll definitely will
 be doing *something* in that space -- we just don't know what, yet. ;)

Same here really. I just thought I'd try and start playing with WebSockets, as 
they sound quite fun, persistent and fast.

 What functionality did you have in mind that the ZTK might grow?

Good question. The main feature I thought ZTK would benefit from, is managing 
the handshake, and forwarding the connection to the relevant socket. I see no 
reason why the server endpoint needs to be a Zope application (could be a 
completely separate application, written in C++ for example), but Zope would 
still need to recognise the URL prefix (ws:// or wss://) and to connect the 
endpoints.

In the grok world, I thought a conf file might be an appropriate way of 
configuring the server socket port numbers and whether to start a listener on 
(or forwarder for) that port. As the initial handshake is done over HTTP, Zope 
would mainly need a way of recognising the WebSocket request and to delegate 
it appropriately.

In terms of public methods for a developer, this would be optional on whether 
Zope / grok manages the endpoint or not. If it did have control of the server-
side WebSocket (e.g. localhost:), it would need a write method and methods 
for parsing WebSocket frames for Content-Length etc (see Section 5.2 of 
RFC6455), and to return only the payload data.

I haven't any experience with bit-wise operations, so could do with some help 
with parsing that first byte of the frame.

Finally, I think testing will be a bit of b*tch, as Zope would also need a 
WebSocket client to perform the testing...

Hope that helps.
Cheers,
Alex



 
 Wolfgang
-- 
Alex Leach BSc. MRes.
Department of Biology
University of York
York YO10 5DD
United Kingdom
www: http://bioltfws1.york.ac.uk/~albl500
EMAIL DISCLAIMER: http://www.york.ac.uk/docs/disclaimer/email.htm___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] WebSockets API

2012-11-27 Thread Alex Leach
On Tuesday 27 Nov 2012 10:07:03 Adam GROSZER wrote:
 
 Some investigations and trials showed about half a year ago that a
 Autobahn + Twisted + pyramid combination worked.
 
 YMMV

Thanks. That is a completely different and separate application stack cf. the 
standard grok dependencies. I've written quite a lot of Grok-specific code 
already, and going down that route would seem to add a lot to my list of 
dependencies... Something which is already getting quite out of hand.

Cheers,
Alex

___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] WebSockets API

2012-11-27 Thread Alex Leach
On Tuesday 27 Nov 2012 07:04:43 Jim Fulton wrote:
 Actually, it is. zope.server is based on asyncore.
 
 Having said that, my impression is that web sockets is largely (or
 completely) orthogonal to WSGI and the HTTP-based publishing
 infrastructure.

From the RFC:

   The WebSocket Protocol attempts to address the
   goals of existing bidirectional HTTP technologies in the context of
   the existing HTTP infrastructure; as such, it is designed to work
   over HTTP ports 80 and 443 as well as to support HTTP proxies and
   intermediaries, even if this implies some complexity specific to the
   current environment.  However, the design does not limit WebSocket to
   HTTP, and future implementations could use a simpler handshake over a
   dedicated port without reinventing the entire protocol.  This last
   point is important because the traffic patterns of interactive
   messaging do not closely match standard HTTP traffic and can induce
   unusual loads on some components.

 
 ZTK is only relevant to the extent that it's a bag of useful libraries
 maintained
 by the Zope community.

It is a bag of useful libraries :) Is there anything that would ease the 
development of a WebSockets server, though? I would have thought there is, and 
that it would be at least possible, if not simple, to implement from existing 
base classes...

KR,
Alex
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] WebSockets API

2012-11-25 Thread Alex Leach
Hi,

I was wondering if anyone has implemented a WebSockets server API using the 
zope toolkit? I've just submitted a blueprint on Launchpad 
(https://blueprints.launchpad.net/zopetoolkit-project/+spec/websockets-api), 
but thought it might be quicker and easier to discuss how one could do this 
here.

In theory (and practice, e.g. http://popdevelop.com/2010/03/a-minimal-python-
websocket-server/), only a very small amount of code is needed to deploy a 
secure WebSockets server. I'd be happy to have a go at doing this myself, but 
thought it would be better to implement upstream, within one of the zope 
packages.

I've been developing with grok, so I'm not too familiar with the internals of 
zope publishing, though. Please could someone point me in the right direction, 
with regards to modules and base classes responsible for parsing requests and 
performing handshakes?

Cheers,
Alex

___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] zope.formlib - Overriding default widget attributes

2012-04-12 Thread Alex Leach
Dear Zope Devs,

I'm trying to remove a couple of default attributes from the rendered version 
of the schema.Text widget, namely cols and rows.

I tried overriding the widgets attributes with None, which didn't work. I then 
found in renderTag, in zope.formlib-4.0.6-py2.7.egg/zope/formlib/widget.py:603 
that if a value of one of the keyword arguments (**kw) is set to None, then 
the value is set to the key, and a deprecation warning is issued. In my case, 
this therefore produces HTML with attributes like cols=cols, and 
rows=rows. I don't like that at all, as all my styles are defined in CSS and 
jQuery, and this overrides them!

So, please can this be replaced with a `continue` flow statement instead??

Suggested patch:-

zope.formlib-4.0.6-py2.7.egg/formlib diff widget.py widget.py.orig 
600c600,602
 for key, value in sorted(kw.items()):
---
 items = kw.items()
 items.sort()
 for key, value in items:
602c604,611
 continue
---
 warnings.warn(
 None was passed for attribute %r.  Passing None 
 as attribute values to renderTag is deprecated. 
 Passing None as an attribute value will be disallowed 
 starting in Zope 3.3.
 % key,
 DeprecationWarning, stacklevel=2)
 value = key

In fact, I'd also get rid of the `if kw:` line, as it seems unnecessary...

Cheers,
Alex

ps. Sorry if this is a duplicate. I think my original message got rejected as 
I hadn't subscribed...

-- 
Alex Leach
Department of Biology
University of York
York YO10 5DD
United Kingdom
www: http://bioltfws1.york.ac.uk/~albl500
EMAIL DISCLAIMER: http://www.york.ac.uk/docs/disclaimer/email.htm
-- 
Alex Leach BSc. MRes.
Department of Biology
University of York
York YO10 5DD
United Kingdom
www: http://bioltfws1.york.ac.uk/~albl500
EMAIL DISCLAIMER: http://www.york.ac.uk/docs/disclaimer/email.htm
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )