Re: Pylons/TG sprint

2008-04-08 Thread Mike Orr

On Mon, Apr 7, 2008 at 7:12 PM, Mark Ramm [EMAIL PROTECTED] wrote:
  We'll be working to document FormEncode, clean up various

I've gotten partway on this, interviewing Ian about the questions
people have and trying to write something from the perspective of a
web framework user, but I got bogged down in the wording and examples.
 My notes are here. If anyone wants to help work on this let me know.

http://wiki.pylonshq.com/display/pylonscookbook/The+other+FormEncode+manual+%28UNFINISHED%29


-- 
Mike Orr [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



odd nosetests error

2008-04-08 Thread Dunk Fordyce

hello,

Im trying to write some unittests however I get this strange error
when running them:

==
ERROR: Failure: AttributeError ('module' object has no attribute 'helpers')
--
Traceback (most recent call last):
  File /usr/lib/python2.5/site-packages/nose-0.10.1-py2.5.egg/nose/loader.py,
line 364, in loadTestsFromName
addr.filename, addr.module)
  File 
/usr/lib/python2.5/site-packages/nose-0.10.1-py2.5.egg/nose/importer.py,
line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
  File 
/usr/lib/python2.5/site-packages/nose-0.10.1-py2.5.egg/nose/importer.py,
line 84, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
  File myproj/tests/__init__.py, line 33, in module
cmd.run([test_file])
  File 
/usr/lib/python2.5/site-packages/PasteScript-1.6.2-py2.5.egg/paste/script/appinstall.py,
line 68, in run
return super(AbstractInstallCommand, self).run(new_args)
  File 
/usr/lib/python2.5/site-packages/PasteScript-1.6.2-py2.5.egg/paste/script/command.py,
line 213, in run
result = self.command()
  File 
/usr/lib/python2.5/site-packages/PasteScript-1.6.2-py2.5.egg/paste/script/appinstall.py,
line 456, in command
self, config_file, section, self.sysconfig_install_vars(installer))
  File 
/usr/lib/python2.5/site-packages/PasteScript-1.6.2-py2.5.egg/paste/script/appinstall.py,
line 600, in setup_config
mod.setup_config(command, filename, section, vars)
  File /home/dunk/projects/myproj/myproj/websetup.py, line 101, in
setup_config
load_environment(conf.global_conf, conf.local_conf)
  File myproj/config/environment.py, line 33, in load_environment
config['pylons.h'] = myproj.lib.helpers
AttributeError: 'module' object has no attribute 'helpers'

I cant see how this is possible as its already imported the module
fine at the top of environment.py

Any clues?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Internal Errors due to WebError failures on source encoding

2008-04-08 Thread Marcin Kasperski


(tested using pylons-dev and WebError-0.8a)

I have some error in my sources. Unfortunately WebError crashes so I
do not see this error but WebError failure instead. And it crashes
because it .encode-s strings using 'ascii'.

I tried replacing all 'ascii' with 'utf-8' in
weberror/exceptions/formatter.py and it seems to resolve the issue
(true error was properly shown in pylons debugging page, in this case
it was lacking import)

The main question: why 'ascii'? Plus ... what about patching WebError
just like I did?

Details:

{ in browser - in spite of debug mode active }

Internal Server Error

{ paster reports }

Exception happened during processing of request from ('127.0.0.1', 49524)
Traceback (most recent call last):
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/Paste-1.6-py2.5.egg/paste/httpserver.py,
 line 1053, in process_request_in_thread
self.finish_request(request, client_address)
  File SocketServer.py, line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
  File SocketServer.py, line 522, in __init__
self.handle()
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/Paste-1.6-py2.5.egg/paste/httpserver.py,
 line 432, in handle
BaseHTTPRequestHandler.handle(self)
  File BaseHTTPServer.py, line 316, in handle
self.handle_one_request()
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/Paste-1.6-py2.5.egg/paste/httpserver.py,
 line 427, in handle_one_request
self.wsgi_execute()
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/Paste-1.6-py2.5.egg/paste/httpserver.py,
 line 287, in wsgi_execute
self.wsgi_start_response)
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/Paste-1.6-py2.5.egg/paste/cascade.py,
 line 121, in __call__
return self.apps[-1](environ, start_response)
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/Paste-1.6-py2.5.egg/paste/registry.py,
 line 334, in __call__
app_iter = self.application(environ, start_response)
  File /home/marcink/Aktualne/IAS20/pylons-dev/pylons/middleware.py, line 
130, in __call__
resp = orig_resp = req.get_response(self.app, catch_exc_info=True)
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/WebOb-0.9-py2.5.egg/webob/__init__.py,
 line 1212, in get_response
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/WebOb-0.9-py2.5.egg/webob/__init__.py,
 line 1184, in call_application
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/WebError-0.8a-py2.5.egg/weberror/evalexception/middleware.py,
 line 226, in __call__
return self.respond(environ, start_response)
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/WebError-0.8a-py2.5.egg/weberror/evalexception/middleware.py,
 line 407, in respond
return debug_info.content()
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/WebError-0.8a-py2.5.egg/weberror/evalexception/middleware.py,
 line 461, in content
traceback_body, extra_data = format_eval_html(self.exc_data, 
self.base_path, self.counter)
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/WebError-0.8a-py2.5.egg/weberror/evalexception/middleware.py,
 line 581, in format_eval_html
show_extra_data=False)[0]
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/WebError-0.8a-py2.5.egg/weberror/exceptions/formatter.py,
 line 469, in format_xml
return XMLFormatter(**ops).format_collected_data(exc_data)
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/WebError-0.8a-py2.5.egg/weberror/exceptions/formatter.py,
 line 394, in format_collected_data
self.format_long_source(source, long_source, newdoc, xml_frame)
  File 
/home/marcink/MYENV/lib/python2.5/site-packages/WebError-0.8a-py2.5.egg/weberror/exceptions/formatter.py,
 line 423, in format_long_source
source = source.encode('ascii', 'xmlcharrefreplace')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 50: 
ordinal not in range(128)

PS I have comments and docstrings in Polish in my (utf-8 encoded) sources.


-- 
--
| Marcin Kasperski   |  In any large change, 1/3 will think it is
| http://mekk.waw.pl | great, 1/3 will think it is stupid, and 1/3
||   will wait (Reed)
--


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Creating a opensource social network in pylons

2008-04-08 Thread openartist

Hello,
I'm working on a social network and I'm interested in pylons as a
platform for development.  However I've found that more robust
projects are currently built in RoR and PHP that would serve as a
foundation for the project I'm working on.  The social site is being
designed to allow for open collaboration across projects and amongst
designers and creatives of various sorts.  But it appears that there
aren't the proper pieces to tie such a network together in Pylons (if
I paid a developer to do the heavy lifting).

For that reason I'm looking for help from the community to help me
identify projects that I may have overlooked or would be willing to
help develop if I get the ball rolling on this project and even hire a
developer to do some initial work.

Features needed are:

Basic CMS (Blogging and publishing)
Forums
Project Management
Social Networking (member profiles, friends)
[real] Email and messaging
File uploading/hosting
Wikis
galleries/portfolios for members and projects that support images and
video

If you think I should just go with RoR that already has enough
projects like lovdbyless.com to build a robust app, or if I should
really go for pylons then I'm open to comments and ideas.

The project is going to be opensource (of course).

Note: I'm a designer with little programming experience and I'm trying
to string together this project as a service to designers and
creatives of all types (engineering, architecture, industrial design,
film) for the benefit of all of us.  I'm even investing my own money
into it not expecting to get anything back.  I just want to make the
most dynamic and appropriately featured environment for project
collaboration (commercial and non-commercial) across a social network.

Thanks for reading.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Controller Newbie Question

2008-04-08 Thread dave

Hi,
I'm just getting started with pylons and I have a question.  Here's
the basic setup.

1. My controller index function sets some class variables.  (eg.
self.myvar )
2. It then renders a template.
3. The template html loads some javascript in the standard html way
( eg. script type=text/javascript src=my javascript.js/
script )
4. The page is loaded and all is happy.
5. On a certain action, the javascript get's called and I'd like to
point back to my controller object.. calling a different function.
But it seems that it creates a new instance of the class because the
'self.myvar' no longer exists.

.
Any help greatly appreciated.
Here's a bit different way of explaining it

class WbController(BaseController):
def index(self):
# get some info from the urlr
self.myvar = some info here
# pass that info to the template.
return render('/foo.mako')

def foo(self):
# foo get's called by the javascript that is loaded in the
template..
# but self.myvar doesn't exist !!!??



-- javascript snip-

var url = wb/foo;
xmlhttpPut.onreadystatechange=empty;
xmlhttpPut.open(GET,url,true);
xmlhttpPut.send(null);


many thanks,
david



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Controller Newbie Question

2008-04-08 Thread Christoph Haas

On Tue, Apr 08, 2008 at 09:26:16AM -0700, dave wrote:
 1. My controller index function sets some class variables.  (eg.
 self.myvar )
 2. It then renders a template.
 3. The template html loads some javascript in the standard html way
 ( eg. script type=text/javascript src=my javascript.js/
 script )
 4. The page is loaded and all is happy.
 5. On a certain action, the javascript get's called and I'd like to
 point back to my controller object.. calling a different function.
 But it seems that it creates a new instance of the class because the
 'self.myvar' no longer exists.
 
 .
 Any help greatly appreciated.
 Here's a bit different way of explaining it
 
 class WbController(BaseController):
 def index(self):
   # get some info from the urlr
   self.myvar = some info here
   # pass that info to the template.
   return render('/foo.mako')
 
 def foo(self):
   # foo get's called by the javascript that is loaded in the
 template..
   # but self.myvar doesn't exist !!!??

Your class variables are not saved between HTTP requests. If you want
data to persist you either need to save it in into a database (hint:
model) or into the session (cookie based session).

Cheers
 Christoph
-- 
[EMAIL PROTECTED]  www.workaround.org   JID: [EMAIL PROTECTED]
gpg key: 79CC6586 fingerprint: 9B26F48E6F2B0A3F7E33E6B7095E77C579CC6586

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Controller Newbie Question

2008-04-08 Thread Raoul Snyman

On Tue, Apr 8, 2008 at 6:39 PM, Christoph Haas [EMAIL PROTECTED] wrote:
  Your class variables are not saved between HTTP requests. If you want
  data to persist you either need to save it in into a database (hint:
  model) or into the session (cookie based session).

Just to further explain what Christoph has said, since I had the same
misconception as Dave when I started writing web apps...

In the traditional software model, once an object is created within
the application, it remains there until either it is destroyed or the
application is closed. In Web Apps, this is not the case. In essence,
each and every page that you go to is a single execution of your
application... from startup to shutdown. This means that while the
page is loading your object is valid, but as soon as the page has
finished loading, your object has been destroyed. So any variables you
set in your controller are not available on the next page or function
execution.

As Christoph also said, the way to make data persist between different
pages is either via database storage, or via the session list object
in your controller. In Dave's case, he most probably wants to use the
session list object.

Here's an example:

if 'message' not in session:
session['message'] = 'This is a message'
session.save()


-- 
Raoul Snyman
B.Tech Information Technology (Software Engineering)
E-Mail: [EMAIL PROTECTED]
Web: http://www.saturnlaboratories.co.za/
Blog: http://blog.saturnlaboratories.co.za/
Mobile: 082 550 3754
Registered Linux User #333298 (http://counter.li.org)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Controller Newbie Question

2008-04-08 Thread Mike Orr

On Tue, Apr 8, 2008 at 10:16 AM, Raoul Snyman [EMAIL PROTECTED] wrote:

  On Tue, Apr 8, 2008 at 6:39 PM, Christoph Haas [EMAIL PROTECTED] wrote:
Your class variables are not saved between HTTP requests. If you want
data to persist you either need to save it in into a database (hint:
model) or into the session (cookie based session).

  Just to further explain what Christoph has said, since I had the same
  misconception as Dave when I started writing web apps...

  In the traditional software model, once an object is created within
  the application, it remains there until either it is destroyed or the
  application is closed. In Web Apps, this is not the case. In essence,
  each and every page that you go to is a single execution of your
  application... from startup to shutdown. This means that while the
  page is loading your object is valid, but as soon as the page has
  finished loading, your object has been destroyed. So any variables you
  set in your controller are not available on the next page or function
  execution.

Well, yes, but not precisely.  A web app has several kinds of state
(scopes).  Request state lasts for the duration of the request.
Pylons instantiates a controller for every request; another framework
might use the same instance for every request.  So in Pylons the
'request' object and controller instance are request scope.

Session scope ties together several requests by the same user running
the same browser.  In Pylons the session object has session scope,
so anything you put into it is visible in later requests within the
session.  Normally the session ends when the user quits the browser,
but you can make it longer or shorter by setting the expiration time
of the session cookie, or by deleting the session data on disk (in
myapp/data/sessions).  So session scope sounds like what  you want.

Persistent scope lasts forever, or at least until you delete it or the
hard disk keels over and dies.  In Pylons the model -- tied to a SQL
database or such -- is persistent.  But here you must think about
whether the data should be visible to everybody, or to just the user
who created it.  To keep it private to the user, you'll have to put a
username field in the record, and set up authentication to find out
who the user is.  (You could also keep session data in the database,
though there's no reason to.  But if you wanted to, you'd key it by
session ID, which is session.id in Pylons.)

There are also several global scopes, which are shared by all requests
and users.  Pylons' g variable is one.  So is any module you import,
or any controller class, or any Python global.  Some of these are
shared between threads, while others may be thread local.  Ask on the
list if you're not sure if you're modifying something in a thread-safe
manner.  Global data disappears when the Pylons application quits.

Your original message and replies said class variables.  Those would
be attributes attached to the controller class, not self variables
attached to the instance.  ('MyController.foo = bar' as opposed to
'self.foo = bar'.)  Class attributes are global scope; instance
attributes are request scope.

-- 
Mike Orr [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Session handling

2008-04-08 Thread Dunk Fordyce

Just as a vote of confidence, I pondered the same today two things today!
Why are there no official docs for session in the pylons docs ( nor
indeed the cookbook) and why not call session.save() in a  try/finally
in your base controller __call__() (altho that would it would probably
be more like if session['user']: session.save() to avoid saving every
random user)

On Tue, Apr 8, 2008 at 9:33 PM, Mike Orr [EMAIL PROTECTED] wrote:

  Session handling seems to be missing in the Pylons Official Docs.  My
  particular question is, when should session.save() be called?  For
  instance, I have an action that calls a few utility methods that all
  modify the session, and a generic Flash class that also modifies the
  session.  Should I call session.save() in all of them, or is that
  inefficient?  One issue is that the user of the Flash class shouldn't
  have to know whether/how the session is being used.  Should I just
  call session.save() once at the end of the action?  Or in the base
  controller?

  --
  Mike Orr [EMAIL PROTECTED]

  


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Session handling

2008-04-08 Thread Mike Orr

Session handling seems to be missing in the Pylons Official Docs.  My
particular question is, when should session.save() be called?  For
instance, I have an action that calls a few utility methods that all
modify the session, and a generic Flash class that also modifies the
session.  Should I call session.save() in all of them, or is that
inefficient?  One issue is that the user of the Flash class shouldn't
have to know whether/how the session is being used.  Should I just
call session.save() once at the end of the action?  Or in the base
controller?

-- 
Mike Orr [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: pylons.g and threads

2008-04-08 Thread Ben Bangert

On Apr 8, 2008, at 2:19 PM, Mike Orr wrote:


request.environ is request scope, so it wouldn't work for stuff that
needs to persist between requests.  Like a connection to a Durus
daemon, which has to be thread local.


Attach a thread-local object to 'g' then? That's what the Mako  
templateloader does in 0.9.7, and thats what we've been doing with the  
SQLAlchemy engine.


Cheers,
Ben

smime.p7s
Description: S/MIME cryptographic signature


Re: pylons.g and threads

2008-04-08 Thread Mike Orr

On Tue, Apr 8, 2008 at 2:33 PM, Ben Bangert [EMAIL PROTECTED] wrote:
 On Apr 8, 2008, at 2:19 PM, Mike Orr wrote:


  request.environ is request scope, so it wouldn't work for stuff that
  needs to persist between requests.  Like a connection to a Durus
  daemon, which has to be thread local.
 

  Attach a thread-local object to 'g' then? That's what the Mako
 templateloader does in 0.9.7, and thats what we've been doing with the
 SQLAlchemy engine.

That's not what we've been doing with the SQLAlchemy engine.  The
current standard model puts it model.meta (a module).  The previous
model (SQLAlchemy for people in a hurry) put it directly under
pylons.g without a threadlocal.


-- 
Mike Orr [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: pylons.g and threads

2008-04-08 Thread Ben Bangert

On Apr 8, 2008, at 2:51 PM, Mike Orr wrote:


That's not what we've been doing with the SQLAlchemy engine.  The
current standard model puts it model.meta (a module).  The previous
model (SQLAlchemy for people in a hurry) put it directly under
pylons.g without a threadlocal.


Ah right. I was thinking of the old way. Anyways, attaching a thread  
local to the 'g' will work.


- Ben

smime.p7s
Description: S/MIME cryptographic signature


Re: Internal Errors due to WebError failures on source encoding

2008-04-08 Thread Philip Jenvey


On Apr 8, 2008, at 3:41 AM, Marcin Kasperski wrote:



 (tested using pylons-dev and WebError-0.8a)

 I have some error in my sources. Unfortunately WebError crashes so I
 do not see this error but WebError failure instead. And it crashes
 because it .encode-s strings using 'ascii'.

 I tried replacing all 'ascii' with 'utf-8' in
 weberror/exceptions/formatter.py and it seems to resolve the issue
 (true error was properly shown in pylons debugging page, in this case
 it was lacking import)

 The main question: why 'ascii'? Plus ... what about patching WebError
 just like I did?


There's a ticket logged about this here:

http://pylonshq.com/project/pylonshq/ticket/406

Ideally this would be taken care of before the 0.9.7 release. Is  
there any similar issues with the EvalException used in 0.9.6.1 I  
wonder, or is this new due to the new XML generation?

The problem isn't just as easy as using utf-8, unfortunately not  
everybody's source encoding is utf-8. Basically WebError needs to  
determine the actual source encoding used (there's a patch in the  
ticket for that), and use that to generate a displayable version.

--
Philip Jenvey



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: Internal Errors due to WebError failures on source encoding

2008-04-08 Thread Ben Bangert

On Apr 8, 2008, at 4:53 PM, Philip Jenvey wrote:


There's a ticket logged about this here:

http://pylonshq.com/project/pylonshq/ticket/406

Ideally this would be taken care of before the 0.9.7 release. Is
there any similar issues with the EvalException used in 0.9.6.1 I
wonder, or is this new due to the new XML generation?

The problem isn't just as easy as using utf-8, unfortunately not
everybody's source encoding is utf-8. Basically WebError needs to
determine the actual source encoding used (there's a patch in the
ticket for that), and use that to generate a displayable version.


If this is only occurring in the XML output, I'll remove that option  
for now until I have more time to perfect it. Or does the attached  
patch to the ticket resolve it?


Cheers,
Ben

smime.p7s
Description: S/MIME cryptographic signature