[Repoze-dev] [issue142] Chameleon does not understand Python list comprehension

2010-03-22 Thread Chris McDonough

Chris McDonough  added the comment:

This got fixed in SVN by Malthe today.

--
status: unread -> resolved

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue142] Chameleon does not understand Python list comprehension

2010-03-16 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Chris McDonough wrote:
> On 3/16/10 3:36 PM, Charlie Clark wrote:
>> Am 16.03.2010, 20:12 Uhr, schrieb Adam Hutton:
>>
>>> In this example, c.facility_housing is a list of objects
>>> (SQLAlchemy-created)
>>> which have an attribute '.housing' that is a string.
>>> @@ PYTHON
>> ', '.join([housing_type.housing for housing_type in
>> c.facility_housing])
>>> u'Assisted Living, Independent Living'
>>> @@ Chameleon Page Template
>>> 
>> Do list comprehensions count as statements?
> 
> Yes.  Basically anything that doesn't do a variable assignment or uses 
> something like "print" can be part of a statement.

'expressions' are things that have values;  'statements' (like print in
Python2, or assignments) don't.


Tres.
- --
===
Tres Seaver  +1 540-429-0999  tsea...@palladion.com
Palladion Software   "Excellence by Design"http://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkuf5nkACgkQ+gerLs4ltQ7SMACeJHgybyJOE8GOvB0FYhLSoXq8
ZX8AoIZ8QVpxHB2P+J/Rds5ORNAbc+cO
=8KUu
-END PGP SIGNATURE-
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue142] Chameleon does not understand Python list comprehension

2010-03-16 Thread Chris McDonough
On 3/16/10 3:36 PM, Charlie Clark wrote:
> Am 16.03.2010, 20:12 Uhr, schrieb Adam Hutton:
>
>> In this example, c.facility_housing is a list of objects
>> (SQLAlchemy-created)
>> which have an attribute '.housing' that is a string.
>> @@ PYTHON
> ', '.join([housing_type.housing for housing_type in
> c.facility_housing])
>> u'Assisted Living, Independent Living'
>> @@ Chameleon Page Template
>> 
>
> Do list comprehensions count as statements?

Yes.  Basically anything that doesn't do a variable assignment or uses 
something like "print" can be part of a statement.

- C
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] [issue142] Chameleon does not understand Python list comprehension

2010-03-16 Thread Charlie Clark
Am 16.03.2010, 20:12 Uhr, schrieb Adam Hutton :

> In this example, c.facility_housing is a list of objects  
> (SQLAlchemy-created)
> which have an attribute '.housing' that is a string.
> @@ PYTHON
 ', '.join([housing_type.housing for housing_type in  
 c.facility_housing])
> u'Assisted Living, Independent Living'
> @@ Chameleon Page Template
> 

Do list comprehensions count as statements? In any case I wouldn't like to  
see this amount of Python code in a template.

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue142] Chameleon does not understand Python list comprehension

2010-03-16 Thread Adam Hutton

New submission from Adam Hutton :

I'm using Chameleon 1.1.1 and Pylons 0.9.7.

In this example, c.facility_housing is a list of objects (SQLAlchemy-created)
which have an attribute '.housing' that is a string.

@@ PYTHON
>>> ', '.join([housing_type.housing for housing_type in c.facility_housing])
u'Assisted Living, Independent Living'

@@ Chameleon Page Template


@@ ERROR
NameError: housing_type

@@FAILING TEST
@@ (note: I've never written a test before so apologies for any errors in the
test-writing)
Tack this onto one of the existing doc tests:

List Comprehension
---

An issue was observed where list comprehension notation resulted
in a NameError unless the iterator was already defined.

  >>> print render("""\
  ... http://www.w3.org/1999/xhtml";
  ...  xmlns:tal="http://xml.zope.org/namespaces/tal";>
  ...  
  ... """)
  http://www.w3.org/1999/xhtml";>
   0-1-2-3-4-5
  

--
messages: 387
nosy: adamhutton
priority: bug
status: unread
title: Chameleon does not understand Python list comprehension

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev