RE: newb: Correct way to set a SQLalchemy 'relation'

2008-11-20 Thread Jules Stevenson

Hi Dalius,

Thanks for getting back to me.

 Never seen it done this way. Even if it works it does not look correct
 way. It looks hard to understand and in some sense it is unpythonic -
 other developers will have hard time to understand it. Just look at
 pylons tutorials how it is done.

I have checked the docs, and I can't find a specific example where a controller 
is explicitly trying to set a class attribute that is a foreign key:

mapper(ArkClient, clients_table, properties={
'contacts':relation(ArkContact, backref='client', cascade=all, delete),
'projects':relation(ArkProject, backref=backref('client'), cascade=all, 
delete, delete-orphan)
})

Ie. Setting ArkClient.contacts or ArkCLient.projects

As before, currently doing the following:

contact.client=Session.query(ArkClient).filter(ArkClient.client=='clientName').first()

The 'clientName' string is passed through via request.POST. If anyone has links 
to examples of how this is done better that would be much appreciated.

Many thanks,

Jules




--~--~-~--~~~---~--~~
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: newb: Correct way to set a SQLalchemy 'relation'

2008-11-20 Thread Dalius Dobravolskas

 contact.client=Session.query(ArkClient).filter(ArkClient.client=='clientName').first()

I'd expect something like:
contact.client=Session.query(ArkClient).filter(ArkClient.client.name=='clientName').first()

I just find it very strange how you use SQLAlchemy: Table, class and
mapper mixed into one class (ArkContact). While ArkClient mapper seems
to be correct. As well it looks very strange that ArkClient has
backref and you define client in ArkContact again and in addition with
backref. It is enough to define this relation in one mapper.

-- 
Dalius
http://blog.sandbox.lt

--~--~-~--~~~---~--~~
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: newb: Correct way to set a SQLalchemy 'relation'

2008-11-20 Thread Jules Stevenson

Hey Dalius,

 contact.client=Session.query(ArkClient).filter(ArkClient.client=='clien
 tName').first()
 
 I'd expect something like:
 contact.client=Session.query(ArkClient).filter(ArkClient.client.name=='
 clientName').first()
 
 I just find it very strange how you use SQLAlchemy: Table, class and
 mapper mixed into one class (ArkContact). While ArkClient mapper seems
 to be correct. As well it looks very strange that ArkClient has
 backref and you define client in ArkContact again and in addition with
 backref. It is enough to define this relation in one mapper.

Yes, apologies - I've changed from declarative to the more 'traditional' 
[separate table / class / mapper] route since my first post, I should have 
clarified that. 


--~--~-~--~~~---~--~~
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: Beaker 1.1 Release

2008-11-20 Thread Philip Jenvey


On Nov 19, 2008, at 1:47 PM, Michael Bayer wrote:


 also your usage is more succinct via:

 response = cache.get_value(request, expiretime=x, createfunc=lambda:
 func(self, *arg, **kw))

Mike, I've attempted a quick and dirty auto upgrade patch for the  
Beaker 1.0.x format to 1.1, take a look:

http://pylonshq.com/pasties/1003

--
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: Javascript library

2008-11-20 Thread Iain Duncan

On Mon, 2008-11-10 at 01:21 -0800, cropr wrote:
 
 It is difficult to choose the right one.
 
 I've tried extjs, jquery and yui for my webproject.  Here are my
 findings:
  - I started testing with extjs.  Extjs is extremely bloated and
 because of that extjs is slow to load and to use and difficult to
 debug.  On my development machine (a 3 year old 1.6 Ghz single core PC
 with 512 MB ram)  it takes 15 seconds to load a full extjs
 application, serving only local files.   Could be fine in an intranet
 environment with unlimited bandwidth and  you are sure that all client
 PCs are fast.  Is basically unusable for Internet websites
  - after that I tested jQuery, fast and concise but does not have UI
 widgets on its own.  If you don't need widgets , this is the very good
 choice.  The UI addon is a less quality than jquery, without a good
 rich text editor.  So I looked around for more

You might like WYMISWYG, which uses jquery. I've found this ideal for
situations where a rich text editor that integrates well is preferable
over a WYSIWYG that is a pain to hack on. (TinyMCE)

I find jQuery's find stuff do stuff model really good for writing super
concise ajax+dom manipulation. 

Iain



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Testing tool to simply form session interaction

2008-11-20 Thread Randy Syring

I would like to be able to test my web applications from the
perspective of an actual user.  Are there any tools that would let me
do something like:

c = Client(myapp)
r = c.get(/user/login)
r.checkfor('User Login')
r.checkfor('enter credentials')
r.set('username', 'foo')
r.set('password', 'bar')
r2 = c.submit(r)
r2.checkfor('login succesful')
r = c.get(/uploadfile) # at this point, the user's session from the
above login would be in effect
r = c.setfile('toupload', open('myfile.txt'))
r2 = c.submit(r)
r2.checkfor('file uploaded')
etc.

Obviously, the API would vary, but I hope you get my drift.



--~--~-~--~~~---~--~~
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: Testing tool to simply form session interaction

2008-11-20 Thread Jeremy Gransden
Maybe twill is what you are looking for.

http://twill.idyll.org/

On Thu, Nov 20, 2008 at 6:15 PM, Randy Syring [EMAIL PROTECTED] wrote:


 I would like to be able to test my web applications from the
 perspective of an actual user.  Are there any tools that would let me
 do something like:

 c = Client(myapp)
 r = c.get(/user/login)
 r.checkfor('User Login')
 r.checkfor('enter credentials')
 r.set('username', 'foo')
 r.set('password', 'bar')
 r2 = c.submit(r)
 r2.checkfor('login succesful')
 r = c.get(/uploadfile) # at this point, the user's session from the
 above login would be in effect
 r = c.setfile('toupload', open('myfile.txt'))
 r2 = c.submit(r)
 r2.checkfor('file uploaded')
 etc.

 Obviously, the API would vary, but I hope you get my drift.



 


--~--~-~--~~~---~--~~
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: Testing tool to simply form session interaction

2008-11-20 Thread Florent Aide

On Fri, Nov 21, 2008 at 12:15 AM, Randy Syring [EMAIL PROTECTED] wrote:

 I would like to be able to test my web applications from the
 perspective of an actual user.  Are there any tools that would let me
 do something like:

 c = Client(myapp)
 r = c.get(/user/login)
 r.checkfor('User Login')
 r.checkfor('enter credentials')

webtest is nearly that and is quite easy and fun to use.

pypi page: http://pypi.python.org/pypi/WebTest
docs: http://pythonpaste.org/webtest/

Florent

--~--~-~--~~~---~--~~
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: Testing tool to simply form session interaction

2008-11-20 Thread Mike Orr

On Thu, Nov 20, 2008 at 3:59 PM, Florent Aide [EMAIL PROTECTED] wrote:

 On Fri, Nov 21, 2008 at 12:15 AM, Randy Syring [EMAIL PROTECTED] wrote:

 I would like to be able to test my web applications from the
 perspective of an actual user.  Are there any tools that would let me
 do something like:

 c = Client(myapp)
 r = c.get(/user/login)
 r.checkfor('User Login')
 r.checkfor('enter credentials')

 webtest is nearly that and is quite easy and fun to use.

 pypi page: http://pypi.python.org/pypi/WebTest
 docs: http://pythonpaste.org/webtest/

Isn't this the same as the test framework built into Pylons?


-- 
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: Testing tool to simply form session interaction

2008-11-20 Thread Ian Bicking

Randy Syring wrote:
 I would like to be able to test my web applications from the
 perspective of an actual user.  Are there any tools that would let me
 do something like:
 
 c = Client(myapp)

app = TestApp(myapp)

 r = c.get(/user/login)

r = app.get('/user/login')

 r.checkfor('User Login')

r.mustcontain('User Login')

 r.checkfor('enter credentials')

r.mustcontain('enter credentials')

 r.set('username', 'foo')

r.form['username'] = 'foo'

 r.set('password', 'bar')

r.form['password'] = 'bar'

 r2 = c.submit(r)

r2 = r.form.submit()


And... I don't feel like translating the rest, but it's all just 
different names for the stuff in WebTest, which is what Pylons sets up 
for its tests by default.

 r2.checkfor('login succesful')
 r = c.get(/uploadfile) # at this point, the user's session from the
 above login would be in effect
 r = c.setfile('toupload', open('myfile.txt'))
 r2 = c.submit(r)
 r2.checkfor('file uploaded')
 etc.
 
 Obviously, the API would vary, but I hope you get my drift.


-- 
Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.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: Beaker 1.1 Release

2008-11-20 Thread joeformd

Thanks Mike - that all works great!
--~--~-~--~~~---~--~~
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: Testing tool to simply form session interaction

2008-11-20 Thread Randy Syring

Thanks to everyone who posted.  It was right there all along!  I will
check it out.

On Nov 20, 7:10 pm, Ian Bicking [EMAIL PROTECTED] wrote:
 Randy Syring wrote:
  I would like to be able to test my web applications from the
  perspective of an actual user.  Are there any tools that would let me
  do something like:

  c = Client(myapp)

 app = TestApp(myapp)

  r = c.get(/user/login)

 r = app.get('/user/login')

  r.checkfor('User Login')

 r.mustcontain('User Login')

  r.checkfor('enter credentials')

 r.mustcontain('enter credentials')

  r.set('username', 'foo')

 r.form['username'] = 'foo'

  r.set('password', 'bar')

 r.form['password'] = 'bar'

  r2 = c.submit(r)

 r2 = r.form.submit()

 And... I don't feel like translating the rest, but it's all just
 different names for the stuff in WebTest, which is what Pylons sets up
 for its tests by default.

  r2.checkfor('login succesful')
  r = c.get(/uploadfile) # at this point, the user's session from the
  above login would be in effect
  r = c.setfile('toupload', open('myfile.txt'))
  r2 = c.submit(r)
  r2.checkfor('file uploaded')
  etc.

  Obviously, the API would vary, but I hope you get my drift.

 --
 Ian Bicking : [EMAIL PROTECTED] :http://blog.ianbicking.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: Testing tool to simply form session interaction

2008-11-20 Thread Dalius Dobravolskas

On Fri, Nov 21, 2008 at 1:15 AM, Randy Syring [EMAIL PROTECTED] wrote:

 I would like to be able to test my web applications from the
 perspective of an actual user.  Are there any tools that would let me
 do something like:

 c = Client(myapp)
 r = c.get(/user/login)
 r.checkfor('User Login')
 r.checkfor('enter credentials')
 r.set('username', 'foo')
 r.set('password', 'bar')
 r2 = c.submit(r)
 r2.checkfor('login succesful')
 r = c.get(/uploadfile) # at this point, the user's session from the
 above login would be in effect
 r = c.setfile('toupload', open('myfile.txt'))
 r2 = c.submit(r)
 r2.checkfor('file uploaded')
 etc.
It looks like you are reinventing AuthKit :-) That's OK.

Just in case you might find my authform-middleware usefull. It
contains some unit-tests too (if you will not use middleware
unit-tests might help):
http://hg.sandbox.lt/authform-middleware/file/36d42b4219bf/tests/test.py

You can check authorize-middleware as well:
http://hg.sandbox.lt/authorize-middleware/

I need to document those middlewares...

-- 
Dalius
http://blog.sandbox.lt

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---