[TurboGears] Re: dynamic widget.TableForm

2006-01-05 Thread Jeremy Jones


Kevin Dangoor wrote:


On 1/4/06, JP Farias [EMAIL PROTECTED] wrote:
 


Is there a way to pass parameters to the callback?

I just wanted to pass the **kw the controller method receives to the
callback
to create the form.
   



No, the callback can't take parameters. However, cherrypy.request
should have everything you need.

Kevin

--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com

 

As a side note, it looks like if you pass in a callable to the 
decorator, the callable gets passed in your controller object.  This is 
from controllers.py:



   104 def validate(form=None, validators=None):
   105 def decorator(func):
   106 def newfunc(self, *args, **kw):
   107 processed = getattr(cherrypy.request, 
form_processed, False)

   108 if not processed and form:
   109 if callable(form) and not 
hasattr(form,'declarative_count'):

   110 inputform = form(self)
   111 else:
   112 inputform = form


So, I guess if you needed something that didn't come in on 
cherrypy.request, you could hang it off of your controller before the 
form is created.  I think it's probably safer to try to get it passed in 
on cherrypy.request, though.


- jmj


[TurboGears] Re: kid problem in turbogear

2006-01-05 Thread Lee McFadden

Enumerate may be your friend here:

?python pages = ['one','two','three','two'] ?
div py:strip=True py:for=i,pagename in enumerate(pages)
a href=${std.url('/%s' % pagename)} py:content=pagenameContent/a
span class=separator py:if=len(pages)  i|/span
/div


Now, I can't quite remember, but I think that  will work there and
it's  that doesn't work.  Due to the nature of that loop you could
proably do py:if=not len(pages) == i instead and it would have the
same effect.

This was all written in gmail, so it may or may not work out of the box :)

Lee


On 1/4/06, Ivo Looser [EMAIL PROTECTED] wrote:

  
   Well if you know it's a list or tuple:
  
   ?python pages = ['one','two','three'] ?
   div py:strip=True py:for=pagename in pages
   a href=${std.url('/%s' % pagename)}
  py:content=pagenameContent/a·
   span class=separator py:if=pagename != pages[-1]|/span
   /div
  
   If it's an iterator, I'm not sure.
  

 Thanks Liza it works.

 
  This may not be the best general example. What if pages equaled ['one',
  'two', 'three', 'two']?
 
  -- David
 

 its a unique key in the Database. Duplicates arent possible.

 May i come to this when i got the solution how i can change unicodes
 right to 8859-1 in Database and in the Page. :-)

 Best Regards Ivo



[TurboGears] Re: How to avoid importing SQLObjectNotFound

2006-01-05 Thread Lee McFadden

I'm curious as to why you don't want to import SQLObjectNotFound. 
With SQLObjectNotFound in the except statement it's perfectly clear as
to when you want the exception to be handled and when you don't. 
LookupError may cover other things in your try block and could cause
bugs down the road.

On 1/5/06, Stephen Thorne [EMAIL PROTECTED] wrote:

 I've been seeing this in various places around turbogears and example
 code, and I thought I'd just make a comment about it:

 except SQLObjectNotFound:

 Using sqlobject.SQLObjectNotFound isn't actually necessery.
 SQLObjectNotFound extends LookupError, which is a builtin, so you can
 just use

 try:
 o = foo.byName(bar)
 except LookupError:
 raise cherrpy.HTTPRedirect, '/'

 should work. :)
 --
 Regards,
 Stephen Thorne
 Development Engineer

 Scanned by the NetBox from NetBox Blue
 (http://netboxblue.com/)




[TurboGears] Re: how to recover from aborted transaction

2006-01-05 Thread Kevin Dangoor

Note also that TurboGears 0.9 makes the hub.begin(), commit() and
end() automatic.

Kevin

On 1/5/06, Olivier Favre-Simon [EMAIL PROTECTED] wrote:
 Unless I miss something, this much more simple code should work:

 n = 'a subject'
 hub.begin()
 try:
 rs = Subject.byName(n)
 print Found: %s % rs
 except SQLObjectNotFound:
 print %s Not Found! Creating... % rs
 rs = Subject(name=n)
 hub.commit()
 hub.end()

 of course you must have alternateID=True in your model, i.e. something like

name = StringCol(alternateID=True, length=200)


 Olivier.


 Soni Bergraj wrote:
  Hello,
  I try to get a Subject from the database, if this fails i want to create
  a new one. But how ever i arrange hub.begin(), hub.end() and
  hub.commit() i always get an
 
  AssertionError: This transaction has already gone through ROLLBACK;
  begin another transaction
 
  For the except statement (object does not exist, create a new one)
 
  hub.begin()
  try:
  subject = Subject.byName(name)
  hub.commit
  hub.end()
 
  except SQLObjectNotFound:
  hub.end()
  hub.begin()
  subject = Subject(name = name)
  hub.commit()
  hub.end()
 
  The hub is of type PackageHub, I didn't found documentation for it
  (deprecated?).
 
  Thanks for help,
 
 






--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com


[TurboGears] Re: Connections with existing SQLObject classes

2006-01-05 Thread Kevin Dangoor

Hi Randall,

You don't *have* to use one of those two hubs unless you want
TurboGears' database features (TG config file for the connection URI,
automatic connection per thread, automatic transactions in 0.9).

Setting _connection on the class to the hub is a fine way to set the
hub. You might also try module.__connection__ = hub, which is what TG
does in quickstart projects.

Kevin

On 1/5/06, Randall [EMAIL PROTECTED] wrote:

 I've got many existing SQLObject classes that I would like to use in
 TurboGears.  They are designed with no connection specified so that
 they automatically pick up sqlobject.sqlhub.  I'm new to TG, so please
 take into consideration my ignorance.  I looked at AutoConnectHub and
 PackageHub.  It looks like I have to use one of these two with my
 SQLObject classes to get them to work.

 I've managed to get this to work like so:

 In Model.py

 hub = PackageHub(mypackage)
 MySQLObjectClass._connection = hub

 Is this a good way to set the connection?

 Randall




--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com


[TurboGears] Re: Announcing Scaffolding - A CMS for Turbogears

2006-01-05 Thread Cliff Wells


Karl Guertin wrote:

On 1/4/06, Gábor Farkas [EMAIL PROTECTED] wrote:
  

an interesting discussion about this to trigger or not to trigger
issue was spawned based in a blog entry on David Heinemeier Hansson's
(ruby on rails...) blog:

http://www.loudthinking.com/arc/000516.html



You'll notice in that article he qualifies the statement saying that
he's talking (only!) about application databases. For most of the
stuff I do at work (and apparently for Jorge as well), the database is
the lingua franca of the system, i.e. they're integration databases
and not app databases. This means that I have to spindle/fold/mutilate
SQLObject to fit with the DB relational model but it also means that I
want the triggers to fire because that kicks off the rest of the
system.
  
What I took away from this article is the sense that while David is a 
brilliant programmer with an uncanny sense of where to ride the line on 
many ideas, he's not really a database guy.  In fact, I'd say he'd 
probably happily agree, judging from the tone of the article.  I think 
his view, while interesting in a very abstract we're not talking about 
real databases with real, important data sense has some merit.   
However, I think the notion of an application database is a fallacy, 
unless you are just talking about the database for a blog or some other 
highly specific, non-enterprise type of application.  The minute the 
data has interest outside the original application, the minute you'll 
find people wanting to access it by other means and about one minute 
later his entire fallacy falls apart.  Take this with the well-known 
adage that data outlives applications and David's argument is a recipe 
for disaster. 

It's well-known that language to a large extent limits what you can 
express.  I think that extends to other things as well, and I think 
David's argument reveals more about his MySQL-centric past than anything 
else.   Not only that, but his position is inconsistent with his 
position on other aspects of the Rails stack.  He argues that it's okay 
to have code in templates as long as it's presented as a domain-specific 
language, but that it's not okay to have code in databases, that they 
should rather be dumb storage.  He makes a distinction between 
relational (database) logic and business logic (as do I) but fails to 
make the same distinction between data logic (relations) and business 
logic.  

At the end of the day, even if David's arguments had merit, I'd still be 
more inclined to trust my relational logic to the database developers 
and their years of experience in this domain *and* their millions of 
users who provide an ample test-bed than to one guy who's used one 
database for a few years, and who, up until a couple of years ago, 
thought PHP was a good language.


Sorry to rant, but he closed off comments on that blog and it's been 
eating at me ;-)



Regards,
Cliff





[TurboGears] Re: SQLObject Help

2006-01-05 Thread zgoda

The doc you mention says it's possible.


You can use the keyword arguments orderBy to create ORDER BY in the
select statements: orderBy takes a string, which should be the database
name of the column, or a column in the form Person.q.firstName. You can
use -colname to specify descending order, or call
MyClass.select().reversed().


Anyway, I don't know how to make ordering by 2 columns, one asc and one
desc.

Cheers
Jarek Zgoda



[TurboGears] TurboStan 0.7

2006-01-05 Thread Cliff Wells


Hot on the tails of 0.5, because 0.6 was boring, TurboStan 0.7 is
released.  I probably wouldn't have mentioned it except that there are a
couple important bugfixes and a new feature that everyone (well, me) was
screaming for: template inheritance.

From the Changelog (since 0.5):

 - Added std variables and functions (i.e. things like std.tg_js and
std.url are now available)
 - Dynamically filter variables passed to Kid for reserved names (this
should be removed when Kid is fixed)
 - Added config option (stan.prettyoutput = True) to turn on pretty
html output if utidylib is installed - useful for debugging output
 - Changed package name to turbostan from stansupport.  You can now
directly import (if you really need to) via turbostan.stansupport
   which looks a bit better to my eye than stansupport.stansupport ;-)
 - Added inheritance similar to Kid and Django templates

The basic syntax of inheritance is this:

index.stan:
-
html [
   body [
   div [ slot ('menu') ],
   div [ slot ('content') ]
   ]
]

page.stan:
-
inherits (template = 'index.stan') [
   replace (slot = 'content') [
   p [ 'this replaces the slot in index.stan' ]
   ],
   replace (slot = 'menu') [
   ul (class_ = 'menu') [ li (class_='menuitem')[ m ] for m in
['menu1', 'menu2', 'menu3'] ]
   ]
]


You may not think it's cool, but I sure did.   I also thought it was
damn lucky I got it to work at all, so send me your bug reports.

You can get TurboStan via the Cheese shop (easy_install TurboStan) or
from http://www.develix.com/downloads/TurboStan/TurboStan-0.7.tgz

Regards,
Cliff




[TurboGears] Re: Connections with existing SQLObject classes

2006-01-05 Thread Michael Schneider

Kevin,

Is ticket #77   (the SQLObject classes) must be defined in model.py?

http://trac.turbogears.org/turbogears/ticket/77

I started my project in a similar situation.  I imported my SQLObjects
into model.py and it did not work.  I ended up, pasting all of my
objects into model.py.  This
gets ugly as your model gets complicated (many SQLObjects).

This is not a .9 issue.  It would be nice for 1.0.

If it is not possible to look for SQLObjects imported into model.py,
maybe
a model package could be used under the main project dir, and all
SQLObjects
in that package could be viewed by tg-admin.

tg-admin sql features are great, and worth putting all SQLObject's in
model.py.

Thanks again for your efforts in TurboGears.  It is a pleasure to
develop in this
framework.

Happy Coding,
Mike



[TurboGears] Re: TurboStan 0.7

2006-01-05 Thread Michael Schneider

Thanks Cliff,


That is a great feature.  I am stuck in meetings this morning, but look
forward to trying it out this afternoon.


Mike



[TurboGears] Re: TurboStan 0.7

2006-01-05 Thread [EMAIL PROTECTED]

What python modules we need to install TurboStan?

Nevow (zope ???)
turbogears



[TurboGears] Re: Announcing Scaffolding - A CMS for Turbogears

2006-01-05 Thread Kevin Dangoor

On 1/5/06, Cliff Wells [EMAIL PROTECTED] wrote:
 What I took away from this article is the sense that while David is a
 brilliant programmer with an uncanny sense of where to ride the line on
 many ideas, he's not really a database guy.  In fact, I'd say he'd
 probably happily agree, judging from the tone of the article.  I think
 his view, while interesting in a very abstract we're not talking about
 real databases with real, important data sense has some merit.
 However, I think the notion of an application database is a fallacy,
 unless you are just talking about the database for a blog or some other
 highly specific, non-enterprise type of application.

Actually, I do think that both styles (application database,
integration database) have merit for certain apps. Here's where
application databases make some amount of sense:

1) newfangled, Web 2.0 applications and web services. Things like
Backpack (surprise, surprise!), where the application serves a
distinct purpose and lives out on the net. Data I/O is all done via
web requests that go through the application code, which ensures the
integrity of the data (to whatever extent it has been programmed to do
so).

2) small office applications. I did a lot of work on billing systems
for doctors offices. Those systems are (or, at least, were) quite
self-contained and the people in the office tended to use those apps
for everything and not be computer literate enough to do much outside
of there beyond word processing. (That's a generalization, certainly.)

Now, these two points are what you mean by highly specific,
non-enterprise type of application, but I wanted to break it out more
and emphasize that there's *a lot* of this, and #1 is still a growing
category.

The larger the organization, the more likely it is to move into the
integration database' category. A big organization *could* decide to
expose the database entirely via web services and use that layer to
maintain the database, or it could opt to move more into stored
procedures, triggers and the like to make the database engine do the
work. So, even within big organizations, there's still a choice to be
made that could enable the application database perspective.

Kevin


[TurboGears] Re: SQLObject Help

2006-01-05 Thread Ksenia Marasanova

2006/1/5, zgoda [EMAIL PROTECTED]:

 The doc you mention says it's possible.

 
 You can use the keyword arguments orderBy to create ORDER BY in the
 select statements: orderBy takes a string, which should be the database
 name of the column, or a column in the form Person.q.firstName. You can
 use -colname to specify descending order, or call
 MyClass.select().reversed().
 

 Anyway, I don't know how to make ordering by 2 columns, one asc and one
 desc.

I guess the docs are not complete. You can pass multiple columnnames in a list:

results = Employee.select(orderBy=['-title', 'age'])
--
Ksenia


[TurboGears] What is sqlobject-history meant for?

2006-01-05 Thread Soni Bergraj

Hello,
tg-admin quickstart creates a directory 'sqlobject-history' and I'm
really puzzled what it's meant for?

Didn't found something useful in the archives.

Thanks,

-- 
Soni Bergraj


[TurboGears] Re: Connections with existing SQLObject classes

2006-01-05 Thread Kevin Dangoor

On 1/5/06, Michael Schneider [EMAIL PROTECTED] wrote:
 I started my project in a similar situation.  I imported my SQLObjects
 into model.py and it did not work.  I ended up, pasting all of my
 objects into model.py.  This
 gets ugly as your model gets complicated (many SQLObjects).

I agree. This will get fixed in some fashion, I'm just not sure what
the best way is. (At the moment, you can edit
Project.egg-info/sqlobject.txt to put the appropriate list of modules
there.)

Kevin


[TurboGears] sqlwidgets

2006-01-05 Thread Randall

I think sqlwidgets is a great idea and I'm determined not to duplicate
data and logic in my forms.  Referring to formmaker.column_params,
couldn't you use column.validator as the validator by default?  Also,
could there be a use for these attributes?

foreignKey:  for creating a list or search to populate the element.
notNone:  validation.  Should be done by column.validator, right?
tags:  Not sure what those are.
varchar:  If False, set a maxlength attribute in the element.

I think that SQLObject should and does to a good degree facilitate
detailed descriptions and rules for its data in a way that is reusable
and TurboGears should take full advantage.

A simple but cool example:  An email column is defined in an
SQLObject class as notNone.  Its FormEncode validator checks to see the
address is valid.  TurboGears automatically generates the column
complete with server side and javascript validation to ensure the value
is not null and a valid email address.

Randall



[TurboGears] Re: Announcing Scaffolding - A CMS for Turbogears

2006-01-05 Thread Karl Guertin

On 1/5/06, Cliff Wells [EMAIL PROTECTED] wrote:
 It's well-known that language to a large extent limits what you can
 express.

I'm not entirely sure about 'express', but the definitely affect how
you think. This is the Sapir-Whorf Hypothesis.

http://lambda-the-ultimate.org/classic/message928.html


[TurboGears] Re: fastdata DataController does not coerce types

2006-01-05 Thread Randall

True.  Where should the limit be defined?  I think the select list
could be created using convention.  In my experience, an id/name combo
is the most often used.  With SQLObject, even if you don't have a name
field, it is easy to add a method for it.  I'm implementing this now.
Will check back.

Randall



[TurboGears] Problems installing pysqlite on Linux

2006-01-05 Thread Michael Schneider

Hello All,

This is a specific question on linux, sqlite, pysqlite.

Sorry to ask such a specific question to this group, but my email to
the pysqlite is awaiting moderator approval.

Any help would be very apreciated.

Thanks
Mike
--


I develop on windows and will deploy on linux.   Python was not
installed on my server,
(and I don't have root access).


suse 9.2 64 bit linux.


sqlite works ok, but I can't seem to get pysqlite to find mysqlite3.so.


All of turbogears runs, but I can't get sqlite going

here is the info
---

I haven't been on UNIX for a couple of years so it is a little rusty.



It looks like I am having problems finding libsqlite3.so when running.





Where I am at:

-compile sqlite

-test sqlite (ok)

-compile pysqlite (ok)

-install pysqlite (no errors)

test, fail,   ImportError:
/misc/pdtools/scm/.scmikes/python2.4/dist/lnx64/lib/python2.4/site-

packages/pysqlite2/_sqlite.so: undefined symbol: sqlite3_bind_blob







Is there a place in the python distribution where I can copy sqlite3.so
?



Thanks

Mike



-- install info -.



Python 2,4,2 is installed with:

prefix= /misc/pdtools/scm/.scmikes/python2.4/dist/

exec-prefix= /misc/pdtools/scm/.scmikes/python2.4/dist/lnx64





sqlite3 (latest release) was just installed with the same prefix and
exec prefix



PATH=$PATH:{prefix}/bin;{exec-prefix}/lnx64





sqlite3  works from the command line !!!





Compile/build/install step





I forced the copied sqlite3.h into the python header file area (bad, I
know)





(scmikes)cila6s08:pysqlite-2.0.5python setup.py install

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.4

creating build/lib.linux-x86_64-2.4/pysqlite2

copying lib/__init__.py - build/lib.linux-x86_64-2.4/pysqlite2

copying lib/dbapi2.py - build/lib.linux-x86_64-2.4/pysqlite2

creating build/lib.linux-x86_64-2.4/pysqlite2/test

copying lib/test/__init__.py -
build/lib.linux-x86_64-2.4/pysqlite2/test

copying lib/test/dbapi.py - build/lib.linux-x86_64-2.4/pysqlite2/test

copying lib/test/factory.py -
build/lib.linux-x86_64-2.4/pysqlite2/test

copying lib/test/transactions.py -
build/lib.linux-x86_64-2.4/pysqlite2/test

copying lib/test/types.py - build/lib.linux-x86_64-2.4/pysqlite2/test

copying lib/test/userfunctions.py -
build/lib.linux-x86_64-2.4/pysqlite2/test

running build_ext

building 'pysqlite2._sqlite' extension

creating build/temp.linux-x86_64-2.4

creating build/temp.linux-x86_64-2.4/src

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -fPI

C -DPYSQLITE_VERSION=2.0.5 -DPY_MAJOR_VERSION=2 -DPY_MINOR_VERSION=4
-I/misc/p

dtools/scm/.scmikes/python2.4/dist/include/python2.4
-I/misc/pdtools/scm/.scmike

s/python2.4/dist/lnx64/include/python2.4 -c src/module.c -o
build/temp.linux-x86

_64-2.4/src/module.o

In file included from src/connection.h:32,

 from src/module.c:24:

/misc/pdtools/scm/.scmikes/python2.4/dist/include/python2.4/sqlite3.h:1254:
warn

ing: function declaration isn't a prototype

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -fPI

C -DPYSQLITE_VERSION=2.0.5 -DPY_MAJOR_VERSION=2 -DPY_MINOR_VERSION=4
-I/misc/p

dtools/scm/.scmikes/python2.4/dist/include/python2.4
-I/misc/pdtools/scm/.scmike

s/python2.4/dist/lnx64/include/python2.4 -c src/connection.c -o
build/temp.linux

-x86_64-2.4/src/connection.o

In file included from src/connection.h:32,

 from src/connection.c:25:

/misc/pdtools/scm/.scmikes/python2.4/dist/include/python2.4/sqlite3.h:1254:
warn

ing: function declaration isn't a prototype

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -fPI

C -DPYSQLITE_VERSION=2.0.5 -DPY_MAJOR_VERSION=2 -DPY_MINOR_VERSION=4
-I/misc/p

dtools/scm/.scmikes/python2.4/dist/include/python2.4
-I/misc/pdtools/scm/.scmike

s/python2.4/dist/lnx64/include/python2.4 -c src/cursor.c -o
build/temp.linux-x86

_64-2.4/src/cursor.o

In file included from src/connection.h:32,

 from src/cursor.h:28,

 from src/cursor.c:24:

/misc/pdtools/scm/.scmikes/python2.4/dist/include/python2.4/sqlite3.h:1254:
warn

ing: function declaration isn't a prototype

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -fPI

C -DPYSQLITE_VERSION=2.0.5 -DPY_MAJOR_VERSION=2 -DPY_MINOR_VERSION=4
-I/misc/p

dtools/scm/.scmikes/python2.4/dist/include/python2.4
-I/misc/pdtools/scm/.scmike

s/python2.4/dist/lnx64/include/python2.4 -c src/cache.c -o
build/temp.linux-x86_

64-2.4/src/cache.o

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -fPI

C -DPYSQLITE_VERSION=2.0.5 -DPY_MAJOR_VERSION=2 

[TurboGears] Static Site question

2006-01-05 Thread SamFeltus

Maybe there should be some marker to put on your CherryPy pages, for an
option to publish all marked pages, with associated JavaScript, images,
CSS, etc, as a static site.  Perhaps publish as a tar file or FTP to a
site?

I haven't seen this feature (am I blind).  Seems to me it oughta be
added, so one could develop/edit simple sites in TuboGears, and then
deploy a static site.

Then again, maybe this is Creeping Featurism and not a Missing Feature?

Sam

Then again, maybe I overlook something.



[TurboGears] Re: Attention: people running TurboGears 0.9 out of SVN

2006-01-05 Thread markc

This seemed to work for me (ubuntu/breezy)...

 cd /path/to/svn/turbogears
 svn up .
 python ez_setup.py setuptools
 python ez_setup.py
http://www.turbogears.org/download/eggs/PasteScript-0.4dev_r4192-py2.4.egg
 python ez_setup.py
http://www.turbogears.org/download/eggs/SQLObject-0.7.1dev_r1457-py2.4.egg
 python setup.py develop

The links being from the Download packages section at...

 http://www.turbogears.org/download/index.html

--markc



[TurboGears] Re: fastdata DataController does not coerce types

2006-01-05 Thread Randall

Check this out.  I added this to formmaker.py  It creates a select box
if your SQLObject class has an attribute named 'option_name'.
option_name should be configurable.  Really cool I think!

# Added to handle foreign keys.
def column_widget_fk_col(column):
parms = column_parms(column)
fk_class_name = column.foreignKey
fk_class = sqlobject.classregistry.findClass(fk_class_name)
fk_class_data = fk_class.select()
if hasattr(fk_class, 'option_name'):
options = [[rset.id, rset.option_name] for rset in
fk_class_data]
return widgets.SelectField(validator=None, options=options,
**parms)
else:
return widgets.TextField(validator=None, **parms)
column_widget_fk_col = column_widget.when(
isinstance(column, col.SOKeyCol))(column_widget_fk_col)



[TurboGears] Re: sqlwidgets

2006-01-05 Thread Randall

Forgive me for cross posting, but this really belongs under
sqlwidgets.  I think sqlwidgets rocks!

Check this out.  I added this to formmaker.py  It creates a select box
if your SQLObject class has an attribute named 'option_name'.
option_name should be configurable.  Really cool I think!

# Do this at the top.
import sqlobject

# Added to handle foreign keys.
def column_widget_fk_col(column):
parms = column_parms(column)
fk_class_name = column.foreignKey
fk_class = sqlobject.classregistry.findClass(fk_class_name)
fk_class_data = fk_class.select()
if hasattr(fk_class, 'option_name'):
options = [[rset.id, rset.option_name] for rset in
fk_class_data]
return widgets.SelectField(validator=None, options=options,
**parms)
else:
return widgets.TextField(validator=None, **parms)
column_widget_fk_col = column_widget.when(
isinstance(column, col.SOKeyCol))(column_widget_fk_col)



[TurboGears] Re: What is sqlobject-history meant for?

2006-01-05 Thread Jeff Grimmett
I think that's used for database backup and restore (upgrade?).On 1/5/06, Soni Bergraj [EMAIL PROTECTED] wrote:
Hello,tg-admin quickstart creates a directory 'sqlobject-history' and I'm
really puzzled what it's meant for?Didn't found something useful in the archives.Thanks,--Soni Bergraj-- I never gave anybody hell. I just told the truth and the Republicans thought it was hell.
- Harry S. Truman.Best,Jeff 


[TurboGears] Re: What is sqlobject-history meant for?

2006-01-05 Thread Karl Guertin

On 1/5/06, Jeff Grimmett [EMAIL PROTECTED] wrote:
 I think that's used for database backup and restore (upgrade?).

My guess is that eventually it'll be a db migration feature like rails has.


[TurboGears] Re: tg-admin sql create failing with MySQL 3.23

2006-01-05 Thread Kevin Dangoor

I just double checked this, and I think you must be using an
AutoConnectHub rather than a PackageHub. This behavior is actually
implemented in PackageHub.

Kevin

On 1/4/06, Mike Kent [EMAIL PROTECTED] wrote:

 I decided to try TurboGears 0.9 (svn) on another linux box at work,
 which has MySQL 3.23.  After installing 0.9 by following the
 instructions on the 'Contributing to TurboGears' page, and defining my
 model (all of which works fine on another machine with MySQL 4),  I
 run 'tg-admin sql create' and get:

 Exception exceptions.TypeError: 'exceptions must be classes, instances,
 or strings (deprecated), not NoneType' in bound method
 Transaction.__del__ of sqlobject.dbconnection.Transaction object at
 0x40a4ddcc ignored

 OK, I know this version of MySQL doesn't have transaction.  Checking
 'dev.cfg', I see a new comment:

 # if you are using a database or table type without transactions
 # (MySQL default, for example), you should turn off transactions
 # by prepending notrans_ on the uri
 #
 sqlobject.dburi=notrans_mysql://username:[EMAIL PROTECTED]:port/databasename

 So I do so.  Then when I run 'tg-admin sql create' I get a long
 exception dump that ends in:

 AssertionError: No SQLObject driver exists for notrans_mysql (only
 sqlite, sapdb, postgresql, firebird, maxdb, sybase, interbase, psycopg,
 mysql, postgres)

 Examining the code leads me to believe that while TurboGears understand
 'notrans_', SQLObject does not.  Is this a known issue?




--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com


[TurboGears] Re: What is sqlobject-history meant for?

2006-01-05 Thread Kevin Dangoor

usage: tg-admin sql record [options]
Record historical information about the database status
Record state of table definitions.  The state of each table is written out
to a separate file in a directory, and that directory forms a version.  A
table is also added to you datebase (sqlobject_db_version) that reflects the
version the database is currently at.  Use the upgrade command to sync
databases with code.

On 1/5/06, Soni Bergraj [EMAIL PROTECTED] wrote:

 Hello,
 tg-admin quickstart creates a directory 'sqlobject-history' and I'm
 really puzzled what it's meant for?

 Didn't found something useful in the archives.

 Thanks,

 --
 Soni Bergraj



--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com


[TurboGears] Re: Proposal: Visitor Tracking

2006-01-05 Thread Michele Cella

Kevin Dangoor wrote:
 On 1/3/06, Michele Cella [EMAIL PROTECTED] wrote:
  Can this be a starting point?
  http://www.cherrypy.org/changeset/908

 Yeah, that's good stuff. Unfortunately, that is likely CherryPy 3.0.

 It would be nice if we can implement a stopgap before then.


Good news (if I'm not mistake), it seems as this (or sort of) has found
its way into CP trunk (2.2):

http://www.cherrypy.org/ticket/145

Ciao
Michele



[TurboGears] Re: Problems installing pysqlite on Linux

2006-01-05 Thread [EMAIL PROTECTED]

Michael,

I had a similar problem (the exact same message from the import,
actually), and I eventually solved it by fixing my LD_LIBRARY_PATH to
include 'libsqlite3.so.0'

I think you're having the same problem.  When I do ldd on _sqlite.so,
I get this:

[phedex] /usr/local/lib/python2.4/site-packages/pysqlite2  ldd
_sqlite.so
libsqlite3.so.0 =
/opt/cms/lcg/external/sqlite/3.0.8/slc3_ia32_gcc323/lib/libsqlite3.so.0
(0x00ede000)
libpthread.so.0 = /lib/tls/libpthread.so.0 (0x002e2000)
libc.so.6 = /lib/tls/libc.so.6 (0x001a8000)
libgcc_s.so.1 = /lib/libgcc_s.so.1 (0x0030)
/lib/ld-linux.so.2 = /lib/ld-linux.so.2 (0x00878000)

Notice how that is linking to libsqlite3.so.0, but yours is not.
That's why I think your LD_LIBRARY_PATH is incorrect.



[TurboGears] Re: tg-admin sql create failing with MySQL 3.23

2006-01-05 Thread Karl Guertin

On 1/5/06, Mike Kent [EMAIL PROTECTED] wrote:
 Now, it's true that this model.py, and my entire project, was
 originally created for TG 0.8, and moved over to a new project using TG
 0.9.  Could this be a factor?


I just quickstarted a project from scratch (r457) and I'm still seeing
the issue. I haven't looked much at the db code, so I didn't trace it
fully. It looks like it should be pulled out but somehow it's not.

Steps:
1. tg-admin quickstart
2. configure dburi from another project using 'mysql://'
3. copy a sqlobject from that class into quickstarted project
4. tg-admin shell
5. Object.get(1) -- is ok
6. prepend 'notrans_' onto dburi
7. tg-admin shell
8. Object.get(1) -- stack trace as listed above


[TurboGears] 1000+ Users Subscribed

2006-01-05 Thread Jared Kuolt

Some time between Tuesday and today we passed the 1000 users mark on
the mailing list!

Congratulations to all involved, especially Kevin The Danger Dangoor!
--
[EMAIL PROTECTED]


[TurboGears] escaping text for kid templates...

2006-01-05 Thread Jonathan LaCour


I am seeing a bug in a TurboGears application that I have in  
production where people are entering text in textile format.  I am  
saving this text in the database, and on the way out textile encoding  
it, and passing it into a kid template, which then includes the  
string in the template using the XML() function.


The bug I am seeing is when people use certain characters in their  
text (such as  and , for example) that cause invalid XML.   
Typically, I would just run my string through cgi.escape() before I  
pass it into textile, but this will use named entity definitions,  
which I don't believe XML supports.


Is there an equivalent to cgi.escape out there that will generate XML- 
friendly entity definitions, or a better solution to my problem?  I  
am considering just doing a string replacement on the two offending  
characters for now, but this seems a bit of a hack, and doesn't  
handle other characters that could potentially cause problems...


Thanks.

--
Jonathan LaCour
http://cleverdevil.org




[TurboGears] Re: 1000+ Users Subscribed

2006-01-05 Thread Kevin Dangoor

On 1/5/06, Jared Kuolt [EMAIL PROTECTED] wrote:

 Some time between Tuesday and today we passed the 1000 users mark on
 the mailing list!

 Congratulations to all involved, especially Kevin The Danger Dangoor!

Boy, I sure hope The Danger that doesn't stick. I haven't been
planning to enter pro wrestling, but with a name like that I might
just have to.

For a bit more on the 1,000 member milestone:
http://www.blueskyonmars.com/2006/01/05/1000-members/

Thank you to all of the members of this community who have helped it
grow and flourish!

Kevin


[TurboGears] Re: tg-admin sql create failing with MySQL 3.23

2006-01-05 Thread Kevin Dangoor

On 1/5/06, Mike Kent [EMAIL PROTECTED] wrote:

 From the top of my model.py:

 from sqlobject import *
 from turbogears.database import PackageHub

 hub = PackageHub(books)
 __connection__ = hub

 Now, it's true that this model.py, and my entire project, was
 originally created for TG 0.8, and moved over to a new project using TG
 0.9.  Could this be a factor?

Thankfully, no. This is standard Python... so if you've got a
PackageHub, you've got a PackageHub :)

I'll have to look a bit further then. For me, the uri that went into
the AutoConnectHub that's running behind the scenes had the notrans_
removed when I was playing at the Python prompt.

Kevin

--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com


[TurboGears] Re: Proposal: Visitor Tracking

2006-01-05 Thread Kevin Dangoor

On 1/5/06, Michele Cella [EMAIL PROTECTED] wrote:
 Good news (if I'm not mistake), it seems as this (or sort of) has found
 its way into CP trunk (2.2):

 http://www.cherrypy.org/ticket/145

Gadzooks. All hail the mighty Fumanchu!

This puts me in a bit of a quandry as far as CP 2.2 is concerned.
IMHO, this is a hugely important feature for a variety of reasons. I
think I'll work on clearing the TurboGears 0.9 queue in Trac and then
decide whether CP 2.2 arrives in TurboGears 0.9 or 1.0.

Kevin


[TurboGears] Re: escaping text for kid templates...

2006-01-05 Thread Kevin Dangoor

Hi Jonathan,

You might want to try cgi.escape. There was a change made to Kid that
gives it (some|all) of the common HTML entities.

Kevin

On 1/5/06, Jonathan LaCour [EMAIL PROTECTED] wrote:

 I am seeing a bug in a TurboGears application that I have in
 production where people are entering text in textile format.  I am
 saving this text in the database, and on the way out textile encoding
 it, and passing it into a kid template, which then includes the
 string in the template using the XML() function.

 The bug I am seeing is when people use certain characters in their
 text (such as  and , for example) that cause invalid XML.
 Typically, I would just run my string through cgi.escape() before I
 pass it into textile, but this will use named entity definitions,
 which I don't believe XML supports.

 Is there an equivalent to cgi.escape out there that will generate XML-
 friendly entity definitions, or a better solution to my problem?  I
 am considering just doing a string replacement on the two offending
 characters for now, but this seems a bit of a hack, and doesn't
 handle other characters that could potentially cause problems...

 Thanks.

 --
 Jonathan LaCour
 http://cleverdevil.org





--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com


[TurboGears] Re: Proposal: Visitor Tracking

2006-01-05 Thread Michele Cella

Kevin Dangoor wrote:

 Gadzooks. All hail the mighty Fumanchu!

:-)


 This puts me in a bit of a quandry as far as CP 2.2 is concerned.
 IMHO, this is a hugely important feature for a variety of reasons. I
 think I'll work on clearing the TurboGears 0.9 queue in Trac and then
 decide whether CP 2.2 arrives in TurboGears 0.9 or 1.0.


I'm not an expert but I'm under the impression (after reading all these
blog posts regarding python and RoR) that Paste Deploy+WSGI can really
become a winning factor for python (and TG) future.

But when will CP 2.2 arrive? Their release schedule is time or feature
based?

Ciao
Michele



[TurboGears] Re: Catwalk hates me

2006-01-05 Thread [EMAIL PROTECTED]

hi,
i got the same empty page comming from catwalk request
solved with:

tg.allow_json = True
in dev.cfg and prod.cfg

andre



[TurboGears] Re: Proposal: Visitor Tracking

2006-01-05 Thread Ben Bangert

I would also consider the flexibility and re-usability of middleware to
be a big assist too since it will allow a variety of talented
developers using multiple frameworks ways to consolidate efforts.

Some examples of current middleware in Paste:
- Eval Exception (that awesome AJAX-based interactive Python traceback
explorer)
- HTTPExceptions (a standard 404/500/etc HTTP catcher)
- Auth functions (Secure Cookies, OpenID, CAS, Digest, Basic)

Obviously the middleware just takes part of one side of most the
problems, but it does push re-usable portions into a place where we can
all actually re-use them.

Being able to attach small WSGI apps, plug-and-play style, also is
rather powerful. If you take a look at the end of the middleware file I
use:
http://pylons.groovie.org/svn/trunk/pylons/templates/paster_template/+package+/config/middleware.py_tmpl

With the knowledge that the Cascade app tries each app, and moves on if
it gets a 404, its pretty obvious how you could extend your app to
support multiple static doc roots (I hope). A basic amount of working
knowledge immediately becomes quite powerful.

Several parts of TurboGears would work great as smaller WSGI apps used
by default on a new TG project. It's also be easy to toggle them
on/off. Ie, turn on the Toolbox during dev mode, but off during
production. Or even package Catwalk as a small Paste compatible app,
and anyone working on a SQLObject-based project can toss up a nice
Catwalk explorer just by pointing a conf file to their models file...

The possibilities are powerful, extensible, and quickly approaching
viability. The middleware file I use could be used almost directly with
TurboGears by replacing the pylons.make_app thing, with the command
needed to create a CherryPy WSGI app. This isn't pie-in-the-sky stuff,
its very close at hand, especially with the CherryPy patch.

Given the inevitability that different frameworks will appeal to
different people, being able to unite on hard problems wherever
possible is a big win in my book.



[TurboGears] Re: Dynamic setting of config options (e.g., database URI)

2006-01-05 Thread markc

This is the very first time I have ever messed with python code and
only then with help from #python. I know there are probably a zillion
righteous ways to do it but this actually works, for me. Aim; to
provide a dynamic default database value to TurboGears so that no
config file(s) have to be edited to get a simple example working. Using
this method, or something similar, means that a *simple* tutorial can
be distributed and unzipped and immediately used without being forced
to edit dev.cfg.

. in dev.cfg comment out all sqlobject.dburi values
. mv your_sqlite.db to default.sqlite
. add to *-start.py - from os.path import *
. add to *-start.py - tg_path = dirname(realpath(__file__))
. add to /your_tg_install_path/turbogears/database.py line line ~10
  - import __main__ as main
. change /your_tg_install_path/turbogears/database.py line line ~142
  from - dburi = cherrypy.config.get(sqlobject.dburi, None)
  to - dburi = cherrypy.config.get(sqlobject.dburi,
sqlite://%s/default.sqlite % main.tg_path)
. start your *-start.py server

Bingo! Hopefully somebody who knows how to will add something like this
properly.

--mark(what's a global between friends)c



[TurboGears] Re: Made a filter similar to variablesdecode()

2006-01-05 Thread Igor Murashkin

Sorry to double post, but a cleaned up and tested version is here, in
the cherrypy wiki:
http://www.cherrypy.org/wiki/NestedListFilter

There is also an example of a FormEncode schema.. very easy to set them
up now that this filter does a lot of grunt work :).



[TurboGears] Re: Stripping 'submit' argument from validated form input inconsistent

2006-01-05 Thread Michele Cella


Kevin Dangoor wrote:
 On 1/4/06, Keir Mierle [EMAIL PROTECTED] wrote:
  The devcast says that the submit argument is removed from the form
  parameters when passed via the inputform; hence there is no 'submit'
  parameter to signup_confirm(). This works great, but only when there is
  no validation errors. When there is errors, somehow the 'submit'
  parameter is sent the second time (i.e. after showing the validation
  errors, the user puts in valid data, clicks submit again). This causes
  a 'unexpected keyword argument submit' error.
 
  I suspect this is not the intended behaviour. I looked through the
  validation code briefly but did not see an obvious answer.

 Sounds like a bug to me. Can you submit a ticket? http://trac.turbogears.org


Regarding sumbit arguments being stripped during the form validation,
if we change the SubmitButton widget to not use the name attribute (who
need this?) there is no need to special case it for removing.

Ciao
Michele



[TurboGears] Re: escaping text for kid templates...

2006-01-05 Thread Jonathan LaCour


Thanks Kevin, this worked like a champ once I upgraded to TurboGears  
0.8.7 (it didn't seem to work before).


Thanks for letting me know about this, I seemed to miss the change  
during my holiday vacation!


  -- Jonathan

On Jan 5, 2006, at 1:39 PM, Kevin Dangoor wrote:


Hi Jonathan,

You might want to try cgi.escape. There was a change made to Kid that
gives it (some|all) of the common HTML entities.

Kevin

On 1/5/06, Jonathan LaCour [EMAIL PROTECTED] wrote:


I am seeing a bug in a TurboGears application that I have in
production where people are entering text in textile format.  I am
saving this text in the database, and on the way out textile encoding
it, and passing it into a kid template, which then includes the
string in the template using the XML() function.

The bug I am seeing is when people use certain characters in their
text (such as  and , for example) that cause invalid XML.
Typically, I would just run my string through cgi.escape() before I
pass it into textile, but this will use named entity definitions,
which I don't believe XML supports.

Is there an equivalent to cgi.escape out there that will generate  
XML-

friendly entity definitions, or a better solution to my problem?  I
am considering just doing a string replacement on the two offending
characters for now, but this seems a bit of a hack, and doesn't
handle other characters that could potentially cause problems...

Thanks.

--
Jonathan LaCour
http://cleverdevil.org






--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com


--
Jonathan LaCour
http://cleverdevil.org




[TurboGears] nl2br for Kid?

2006-01-05 Thread Jared Kuolt

Is there a simple solution for newline-to-br (nl2br) in Kid?

Simple explantation, I need something that will escape all HTML
entities then add a br/ at every newline.

Thanks in advance,
Jared Kuolt
--
[EMAIL PROTECTED]


[TurboGears] Re: nl2br for Kid?

2006-01-05 Thread Bob Ippolito


Something like this, I guess:

span py:for=line in line.splitlines()${line}br//span

On Jan 5, 2006, at 12:58 PM, Jared Kuolt wrote:



Is there a simple solution for newline-to-br (nl2br) in Kid?

Simple explantation, I need something that will escape all HTML
entities then add a br/ at every newline.

Thanks in advance,
Jared Kuolt
--
[EMAIL PROTECTED]




[TurboGears] Re: nl2br for Kid?

2006-01-05 Thread Jared Kuolt

Works for me, thanks!

On 1/5/06, Bob Ippolito [EMAIL PROTECTED] wrote:

 Something like this, I guess:

 span py:for=line in line.splitlines()${line}br//span

 On Jan 5, 2006, at 12:58 PM, Jared Kuolt wrote:

 
  Is there a simple solution for newline-to-br (nl2br) in Kid?
 
  Simple explantation, I need something that will escape all HTML
  entities then add a br/ at every newline.
 
  Thanks in advance,
  Jared Kuolt
  --
  [EMAIL PROTECTED]




--
[EMAIL PROTECTED]


[TurboGears] Re: TurboGears new site look - let's get to it!

2006-01-05 Thread Richard (koorb)

Just going to throw this on the table quickly for some feedback
http://koorb.co.uk/static/images/tglogos/layouts/blue-light-2.png



[TurboGears] Re: TurboGears new site look - let's get to it!

2006-01-05 Thread Ronald Jaramillo


Hi,
Short comments:
- The download box should left align with the 'Learn  fast column
- Green for the download is ok (kind of a convention this days), but  
orange will be better for

  the other links so they could play up to to the golden gear.
- What about a blue bar at the bottom repeating the top menu (and  
place for copyright notices and other legaleze)

- Search box
- Join mail list box
-(?) a rss icon for subscribing to planet TG (?)

Great work!
Cheers
Ronald

On Jan 5, 2006, at 11:34 PM, Richard (koorb) wrote:



Just going to throw this on the table quickly for some feedback
http://koorb.co.uk/static/images/tglogos/layouts/blue-light-2.png




Ronald Jaramillo
mail: ronald AT checkandshare DOT com
blog: http://www.checkandshare.com/blog





[TurboGears] Re: TurboGears new site look - let's get to it!

2006-01-05 Thread Jared Kuolt

I like most of it, except that green candy-looking Download Now
button makes the whole amalgamation remind me of KDE.

On 1/5/06, Richard (koorb) [EMAIL PROTECTED] wrote:

 Just going to throw this on the table quickly for some feedback
 http://koorb.co.uk/static/images/tglogos/layouts/blue-light-2.png




--
[EMAIL PROTECTED]


[TurboGears] Re: TurboGears new site look - let's get to it!

2006-01-05 Thread Michele Cella


Ronald Jaramillo wrote:
 Hi,
 Short comments:
 - The download box should left align with the 'Learn  fast column

 - Green for the download is ok (kind of a convention this days), but
 orange will be better for
the other links so they could play up to to the golden gear.
 - What about a blue bar at the bottom repeating the top menu (and
 place for copyright notices and other legaleze)
 - Search box
 - Join mail list box
 -(?) a rss icon for subscribing to planet TG (?)


Agreed, I really like the 1) 2) 3) slogan but I think we can find
better words for Run and Visit (Quickstart is ok)... by the way I don't
know what we can use! :P

Really great work!

Ciao
Michele



[TurboGears] Re: TurboGears new site look - let's get to it!

2006-01-05 Thread Karl Guertin

On 1/5/06, Richard (koorb) [EMAIL PROTECTED] wrote:
 Just going to throw this on the table quickly for some feedback
 http://koorb.co.uk/static/images/tglogos/layouts/blue-light-2.png

Excellent grid and hiearchy. The following are my nits, I don't expect
them to be mocked up, but please incorporate them when you're doing
the actual design:

Please center the layout, it feels unbalanced to me when flush left. I
venture that anybody visiting this site will have at least 1024
screens. I know that 800 is the current standard width because quite a
few people still run 800x600, but I would be very surprised if anybody
 interested in python web development were running a screen that
small. I'd say you can safely go up to 990px if you need the space
(which your layout really doesn't).

The line height on the body copy is too high and is breaking up the
text, please drop it to betweeen 1.2em and 1.3 em. The current spacing
is fine on the sidebars.

I'd like to see the download box changed:
+---+
| DOWNLOAD   || |
|\/-|
| Turbogears 0.8a6  |   - 1.3 em or so
| Released Dec 26, 2005 |   - .8 em or so, it should fit under the 'Turbogears'
|  * Validation Bugfixes|
|  * OtherFeatures  |
|  * OtherFeatures2 |
+---+

As you can see from my amazing ascii art drawing, I think you should
drop the 'now' so that it reads 'Download Turbogears 0.8a6'. The
bullets display the key features of the release. I feel the redundant
download and upgrade links at the bottom don't add anything and that
people know to click the download header or the product name to get
download or upgrade info.

Now to design a release page and a decent start page. ;]


[TurboGears] Re: TurboGears new site look - let's get to it!

2006-01-05 Thread Karl Guertin

On 1/5/06, Karl Guertin [EMAIL PROTECTED] wrote:
 Excellent grid and hiearchy. The following are my nits, I don't expect
 them to be mocked up, but please incorporate them when you're doing
 the actual design:

One last one -- and I know this is really out there and I think I'm
the only one that will be bothered by this:

I don't like that the gear is facing away from the page, makes me feel
like the web page is tense.


[TurboGears] devcasts - DataController

2006-01-05 Thread Helio MC Pereira
Hi all,

 Is there a way to control the access to FastData/Crud thru turbogears.identity???

 Something like:


class Root(controllers.RootController):
 @turbogears.expose(template=wgstock.templates.welcome)
 def index(self):
 import time
 return dict(now=time.ctime())

 class Admin(controllers.Controller):
 @identity.require( identity.in_group( admin ) )
 User = DataController(sql_class=TG_User)

 @identity.require( identity.in_group( admin ) )
 Group = DataController(sql_class=TG_Group)


Thanks,
Helio Pereira



[TurboGears] Re: TurboGears new site look - let's get to it!

2006-01-05 Thread Michele Cella

Michele Cella wrote:

 Agreed, I really like the 1) 2) 3) slogan but I think we can find
 better words for Run and Visit (Quickstart is ok)... by the way I don't
 know what we can use! :P

1) Quickstart
2) Run
3) Gear Up

!? Ok, time to sleep. :-)

Ciao
Michele



[TurboGears] Re: Problems installing pysqlite on Linux

2006-01-05 Thread Michael Schneider

Thank you very much.

I tried your trick, and I could not get it to go.

I bit the bullet, and did a static link against sqlite3, and that
worked.

I wish that I could get the dynamic lib going, but I am going to start
with this.

Thank you very much,
Mike



[TurboGears] Re: TurboStan 0.7

2006-01-05 Thread Cliff Wells


[EMAIL PROTECTED] wrote:

What python modules we need to install TurboStan?
  

TurboGears = 0.9
Nevow (I think Nevow may have a dependency on zope.interfaces)

Regardless, you should be able to use easy_install TurboStan and not 
worry about this too much.


Cliff


Nevow (zope ???)
turbogears

  




[TurboGears] Extending TG objects

2006-01-05 Thread Stephen Thorne


I'm having a bit of problem with inheritance.

Because of @turbogears.expose() I can't seem to be able to do this:

class MyClass(ParentClass):
@turbogears.expose(self, args):
def foo(self):
 d = super(MyClass, self).foo()
 d.update(dict(bar='baz'))
 return d

because of the double-decoration going on.

Is this kind of behaviour even possible? How do I access the original, 
pre-decorated method in the parent?

--
Regards,
Stephen Thorne
Development Engineer

Scanned by the NetBox from NetBox Blue
(http://netboxblue.com/)



[TurboGears] Re: Stripping 'submit' argument from validated form input inconsistent

2006-01-05 Thread Igor Murashkin

I agree. There is no reason for the submit button to have a name unless
it's given an explicit value that the back-end wants to track. Only in
that case should it be given a name (but then it should be sent to the
method as well).



[TurboGears] Re: how to recover from aborted transaction

2006-01-05 Thread [EMAIL PROTECTED]

Just out of curiosity why you want a transaction that affects only one
table?



[TurboGears] Re: Made a filter similar to variablesdecode()

2006-01-05 Thread Igor Murashkin

That's a good question. You could if you want, but I suppose that would
make javascript harder. document.form_name['var.name'][0] is slightly
better then document.form_name['var-1.name']. Plus, I haven't tried
NestedVariables in complement with @turbogears.expose. If you do it
like that, then there's no need to unpack your parameters, now is there?



[TurboGears] Re: Extending TG objects

2006-01-05 Thread Bob Ippolito


On Jan 5, 2006, at 4:17 PM, Stephen Thorne wrote:



I'm having a bit of problem with inheritance.

Because of @turbogears.expose() I can't seem to be able to do this:

class MyClass(ParentClass):
@turbogears.expose(self, args):
def foo(self):
 d = super(MyClass, self).foo()
 d.update(dict(bar='baz'))
 return d

because of the double-decoration going on.

Is this kind of behaviour even possible? How do I access the  
original, pre-decorated method in the parent?


That should work perfectly fine, given a correct turbogears.expose  
call of course.  How about you show a full example that doesn't work  
and also post the traceback?


-bob



[TurboGears] Re: Made a filter similar to variablesdecode()

2006-01-05 Thread Karl Guertin

On 1/5/06, Igor Murashkin [EMAIL PROTECTED] wrote:
 That's a good question. You could if you want, but I suppose that would
 make javascript harder. document.form_name['var.name'][0] is slightly
 better then document.form_name['var-1.name']. Plus, I haven't tried
 NestedVariables in complement with @turbogears.expose. If you do it
 like that, then there's no need to unpack your parameters, now is there?

I ask because I'm working on nested forms and I currently handle the
output using the decorator. I'd ideally like to make it so that you
didn't have to set NestedVariables as your validator so the container
validators would act like formencode Schema's chained_values.

It shows up on the form as:

foo.bar-0 : '1'
foo.bar-1 : '2'
foo.bar-2 : '3'
baz :'4'

which would turn into:
params = {
'foo':{bar:['1','2','3']},
'baz':'4'}

using the code snippet I supplied.


[TurboGears] Re: sqlwidgets

2006-01-05 Thread [EMAIL PROTECTED]

you have to be carefull on how automated the data is going in and out
of the DB, because that could lead to SQLinjection attacks.



[TurboGears] Re: Extending TG objects

2006-01-05 Thread Stephen Thorne


Bob Ippolito wrote:
That should work perfectly fine, given a correct turbogears.expose  call 
of course.  How about you show a full example that doesn't work  and 
also post the traceback?


This was a PEBKAC, sorry.
--
Regards,
Stephen Thorne
Development Engineer

Scanned by the NetBox from NetBox Blue
(http://netboxblue.com/)



[TurboGears] Re: Static Site question

2006-01-05 Thread [EMAIL PROTECTED]

I'm sorry I don't think I undestand well.

Do you mean generating a dinamic page and saving the output to a html
file so you could later on use that standalone?

if so it's should be really easy (i'm especulating but) I bet all you
have to do is intercept the file-like object that kid returns and dump
that to a file, which in python is a day in the park

I believe what you need is this
http://www.turbogears.org/docs/api/kid.serialization.Serializer-class.html#serialize

then dump that stream to a html file.



[TurboGears] customization of datacontroller messages and translation

2006-01-05 Thread Ksenia Marasanova

Hi,

I wonder what would be the preferred way to customize datacontroller
messages (things like Record deleted!)? Maybe all messages should go
to a class variable:

class DataController(BaseDataController):
messages = dict(
delete='Record deleted!',
add='Record added!',
.
)

Than we can use:

class News(DataController):
messages = dict(
delete='Newsitem is deleted',
add='Newsitem is added, don't forget to a href=/pages/link
ik to a page/a'
)

And the translation: it looks like turbogears internal modules don't
use i18n yet. Since datacontroller and complex widgets are the first
components exposed to the end user, it is probably a good idea not
to hardcode english strings in it. Oh, and maybe translations for
those components should be contributed as plugins / language packs
:) ?

--Ksenia


[TurboGears] Re: how to recover from aborted transaction

2006-01-05 Thread Soni Bergraj

 Just out of curiosity why you want a transaction that affects only one
 table?
Because of the concurrency of several web clients.

-- 
Soni Bergraj


[TurboGears] Re: customization of datacontroller messages and translation

2006-01-05 Thread Soni Bergraj

Hello,
is somebody aware of a way to get Cheetah templates working with 0.8.7?

I tried

http://trac.turbogears.org/turbogears/ticket/214

but the patch is rejected. Any ideas?


-- 
Soni Bergraj


[TurboGears] Getting Cheetah templates to work with 0.8.7?

2006-01-05 Thread Soni Bergraj

Sorry for the wrong subject of the previous message:)

Hello,
is somebody aware of a way to get Cheetah templates working with 0.8.7?

I tried

http://trac.turbogears.org/turbogears/ticket/214

but the patch is rejected. Any ideas?


--
Soni Bergraj


[TurboGears] Re: Getting Cheetah templates to work with 0.8.7?

2006-01-05 Thread Karl Guertin

On 1/5/06, Soni Bergraj [EMAIL PROTECTED] wrote:
 but the patch is rejected. Any ideas?

Move to SVN or wait a week or two for 0.9. Kevin has said that he
wants 1.0 by pycon, which is at the end of Feb, so that doesn't leave
too much time for two major point releases.


[TurboGears] [Test] Please ignore this

2006-01-05 Thread Anthoni Shogan


not getting mails from tg list since december 27.


[TurboGears] Re: Announcing Scaffolding - A CMS for Turbogears

2006-01-05 Thread Cliff Wells


Kevin Dangoor wrote:

Actually, I do think that both styles (application database,
integration database) have merit for certain apps. Here's where
application databases make some amount of sense:

1) newfangled, Web 2.0 applications and web services. Things like
Backpack (surprise, surprise!), where the application serves a
distinct purpose and lives out on the net. Data I/O is all done via
web requests that go through the application code, which ensures the
integrity of the data (to whatever extent it has been programmed to do
so).
  
As far as things like Basecamp go, at least part of the reason I'm not 
using it myself is because of this attitude about data integrity.  
Again, I think David is a brilliant guy, but that doesn't make up for 
the years of domain-specific experience and wide user-base available to 
the database developers.  Any problem at the application layer (which is 
where most problems seem to occur) can cause data integrity issues 
unless the database itself is enforcing those rules.  To be certain, I 
can understand his reluctance to use stored procedures and would even 
grant him that part of the argument.  But foreign keys?  Really.  Those 
belong in the database: they are *not* business logic nor are they as 
easily (or efficiently, I might add) enforced from outside the database.


If the app fails I can restart it.  If it takes my data with it, I've 
got problems.  If my company depends on project management software, it 
won't be written by a MySQL guy, no matter how smart he is.



2) small office applications. I did a lot of work on billing systems
for doctors offices. Those systems are (or, at least, were) quite
self-contained and the people in the office tended to use those apps
for everything and not be computer literate enough to do much outside
of there beyond word processing. (That's a generalization, certainly.)

  
I have almost the exact opposite experience.  The small office is where 
I've almost always found a mishmash of Access databases, Excel 
spreadsheets, etc, some of them sharing data, some not (and most poorly 
designed, because the people who designed them really should have stuck 
to word-processing).  When migrating these systems to a centralized 
system, there is always a large overlap where the centralized system 
starts taking over functionality but parts remain elsewhere until they 
are eventually brought into the fold.  I think David's argument falls 
apart there as well.  If it were always starting from scratch or there 
were a specific cut-over date, then I'd be more likely to agree, but 
I've rarely encountered that.  They always want the old system left 
intact just in case the new system has flaws, or they need some 
feature of the new system right away, etc, but the problem of data 
syncronization requires some integration of the existing infrastructure 
(or creation of infrastructure which brings stray applications into the 
fold during the migration period, which can often be months).



Now, these two points are what you mean by highly specific,
non-enterprise type of application, but I wanted to break it out more
and emphasize that there's *a lot* of this, and #1 is still a growing
category.
  
Absolutely.  Still, I'd wager that even these databases will one day 
outgrow this category.   Data outlives the app that created it, almost 
every single time.  These relationships need to be defined along with 
the data *in the database* if you are at all concerned about the poor 
sap who will have to one day retire your app or integrate it with other 
software.



The larger the organization, the more likely it is to move into the
integration database' category. A big organization *could* decide to
expose the database entirely via web services and use that layer to
maintain the database, or it could opt to move more into stored
procedures, triggers and the like to make the database engine do the
work. So, even within big organizations, there's still a choice to be
made that could enable the application database perspective.
  
Yes, but then so much for DRY ;-)   David's argument puts you in the 
position to choose between DRY and data integrity.  I don't think this 
choice needs to be made or should be made.   At least one friend of mine 
does just this.  He defines the constraints in both PostgreSQL and also 
in the Rails model.   Not a big deal in terms of a workaround, but not 
very DRY either.  If this were an insurmountable issue, I'd call it fair 
and move on.  Since it's not even remotely insurmountable, but rather 
just one guy's rather poorly thought-out opinion about where the line 
between business logic and relational logic lay, I'll pass ;-)


Regards,
Cliff




[TurboGears] Re: devcasts - DataController

2006-01-05 Thread Leandro Lucarella

Helio MC Pereira, el jueves  5 de enero a las 23:18 me escribiste:
 Hi all,
 
   Is there a way to control the access to FastData/Crud thru
 turbogears.identity???
 
   Something like:
 
 
 class Root(controllers.RootController):
 @turbogears.expose(template=wgstock.templates.welcome)
 def index(self):
 import time
 return dict(now=time.ctime())
 
 class Admin(controllers.Controller):
 @identity.require( identity.in_group( admin ) )
 User = DataController(sql_class=TG_User)
 
 @identity.require( identity.in_group( admin ) )
 Group = DataController(sql_class=TG_Group)
 

If this doesn't work this should do it:

class UserDataController(DataController, identity.SecureResource):
sql_class = TG_User
require = identity.in_group(admin)

class Root(controllers.RootController):
# ...

class Admin(controllers.Controller):
user = UserDataController()


(untested!)

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
 .,
  \  GPG: 5F5A8D05 // F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05 /
   ''
Me encanta el éxito; por eso prefiero el estado de progreso constante,
con la meta al frente y no atrás.
-- Ricardo Vaporeso. Punta del Este, Enero de 1918.


[TurboGears] Re: customization of datacontroller messages and translation

2006-01-05 Thread Leandro Lucarella

Ksenia Marasanova, el viernes  6 de enero a las 02:20 me escribiste:
 
 Hi,
 
 I wonder what would be the preferred way to customize datacontroller
 messages (things like Record deleted!)? Maybe all messages should go
 to a class variable:

I gess messages in DataController just have to user _() to be
internationalized... On the other hand, maybe some people just want to use
a different message, in which case the dictionary stuff can be a good
idea.

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
 .,
  \  GPG: 5F5A8D05 // F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05 /
   ''
Damian_Des Me anDa MaL eL CaPSLoCK


[TurboGears] Re: sqlwidgets

2006-01-05 Thread Randall

Understood, but at what level is input checked?  Traditionally, I
always used the parameter feature of database drivers, which is a good
way to prevent injection.  I believe the best place to check for sql
injection is at the db api level.  Also, the field validators,
FormEncode, act as another barrier.

The reason I'm focusing on building forms from the data objects is the
Don't Repeat Yourself principle.  It's better to define logic or data
only once in your application.  I've been writing web apps long enough
to become sick of defining a database field as NOT NULL, wiriting
server side logic to enforce NOT NULL, then writing javascript to check
a field is NOT NULL.  After seeing this pattern too frequently, it's
time for something better.



[TurboGears] Re: Made a filter similar to variablesdecode()

2006-01-05 Thread Igor Murashkin

Hey Karl, you can do that too, I made this filter earlier, and with
your example you would pass almost the same values as you have there:

foo.bar: '1'
foo.bar: '2'
foo.bar: '3'
baz : '4'

result = { 'foo' : {'bar' : ['1', '2', '3']}, 'baz' : '4'} }

Although I'm not as sure as to how you would make a validation schema
for that as easily, but once again it will be easy to access the values
in javascript with a documents.my_form['foo.bar'][0], [1], [2], etc.

### Code below
##

class BuildTreeFilter(BaseFilter):

Will build a tree for request params with periods in the name,
for an example look at _buildTree().


def beforeMain(self):
cherrypy.request.paramMap =
self._buildTree(cherrypy.request.paramMap)

def _buildTree(self, oldDict):

Given a dictionary with keys like 'foo.bar.joo', this will
return a new tree
with a key of foo = { 'bar': {'joo' : oldValue}}, for every
key.

Example:
 print _buildTree({'company': 'Unexistential Inc',
 'names.firstName': ['Joe', 'Boe', 'Moe'],
 'names.lastName': ['Smith', 'Myth',
'Keith'],
 'phone': '555-8980'})
 {'company': 'Unexistential Inc',
 'names': {'firstName': ['Joe', 'Boe', 'Moe'],
   'lastName': ['Smith', 'Myth', 'Keith']},
 'phone': '555-8980'}


stack = []
y = {}
for key, value in oldDict.iteritems():
splitList = key.split(., 1)
if len(splitList)  1: #there was a period in the key
firstLevel = splitList[0]
secondLevel = splitList[1]
firstValue = y.get(firstLevel)

if firstValue:
if type(firstValue) != dict:
y[firstLevel] = {}
y[firstLevel].update({secondLevel : value})
else:
y[firstLevel] = {secondLevel : value}
stack.append( firstLevel ) #add to stack only once
else:
y[key] = value

for i in iter(stack):
y[i] = self._buildTree( y[i] )

return y



[TurboGears] Rewriting static URLs to serve them dynamically

2006-01-05 Thread Clank

Newbie-Q. I have a gaggle of URLs of form

/archive/number.html

I want to update  serve their content dynamically; it's obvious how to
get almost-there with URLs like

/archive/?number=number

but I want the old URLs to work.

It's a MovableType site, so there are probably other people with my
problem. Is there a plausible answer in TG, or do I need to (say) run
behind Apache and use mod_rewrite on those URLs?



[TurboGears] Re: Rewriting static URLs to serve them dynamically

2006-01-05 Thread Robin Munn
On 1/6/06, Clank [EMAIL PROTECTED] wrote:

 Newbie-Q. I have a gaggle of URLs of form

 /archive/number.html

 I want to update  serve their content dynamically; it's obvious how to
 get almost-there with URLs like

 /archive/?number=number

 but I want the old URLs to work.

 It's a MovableType site, so there are probably other people with my
 problem. Is there a plausible answer in TG, or do I need to (say) run
 behind Apache and use mod_rewrite on those URLs?

What you want is to expose a default() method. Take a look at page 4
of the 20-minute Wiki tutorial, on
http://www.turbogears.org/docs/wiki20/page4.html, for an example. Have
/archive point at a class that looks something like the following:

class ArchiveByNumber(object):
@turbogears.expose(html=...)
def default(self, number):
if number.endswith('.html'):
number = number[:-5]
if number.endswith('.htm'):
number = number[:-4]
number = int(number)  # In actual code, you'd use a validator here
# Fetch the appropriate page from the database

The default() method will take any remaining URL components and
receive them as arguments. If you had, for example:

class Archive(object):
@turbogears.expose(html=...)
def default(self, *args):
logDebug(Received args %s..., args)

And your user fetched the URL /archive/2004/11/30/my-blog-post.htm,
your function would log Received args ('2004', '11', '30',
'my-blog-post.htm')...

I hope this helps.

--
Robin Munn
[EMAIL PROTECTED]
GPG key 0xD6497014