[turbogears-commits] [1993] branches/1.0/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl: put Gzip Compressing Content in template (commented)
Title: [1993] branches/1.0/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl: put Gzip Compressing Content in template (commented) Revision 1993 Author fredlin Date 2006-10-19 02:14:12 -0400 (Thu, 19 Oct 2006) Log Message put Gzip Compressing Content in template (commented) http://trac.turbogears.org/turbogears/wiki/GzipCompressing Modified Paths branches/1.0/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl Diff Modified: branches/1.0/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl (1992 => 1993) --- branches/1.0/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl 2006-10-19 02:43:20 UTC (rev 1992) +++ branches/1.0/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl 2006-10-19 06:14:12 UTC (rev 1993) @@ -150,6 +150,12 @@ # identity.saprovider.encryption_algorithm=None #end if #end if + +# compress the data sends to the web browser +# [/] +# gzip_filter.on = True +# gzip_filter.mime_types = [application/x-_javascript_, text/_javascript_, text/html, text/css, text/plain] + [/static] static_filter.on = True static_filter.dir = %(top_level_dir)s/static --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Repository Commits group. To post to this group, send email to turbogears-commits@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-commits -~--~~~~--~~--~--~---
[turbogears-commits] [1994] trunk/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl: merge [1993] from 1.0
Title: [1994] trunk/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl: merge [1993] from 1.0 Revision 1994 Author fredlin Date 2006-10-19 02:16:52 -0400 (Thu, 19 Oct 2006) Log Message merge [1993] from 1.0 Modified Paths trunk/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl Diff Modified: trunk/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl (1993 => 1994) --- trunk/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl 2006-10-19 06:14:12 UTC (rev 1993) +++ trunk/turbogears/qstemplates/quickstart/+package+/config/app.cfg_tmpl 2006-10-19 06:16:52 UTC (rev 1994) @@ -154,6 +154,12 @@ # identity.saprovider.encryption_algorithm=None #end if #end if + +# compress the data sends to the web browser +# [/] +# gzip_filter.on = True +# gzip_filter.mime_types = [application/x-_javascript_, text/_javascript_, text/html, text/css, text/plain] + [/static] static_filter.on = True static_filter.dir = %(top_level_dir)s/static --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Repository Commits group. To post to this group, send email to turbogears-commits@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-commits -~--~~~~--~~--~--~---
[turbogears-commits] [1995] branches/1.0/turbogears/qstemplates/quickstartbig/+package+/controlle rs/root.py_tmpl: port controller.py modification to tgbig root.py template
Title: [1995] branches/1.0/turbogears/qstemplates/quickstartbig/+package+/controllers/root.py_tmpl: port controller.py modification to tgbig root.py template Revision 1995 Author fredlin Date 2006-10-19 03:12:50 -0400 (Thu, 19 Oct 2006) Log Message port controller.py modification to tgbig root.py template Modified Paths branches/1.0/turbogears/qstemplates/quickstartbig/+package+/controllers/root.py_tmpl Diff Modified: branches/1.0/turbogears/qstemplates/quickstartbig/+package+/controllers/root.py_tmpl (1994 => 1995) --- branches/1.0/turbogears/qstemplates/quickstartbig/+package+/controllers/root.py_tmpl 2006-10-19 06:16:52 UTC (rev 1994) +++ branches/1.0/turbogears/qstemplates/quickstartbig/+package+/controllers/root.py_tmpl 2006-10-19 07:12:50 UTC (rev 1995) @@ -1,25 +1,21 @@ -import logging - -import cherrypy - -import turbogears -from turbogears import controllers, expose, validate, redirect +from turbogears import controllers, expose +# from ${package} import model #if $identity != none -from turbogears import identity +from turbogears import identity, redirect +from cherrypy import request, response +from ${package} import json #end if -#if $sqlalchemy == True -from turbogears.database import session -#end if +# import logging +# log = logging.getLogger(${package}.controllers) -from ${package} import json - -log = logging.getLogger(${package}.controllers) - class Root(controllers.RootController): ${b}expose(template=${package}.templates.welcome)${e} +#if $identity != none +# ${b}identity.require(identity.in_group(admin))${e} +#end if def index(self): import time -log.debug(Happy TurboGears Controller Responding For Duty) +# log.debug(Happy TurboGears Controller Responding For Duty) return dict(now=time.ctime()) #if $identity != none @@ -32,7 +28,7 @@ raise redirect(forward_url) forward_url=None -previous_url= cherrypy.request.path +previous_url= request.path if identity.was_login_attempted(): msg=_(The credentials you supplied were not correct or @@ -42,10 +38,11 @@ this resource.) else: msg=_(Please log in.) -forward_url= cherrypy.request.headers.get(Referer, /) -cherrypy.response.status=403 +forward_url= request.headers.get(Referer, /) + +response.status=403 return dict(message=msg, previous_url=previous_url, logging_in=True, -original_parameters=cherrypy.request.params, +original_parameters=request.params, forward_url=forward_url) ${b}expose()${e} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Repository Commits group. To post to this group, send email to turbogears-commits@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-commits -~--~~~~--~~--~--~---
[tg-tickets] [TurboGears] #1152: [PATCH] allow SO Visit to use user-defined class
#1152: [PATCH] allow SO Visit to use user-defined class --+- Reporter: grover| Owner: anonymous Type: defect| Status: new Priority: normal| Milestone: 1.0b2 Component: Identity | Version: 1.0b1 Severity: normal|Keywords: --+- SA/SO identity already have this, as does SA visit. SO visit lets you load a class but then doesn't use it? Here's the missing code needed for SO visit. -- Ticket URL: http://trac.turbogears.org/turbogears/ticket/1152 TurboGears http://www.turbogears.org/ TurboGears front-to-back web development --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears Tickets group. To post to this group, send email to turbogears-tickets@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears-tickets -~--~~~~--~~--~--~---
[TurboGears] Re: SQLObject and forms
On 10/18/06, Gregor Horvath [EMAIL PROTECTED] def dict_to_attr(dict_, object_): valid_attributes = object_.sqlmeta.columns.keys() for attr, value in dict_.iteritems(): if attr in valid_attributes: setattr(object_, attr, value) Ah, that works well! Thanks -- Andy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Turbogears on Media Temple grid hosting
On 19/10/06, Sanjay [EMAIL PROTECTED] wrote: Also, the faq encourages people interested in running Django and TG to get in touch with them so you might want to do that if you find this grid stuff interesting. I could not find this in the FAQ. A link or some guidence would help. Bottom of this page: http://www.mediatemple.net/webhosting/gs/faq/lamp_stack-faq.htm Ed --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: SQLObject and forms
On Oct 18, 10:10 pm, Gregor Horvath [EMAIL PROTECTED] wrote: def dict_to_attr(dict_, object_): valid_attributes = object_.sqlmeta.columns.keys() for attr, value in dict_.iteritems(): if attr in valid_attributes: setattr(object_, attr, value) This saves me a lot of work, but how do I get the type? I still need to cast for my IntCols. Can I just get the column value from the object and check it's type? Like this: --- def dict_to_attr(dict_, object_): valid_attributes = object_.sqlmeta.columns.keys() for attr, value in dict_.iteritems(): if attr in valid_attributes: colCheck = getattr(object_, attr)# get the column-value if( type(colCheck) == int ): # check it's type type = int(type)# 'cast' it setattr(object_, attr, value) -- Hm, I really need to setup a test-model so I don't have to try testing this trough TurboGears. Tor --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Unicode Error with MySQL... :\
Jorge Vargas wrote: On 10/18/06, core [EMAIL PROTECTED] wrote: /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/mysql/mysqlconnection.py, line 73, in _executeRetry myquery = unicode(query, self.encoding) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 71: ordinal not in range(128) This is an issue with mysql's default encoding. please check out your ubuntu's my.cfg file for default encoding which is what mysqldb uses when you don't pass in anything (which is SO's default) I added the charset options on my.cnf but still no game. A \s on the mysql console shows that it is, indeed, using utf: Server characterset:utf8 Db characterset:utf8 But adding accented characters on turbogears still returning the ascii codec error. I tried to put '?use_unicode=1' on the connection string but nah. Too bad I can't afford to run 2 db's on the same server, I think that maybe postgres would be simpler with those encoding matters. []s --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] What's @expose?
I see lots of this @expose thing in the TurboGear tutorial. Is this a Python 2.4 feature? I try to google for it and don't seem to come up with specific hit.. Does that mean using 2.3 is out of the question? I am not using 2.4 yet because there are still issues using my ap under 2.4. Thanks, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] toolbox is not started in TurboGears
Hi! toolbox (Catwalk) is not started in TurboGears code: class User(SQLObject): Reasonably basic User definition. Probably would want additional attributes. # names like Group, Order and User are reserved words in SQL # so we set the name to something safe for SQL class sqlmeta: table=tg_user user_name = UnicodeCol(length=16, alternateID=True, alternateMethodName=by_user_name) email_address = UnicodeCol(length=255, alternateID=True, alternateMethodName=by_email_address) display_name = UnicodeCol(length=255) password = UnicodeCol(length=40) created = DateTimeCol(default=datetime.now) ip = UnicodeCol() mac = UnicodeCol() # groups this user belongs to groups = RelatedJoin(Group, intermediateTable=user_group, joinColumn=user_id, otherColumn=group_id) def _get_permissions(self): perms = set() for g in self.groups: perms = perms | set(g.permissions) return perms def _set_password(self, cleartext_password): Runs cleartext_password through the hash algorithm before saving. hash = identity.encrypt_password(cleartext_password) self._SO_set_password(hash) def set_password_raw(self, password): Saves the password as-is to the database. self._SO_set_password(password) error: Traceback (most recent call last): File /usr/local/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py, line 103, in _run applyFilters('before_main') File /usr/local/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/filters/__init__.py, line 151, in applyFilters method() File /usr/local/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/visit/api.py, line 154, in before_main plugin.record_request( visit ) File /usr/local/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/identity/visitor.py, line 170, in record_request set_current_identity( identity ) File /usr/local/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/identity/__init__.py, line 105, in set_current_identity cherrypy.request.user_name = identity.user_name File /usr/local/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/identity/soprovider.py, line 91, in _get_user_name if not self.user: File /usr/local/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/identity/soprovider.py, line 82, in _get_user self._user= user_class.get( visit.user_id ) File /usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/inheritance/__init__.py, line 161, in get val = super(InheritableSQLObject, cls).get(id, connection, selectResults) File /usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/main.py, line 912, in get val._init(id, connection, selectResults) File /usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/main.py, line 955, in _init selectResults = self._connection._SO_selectOne(self, dbNames) File /usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py, line 576, in _SO_selectOne return self.queryOne( File /usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py, line 760, in queryOne return self._dbConnection._queryOne(self._connection, s) File /usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py, line 342, in _queryOne self._executeRetry(conn, c, s) File /usr/local/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/dbconnection.py, line 298, in _executeRetry return cursor.execute(query) ProgrammingError: ERROR: column child_name does not exist SELECT child_name, user_name, email_address, display_name, password, created FROM tg_user WHERE id = (4) TurboGears 1.0b1 + OpenBSD 3.9 + PostgreSQL TurboGears Version Info * TurboGears 1.0b1 * nose 0.9.0 * configobj 4.3.2 * RuleDispatch 0.5a0.dev-r2115 * setuptools 0.6c3 * FormEncode 0.5.1 * cElementTree 1.0.5-20051216 * PasteScript 0.9.7 * elementtree 1.2.6 * simplejson 1.3 * SQLObject 0.7.1dev-r1860 * CherryPy 2.2.1 * TurboKid 0.9.8 * TurboCheetah 0.9.5 * TurboJson 0.9.9 * PyProtocols 1.0a0 * Cheetah 1.0 * PasteDeploy 0.9.6 * Paste 0.9.7 * FormEncode 0.5.1 * kid 0.9.3 * Cheetah 1.0 * elementtree 1.2.6 Installed Plugins Identity Providers * sqlobject (TurboGears 1.0b1) * sqlalchemy (TurboGears 1.0b1) tg-admin Commands * info (TurboGears 1.0b1) * shell (TurboGears 1.0b1) * quickstart (TurboGears 1.0b1) * update (TurboGears 1.0b1) * sql (TurboGears 1.0b1) * i18n (TurboGears 1.0b1) * toolbox (TurboGears 1.0b1) Visit Managers *
[TurboGears] Re: What's @expose?
@expose is a Python decorator: http://soiland.no/software/decorator They were introduced in Python 2.4 You can probably synthesise an equivalent in your controllers, as per the above URL. I don't know what else (internally) in TG uses decorators, however. 2.4 might be required. Stuart On Wed, 2006-10-18 at 16:43 -0700, John Henry wrote: I see lots of this @expose thing in the TurboGear tutorial. Is this a Python 2.4 feature? I try to google for it and don't seem to come up with specific hit.. Does that mean using 2.3 is out of the question? I am not using 2.4 yet because there are still issues using my ap under 2.4. Thanks, -- Stuart Clarke [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
John Henry wrote: I see lots of this @expose thing in the TurboGear tutorial. Is this a Python 2.4 feature? It's a decorator. The syntactic sugar for decorators is a Python 2.4 feature, but decorators by themselves are not. The 2.4 syntax is: @decorator def decorated(args): do_something and is just a shortcut for def decorated(args): do_something decorated = decorator(decorated) The decorator itself is any callable taking a callable as argument and returning a callable. The builtin types classmethod and staticmethod are decorators. I try to google for it and don't seem to come up with specific hit.. http://www.google.com/search?q=%2Bpython+%2B%40decorator gives me =~ 619 000 answers... Does that mean using 2.3 is out of the question? I don't know if TG runs on 2.3.x, but as far as decorators are concerned, you can just use the 'explicit' syntax instead: class MyController(...): def my_action(...): ... my_action = expose(my_action) -- bruno desthuilliers développeur [EMAIL PROTECTED] http://www.modulix.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Identity Testing
I'm having some problems with a test case I'm trying to write, and I can't figure out why it is failing. It appears that identity isn't initializing, but identity works properly in other test cases, and I was hoping someone might have some ideas as to why. Some pertinent system info: Turbogears svn 0.9a9dev-r1953 SqlAlchemy 0.2.8 Here is what I hope is pertinent: database.set_db_uri('sqlite:///:memory:', 'sqlalchemy') session = database.session config.update({'global': { 'identity.provider': '${identity}', 'visit.saprovider.model':'${package}.model.Visit', 'identity.saprovider.model.user':${package}.model.User, 'identity.saprovider.model.group':${package}.model.Group, 'identity.saprovider.model.permission':${package}.model.Permission, 'identity.saprovider.model.visit':${package}.model.VisitIdentity }}) class TestRegistration(unittest.TestCase, SharedMethods): def setUp(self): database.create_session() self.create_identity_tables() register_model.create_registration_tables() cherrypy.root = None cherrypy.tree.mount_points = {} cherrypy.tree.mount(RegTestController(), '/') config.update({'global':{'registration.verified_user.groups':[], 'registration.unverified_user.groups':[] } }) def tearDown(self): database.rollback_all() self.drop_identity_tables() self.drop_registration_tables() #testutil.sqlalchemy_cleanup() startup.stopTurboGears() # This test passes... def test_new_registration(self): A new pending user is created. self.create_pending_user_by_request() self.assert_ok_response() assert getattr(cherrypy.request, 'identity', None) pend = RegistrationPendingUser.get_by_email_address(test_email) assert(pend.user_name=='dschrute') assert(register_model.user_class_finder.user_class.select().count('*')==0) #This test fails def test_pending_user_groups(self): A unvalidated user is made a real user in the unvalidated group(s). # create the group g_visit = model.Group(group_name='dojo_visitors', display_name='Visitors to the dojo') g_member = model.Group(group_name='dojo_members', display_name='Members of the dojo') config.update({'global':{'registration.unverified_user.groups':['dojo_visitors'], 'registration.verified_user.groups':['dojo_members']}}) session.flush([g_visit, g_member]) assert session.query(model.Group).count()==2 self.create_pending_user_by_request() assert getattr(cherrypy.request, 'identity', None) #Fails with this assertion class SharedMethods(object): Container for methods that can be shared in SQLAlchemy and SQLObject test cases. def create_pending_user_by_request(self): req_str = ''.join(['/register/create?user_name=%semail=%semail2=%s', 'display_name=%spassword1=%spassword2=%s']) % \ ('dschrute', test_email, test_email, 'Dwight+Schrute', 'secret', 'secret') testutil.createRequest(req_str) def assert_ok_response(self): if cherrypy.response.status != '200 OK': raise AssertionError, cherrypy.response.body[0] As I read the code, it appears that the call to testutil.createRequest should handle starting turbogears and starting all the extensions. So, I'm not sure what I am missing. If anyone has any ideas, it would be very useful. I've been looking at this for too long. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: order_by ASC|DESC
On 10/19/06, jose [EMAIL PROTECTED] wrote: NameError: global name 'asc' is not defined I wonder in which module asc is... That would be in the sqlalchemy module. At the top of your controller: from sqlalchemy import asc, desc, and_, or_ This is my standard sqlalchemy import in a controller module. You may need others depending on your code. Lee -- Lee McFadden blog: http://www.splee.co.uk work: http://fireflisystems.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: SQLObject and forms
On Oct 19, 11:34 am, Gregor Horvath [EMAIL PROTECTED] wrote: The type is already correct when the dict comes to this function, because I am working with FormEncode and this converts the dict values to the correct types. FormEncode and Validators seems to be last piece to the puzzle :) I was basically creating the validator.Schema object manually, and using my own homegrown way of validating input. This makes everything a lot easier(I hope). Thanks :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Identity Testing
Sorry, that code got really mangled. I will post a more readable link later. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: order_by ASC|DESC
Lee McFadden wrote: On 10/19/06, jose [EMAIL PROTECTED] wrote: NameError: global name 'asc' is not defined I wonder in which module asc is... That would be in the sqlalchemy module. At the top of your controller: from sqlalchemy import asc, desc, and_, or_ This is my standard sqlalchemy import in a controller module. You may need others depending on your code. Lee thank you Lee. jo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
On 10/19/06, Bruno Desthuilliers [EMAIL PROTECTED] wrote: John Henry wrote: I see lots of this @expose thing in the TurboGear tutorial. Is this a Python 2.4 feature? It's a decorator. The syntactic sugar for decorators is a Python 2.4 feature, but decorators by themselves are not. There is a way to make all of this work with 2.3, and TurboGears has tried to maintain 2.3 compatibility, so you shouldn't have to update your Python just to use TurboGears. As Bruno mentioned: @expose() def myFunction(): return hi Is the equivelent of: def myFunction(): return Hi myFunction=expose(myFunction) That's not really pretty, so TurboGears provides Python 2.3 users with a trick that allows you to use the following syntax: [expose()] def some_method(self, someval): return Hi The preceding code works in both Python 2.3 and 2.4, so you can write code that works on both versions of Python. --Mark Ramm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
On 10/19/06, Mark Ramm [EMAIL PROTECTED] wrote: [expose()] def some_method(self, someval): return Hi Is this hack documented anywhere? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: old field value reappears
A further test, if I shut down and restart the server, everything works fine. I only get the problem with reload after changing a record after retrieving it through its 'id' field. I will do further tests when I have a minute... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
I try to google for it and don't seem to come up with specific hit.. http://www.google.com/search?q=%2Bpython+%2B%40decorator I didn't know @expose is a decorator. I search for Python @expose and came up with zillion of links talking about expose. :=) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
Karl Guertin wrote: [expose()] def some_method(self, someval): return Hi Is this hack documented anywhere? It comes from PEAK: http://trac.turbogears.org/turbogears/ticket/728 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
Mmmmmy brain is thick this morning. You said: @expose() def myFunction(): return hi Is the equivelent of: def myFunction(): return Hi myFunction=expose(myFunction) So expose is an imported function from TurboGear? So, this is just a way to setup a call back function? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
Now that I know what it is, I took a closer look at the controller.py created by TurboGear under Python 2.3, I see that the code created is: class Root(controllers.RootController): [expose(template=wiki20.templates.welcome)] def index(self): import time log.debug(Happy TurboGears Controller Responding For Duty) return dict(now=time.ctime()) May be they should update the tutorial to indicate that. My understanding is that lots of enterprises are still using Python 2.3 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
On 10/19/06, John Henry [EMAIL PROTECTED] wrote: So expose is an imported function from TurboGear? So, this is just a way to setup a call back function? Expose is an imported decorator from turbogears -- specifically, turbogears.controllers.expose(). It's not really a callback*, it's a wrapper around the underlying function. Basically, CherryPy wants a particular method** to have an ``exposed`` attribute set to True in order to ensure only the desired parts of your API are exposed to the web. The original expose() decorator in CherryPy simply set this attribute and called the wrapped function. The TurboGears version adds a number of bells and whistles like template handling, but otherwise it basically does the same thing * I think of a callback as something you register to be called when a certain event happens so you can respond to an event. You could argue the same thing is happening here, but I differentiate because the motivation in callbacks vs wrapping is different. ** Remember that functions/methods in python are objects, so they can have their own attributes, methods, etc. Similarly, objects can be made to be function-like, or callable, by defining __call__() in the class. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
@expose() def myFunction(): return hi Is the equivelent of: def myFunction(): return Hi myFunction=expose(myFunction) So expose is an imported function from TurboGear? So, this is just a way to setup a call back function? *** Yes, it is imported. More like a way to set up a behind-the-scenes wrapper function. Stuart --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
On 10/19/06, John Henry [EMAIL PROTECTED] wrote: May be they should update the tutorial to indicate that. My understanding is that lots of enterprises are still using Python 2.3 The 20 minute wiki tutorial needs a fairly comprehensive overhaul. It really hasn't been rewritten since TurboGears 0.5 just over a year ago and a lot of the TurboGears best practices have changed. I've been letting the wiki percolate for a few weeks so that I can find where people are having problems and because I burned myself out on the initial migration/population. I plan on going through the whole thing again within the next week. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
John Henry wrote: Mmmmmy brain is thick this morning. You said: @expose() def myFunction(): return hi Is the equivelent of: def myFunction(): return Hi myFunction=expose(myFunction) So expose is an imported function from TurboGear? Function, class, any callable. So, this is just a way to setup a call back function? Not quite. It can be used to add attributes to a function, wrap it into another function (or in a callable descriptor object FWIW, cf classmethod and staticmethod), or even replace the function with a totally different object (that sounds kind of crazy, but there are still possible use case - like replacing some method with a no-op according to a global flag...) You should find relevant informations on python.org. -- bruno desthuilliers développeur [EMAIL PROTECTED] http://www.modulix.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Integration of globalization data in Django/TurboGears
I have created several tables in CSV format with globalization data (G11n). There are tables for countries, areas, languages, countries languages, time zones, phones. And they are licensed under a Creative Commons license. http://svn.webda.python-hosting.com/trunk/G11n_data/ I created a new discussion group in order to facilitate the integration of G11n data in any framework. It's focused on integrate it on Django and TurboGears, but it could be integrated in whatever application with the help of the discussions on this group. It's necessary to discuss several subjects before beginning with the integration in the web frameworks. So I ask your collaboration. Thanks! http://groups.google.com/group/webda P.S.: I hope that you don't see this post as SPAM. This is something very interesting for administrators and users of those web frameworks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
Well, since I just went through the whole thing - as a newbie, I suppose I can comment on this. The one confusing thing to a newbie like myself is not knowing which file and which directory the tutorial is talking about. Many a times, I found myself at a total lost simply because I don't know which file (and where) I am suppose to do certain things to. Other than that, I think the whole approach was pretty good. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Current Best Practices for SQLAlchemy in TG?
I have just completed going through the wiki-20 tutorial, making the necessary changes to use SQLAlchemy. But I don't like the feel of the final product. It feels like I'm having to force all database interaction. I found several very informative pages by searching google and the TG-groups archives, but I didn't find anything that I would call definitive. Can someone post a link to a good example of the current best practices for using SA with TG? A few of the issues I ran into: -My goal with TG is to write a new front-end to existing databases. autoload=True is a requirement. -My tables have string columns, but TG tries to write unicode data into them. I had to add extra str()'s every time I'm sending something to the database. -Is there any way to auto save/commit? All of the SA docs I have seen say that I need to force it with session.save and session.flush -As my database is already defined, I don't see any advantages to ActiveMapper. Am I wrong? John Lavoie --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] To TG or not TG?
I am looking for advise on how to do this. I have a Python application which creates a hyperlinked set of Excel spreadsheets, and Word documents. The entire set is stored on a CD and I distribute the CD to client. When they load the CD, out pops a introductory Powerpoint slide and they hyperlink their way throughout the CD. Works very well. The problem is that the CD needs to be physically distributed (I don't have the bandwidth for the client to receive the CD electronically - and even if they do, I can't trust them to go and burn the CD correctly). Besides, I can only fit 600 to 700 M of files on a CD - and some of the projects I am working on is starting to stress a regular DVD. So, I am thinking of doing this as a web application. They only need to look at things they are interested in, and no need to wait for the CD to arrive. Not being a full fledge web programmer, I find all these talks about framework, Zope, Plone, Twisted, TurboGears, CherryPy, Pylons, Myghty, Django, (plus 13 million other terms I am seeing on the web) very intimitating. I don't expect that there will ever be 1 million hits to my tiny web site - just a handful from my clients. They log-on, and hyperlink their way of seeing what's on the CD. Obviously, I have to do something before this can happen - they can't be running Office over the web as they would on their local computer. So, to all you experts, what's the simplist way to go about doing this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: To TG or not TG?
I guess you'd take word and excel out of the picture and instead generate database tables (or objects) and format your text with something like markdown or textile. Once you've done all that (I suspect that's going to be the hard part), TG would be a fine way to put that online. It will take a lot of work no matter how you do it, but it sounds feasible, and TG will save you a lot of time. -i --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Current Best Practices for SQLAlchemy in TG?
On 10/19/06, John Lavoie [EMAIL PROTECTED] wrote: Can someone post a link to a good example of the current best practices for using SA with TG? Using SA in TG is caveat developer, it's not officially supported, so there isn't much in the way of docs. The current thinking on SA is on the docs wiki[1]. All other docs are most likely out of date and incorrect. This holds for most other types of docs. I'm working to ensure that everything on docs.turbogears.org is correct for 1.0, but I'm not 100% sure that everybody is checking the validity of the docs they're converting. [1] http://docs.turbogears.org/1.0/SQLAlchemy A few of the issues I ran into: -My goal with TG is to write a new front-end to existing databases. autoload=True is a requirement. -My tables have string columns, but TG tries to write unicode data into them. I had to add extra str()'s every time I'm sending something to the database. All my development has been strictly EN-us, so ignorance is bliss. I'm pretty sure SA works in unicode internally and the default output encoding is utf-8. You can try setting the encoding option when creating your engine or creating a custom type that does the str() wrapping. -Is there any way to auto save/commit? All of the SA docs I have seen say that I need to force it with session.save and session.flush TG has had automatic transactions in SA for months. Don't believe what you read on the trac wiki. -As my database is already defined, I don't see any advantages to ActiveMapper. Am I wrong? I prefer not using activemapper in general. It doesn't really have a maintainer and doesn't support some of the more advanced relation options, namely primaryjoin/secondaryjoin. Others seem to have no problems with it. I use the assign_mapper method mentioned on the wiki. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: To TG or not TG?
On 10/19/06, John Henry [EMAIL PROTECTED] wrote: So, to all you experts, what's the simplist way to go about doing this? I'm not sure what you want to get out of putting your app on the web. It seems like you're using the various office apps as a pseudo-web site but you don't mention to what end. If you're trying to just put some sort of index of office docs on the web, you can do that in just about anything and I'd actually recommend PHP because it's simple and available on commodity hosting. Just search through the manual to find the function that does what you want and call it. If you're trying to migrate a larger portion of your functionality onto a web site, *don't* use PHP. PHP sucks for app development. I personally like TurboGears and Django. Which I use for a particular project depends on how much I can get out of Django's automatic admin interface. I use Django for stuff that looks more like an online newspaper/blog and TurboGears for stuff where I'm doing a lot of forms processing or working off a legacy db or heavy json calling. I'd possibly consider Pylons as well but I'm happy with the TG/Django pair. I avoid the Zope/Plone due to the developer learning curve (sorry zopistas) and the rest of the packages you've listed are pieces rather than a whole solution. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: To TG or not TG?
I am looking at doing project management over the web down the road (like things you do withwww.basecamp.com). So, if all of the information on these CDs becomes available directly over the web, I can see that it would become big help in improving collaboration among various participants. Oops. Not http://www.basecamp.com/, http://www.basecamphq.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Current Best Practices for SQLAlchemy in TG?
John Lavoie wrote: -As my database is already defined, I don't see any advantages to ActiveMapper. Am I wrong? If you are working against an existing database, and just autoloading, then ActiveMapper doesn't make any sense for you to use, and offers you no advantage over straight SQLAlchemy. I largely wrote ActiveMapper just to support a more SQLObject-like pattern of defining your model. Its been a successful experiment, in my mind, and I use it in several projects today. There are plenty of circumstances in which its a useful way to do things, but a lot of situations where it doesn't really fit. Also, as Karl said, I haven't really had the time to maintain the project to my liking. That being said, I find it fairly comparable to SQLObject already, and am actively looking for people to help enhance ActiveMapper. -- Jonathan LaCour http://cleverdevil.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] TurboGears b1 psycopg error
All, I'm very new to TurboGears, and I was trying this tutorial: http://aymanh.com/turbogears-tutorial-social-bookmarking-application. I was able to work though the Wiki20 tutorial, but received this error with the code from this tutorial(see code below). I'm sure I've overlooked something, and would like someone to take a quick look at this and point me in the right direction. I'm using python 2.4, psycopg 1.1.21, postgresql 8.1, and TurboGears b1. Thanks! --Nick snip part of error psycopg.ProgrammingError: ERROR: relation tg_user does not exist /end snip Code from the model from datetime import datetime from sqlobject import * from turbogears import identity from turbogears.database import PackageHub hub = PackageHub(tglinks) __connection__ = hub # class YourDataClass(SQLObject): # pass class Visit(SQLObject): class sqlmeta: table = visit visit_key = StringCol(length=40, alternateID=True, alternateMethodName=by_visit_key) created = DateTimeCol(default=datetime.now) expiry = DateTimeCol() def lookup_visit(cls, visit_key): try: return cls.by_visit_key(visit_key) except SQLObjectNotFound: return None lookup_visit = classmethod(lookup_visit) class VisitIdentity(SQLObject): visit_key = StringCol(length=40, alternateID=True, alternateMethodName=by_visit_key) user_id = IntCol() class Group(SQLObject): An ultra-simple group definition. # names like Group, Order and User are reserved words in SQL # so we set the name to something safe for SQL class sqlmeta: table = tg_group group_name = UnicodeCol(length=16, alternateID=True, alternateMethodName=by_group_name) display_name = UnicodeCol(length=255) created = DateTimeCol(default=datetime.now) # collection of all users belonging to this group users = RelatedJoin(User, intermediateTable=user_group, joinColumn=group_id, otherColumn=user_id) # collection of all permissions for this group permissions = RelatedJoin(Permission, joinColumn=group_id, intermediateTable=group_permission, otherColumn=permission_id) class User(SQLObject): Reasonably basic User definition. Probably would want additional attributes. # names like Group, Order and User are reserved words in SQL # so we set the name to something safe for SQL class sqlmeta: table = tg_user user_name = UnicodeCol(length=16, alternateID=True, alternateMethodName=by_user_name) email_address = UnicodeCol(length=255, alternateID=True, alternateMethodName=by_email_address) display_name = UnicodeCol(length=255) password = UnicodeCol(length=40) created = DateTimeCol(default=datetime.now) bookmarks = MultipleJoin('Bookmark', joinColumn='user_id') # groups this user belongs to groups = RelatedJoin(Group, intermediateTable=user_group, joinColumn=user_id, otherColumn=group_id) def _get_permissions(self): perms = set() for g in self.groups: perms = perms | set(g.permissions) return perms def _set_password(self, cleartext_password): Runs cleartext_password through the hash algorithm before saving. hash = identity.encrypt_password(cleartext_password) self._SO_set_password(hash) def set_password_raw(self, password): Saves the password as-is to the database. self._SO_set_password(password) class Permission(SQLObject): permission_name = UnicodeCol(length=16, alternateID=True, alternateMethodName=by_permission_name) description = UnicodeCol(length=255) groups = RelatedJoin(Group, intermediateTable=group_permission, joinColumn=permission_id, otherColumn=group_id) class Tag(SQLObject): name = UnicodeCol(alternateID = True, length = 64) bookmarks = RelatedJoin('Bookmark') class Link(SQLObject): url = UnicodeCol(alternateID = True, length = 255) bookmarks = MultipleJoin('Bookmark') class Bookmark(SQLObject): user = ForeignKey('User') link = ForeignKey('Link') tags = RelatedJoin('Tag') title = UnicodeCol(length = 64) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: TG RuleDispatch install problem
venkatbo wrote: You may want to try an offline install option: http://docs.turbogears.org/1.0/OfflineInstall It lists the steps and points to TG's own download pg: http://www.turbogears.org/download/index.html The above article points also to a zip file of all the needed files. If that is not accessible, pl look at the thread Problem with TurboJson=0.9.9, for a list of files you can manuualy download. /venkat I figured out, that (at least here) the problem tracks back to the company proxy. The proxy is not happy about the encoding it gets from the RuleDispatch download link. The error it gives reads as follows: Server response could not be decoded using encoding type returned by server. This is typically caused by a Web Site presenting a content encoding header of one type, and then encoding the data differently. So the only option I am left with is to download it off-site, and bring it along to the office. But that would be against company policy, so I cannot do that :( The way it looks to me it's a simple character encoding problem, which should be fixed easily. *hopes* ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] TurboGears B1 error with psycopg
All, I have been working through some TurboGears tutorial to learn more the framework. I have sucessfully worked through the Wiki20 tutorial, and have started this tutorial: http://aymanh.com/turbogears-tutorial-social-bookmarking-application I have was able to succesfully create the database with the generated code, but when I add the reccomended code as described in the tutorial and get several errors : == Traceback (most recent call last): File /usr/bin/tg-admin, line 7, in ? sys.exit( File /usr/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/command/base.py, line 356, in main command.run() File /usr/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/command/base.py, line 143, in run command.the_runner.run(sys.argv) File /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/manager/command.py, line 102, in run runner.run() File /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/manager/command.py, line 233, in run self.command() File /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/manager/command.py, line 575, in command soClass.createTable() File /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/main.py, line 1332, in createTable conn.createTable(cls) File /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py, line 528, in createTable self.query(self.createTableSQL(soClass)) File /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py, line 307, in query return self._runWithConnection(self._query, s) File /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py, line 221, in _runWithConnection val = meth(conn, *args) File /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py, line 304, in _query self._executeRetry(conn, conn.cursor(), s) File /usr/lib/python2.4/site-packages/SQLObject-0.7.1-py2.4.egg/sqlobject/dbconnection.py, line 299, in _executeRetry return cursor.execute(query) psycopg.ProgrammingError: ERROR: relation tg_user does not exist CREATE TABLE bookmark ( id SERIAL PRIMARY KEY, user_id INT, CONSTRAINT user_id_exists FOREIGN KEY (user_id) REFERENCES tg_user (id) , link_id INT, CONSTRAINT link_id_exists FOREIGN KEY (link_id) REFERENCES link (id) , title VARCHAR(64) ) = Here is my code: = from datetime import datetime from sqlobject import * from turbogears import identity from turbogears.database import PackageHub hub = PackageHub(tglinks) __connection__ = hub # class YourDataClass(SQLObject): # pass class Visit(SQLObject): class sqlmeta: table = visit visit_key = StringCol(length=40, alternateID=True, alternateMethodName=by_visit_key) created = DateTimeCol(default=datetime.now) expiry = DateTimeCol() def lookup_visit(cls, visit_key): try: return cls.by_visit_key(visit_key) except SQLObjectNotFound: return None lookup_visit = classmethod(lookup_visit) class VisitIdentity(SQLObject): visit_key = StringCol(length=40, alternateID=True, alternateMethodName=by_visit_key) user_id = IntCol() class Group(SQLObject): An ultra-simple group definition. # names like Group, Order and User are reserved words in SQL # so we set the name to something safe for SQL class sqlmeta: table = tg_group group_name = UnicodeCol(length=16, alternateID=True, alternateMethodName=by_group_name) display_name = UnicodeCol(length=255) created = DateTimeCol(default=datetime.now) # collection of all users belonging to this group users = RelatedJoin(User, intermediateTable=user_group, joinColumn=group_id, otherColumn=user_id) # collection of all permissions for this group permissions = RelatedJoin(Permission, joinColumn=group_id, intermediateTable=group_permission, otherColumn=permission_id) class User(SQLObject): Reasonably basic User definition. Probably would want additional attributes. # names like Group, Order and User are reserved words in SQL # so we set the name to something safe for SQL class sqlmeta: table = tg_user user_name = UnicodeCol(length=16, alternateID=True, alternateMethodName=by_user_name) email_address = UnicodeCol(length=255, alternateID=True, alternateMethodName=by_email_address) display_name = UnicodeCol(length=255) password = UnicodeCol(length=40) created =
[TurboGears] Python DB-API 2.0 instead of SQLObject/SQLAlchemy
I would like to be able to use SQLObject or SQLAlchemy for my tg project, but since my older database, Sybase 9, is only accessible through mxODBC, I do not think I have much choice. What do I have to worry about in creating custom model classes so that eveything else in the tg stack just works, like widgets, etc. Do I just need to implement an SQLObject like interface for each of my model classes since they are typically derived from the SQLObject class anyway? I would do this just using normal python DB-API calls. I know it's not as fancy as the ORM tools, but if its all I got, its all I got. Also, can I leave identity management alone, pull it normally from postgresql or something like that, and pull other data from legacy system. Is shouldn't matter right if I have multiple data sources as that should all be encapsulated in the model classes? Thanks, Aaron Bostick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Application Security With Identity Framework
All, I'm trying to add some security features in an application that I have started in Django. I was having some difficulty working out how do this, so I started looking at TG, and it's Identity framework. Does the Identity framework allow me to provide the following functionality? Quick Example: 1)Isolate each instance of an object from other users. For example, if users A, B, C create schedules, they should only be able to act on there own schedules by default. 2)Grant Specific rights on objects, schedules , that the user owns. Here are some scenarios: - Lest say that user A would like to give user B the ability to view their schedule, but nothing else. - User A would like to give user C the ability to view and edit their schedule. - User B would like to give everyone the ability to view there schedules(make it public). As you can see, I'm just trying to give each user the ability to control what's done with there objects/data. Essentially, the application I'm working on is like a blog that would allow people to post to the world, have private posts, or share there posts with other users with the option of giving other users or groups of them permissions to perform specific tasks on their blog entry or entries. I have gone through the Identity Tutorial in the docs, but wasn't quite sure how to create user to user permissions on a per object basis. Thanks! --Nick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Python DB-API 2.0 instead of SQLObject/SQLAlchemy
On 10/19/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I would like to be able to use SQLObject or SQLAlchemy for my tg project, but since my older database, Sybase 9, is only accessible through mxODBC, I do not think I have much choice. What do I have to worry about in creating custom model classes so that eveything else in the tg stack just works, like widgets, etc. Do I just need to implement an SQLObject like interface for each of my model classes since they are typically derived from the SQLObject class anyway? I would do this just using normal python DB-API calls. I know it's not as fancy as the ORM tools, but if its all I got, its all I got. SQLObject supports some version of Sybase. You should probably look into making that work with Sybase 9 instead of writing a half-baked clone of SQLObject's functionality. -bob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Python DB-API 2.0 instead of SQLObject/SQLAlchemy
On 10/19/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I would like to be able to use SQLObject or SQLAlchemy for my tg project, but since my older database, Sybase 9, is only accessible through mxODBC, I do not think I have much choice. have you think of migrating it ? or writting mxOBBC support for SA/SO? What do I have to worry about in creating custom model classes so that eveything else in the tg stack just works, like widgets, etc. most of the toolbox wont work and the quickstart templates either, I think tg-admin will be totally broken. Do I just need to implement an SQLObject like interface for each of my model classes since they are typically derived from the SQLObject class anyway? not necessary you could use any other method. like PDO I would do this just using normal python DB-API calls. I know it's not as fancy as the ORM tools, but if its all I got, its all I got. or write a SO/SA wrapper for mxODBC? I don't know for SA but it's not that complicated for SO check out http://sqlobject.org/module-index.html this should get you the basic module needs. on the other hand in order to do what you need you will need to patch this file, and add that TG layer to work with your underlaying protocol. http://trac.turbogears.org/turbogears/browser/tags/1.0b1/turbogears/database.py Also, can I leave identity management alone, pull it normally from postgresql or something like that, and pull other data from legacy system. identity is 100% optional Is shouldn't matter right if I have multiple data sources as that should all be encapsulated in the model classes? for SO this is a bit complicated because you will have to handle 2 connection hubs. Thanks, Aaron Bostick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Application Security With Identity Framework
On 10/19/06, Linicks [EMAIL PROTECTED] wrote: All, I'm trying to add some security features in an application that I have started in Django. I was having some difficulty working out how do this, so I started looking at TG, and it's Identity framework. Does the Identity framework allow me to provide the following functionality? Quick Example: 1)Isolate each instance of an object from other users. For example, if users A, B, C create schedules, they should only be able to act on there own schedules by default. by definition each request is 100% independent of the other so yes what user A creates is for user A. 2)Grant Specific rights on objects, schedules , that the user owns. Here are some scenarios: - Lest say that user A would like to give user B the ability to view their schedule, but nothing else. - User A would like to give user C the ability to view and edit their schedule. - User B would like to give everyone the ability to view there schedules(make it public). this can be acomplish with the groups, they worl in a similar way as UNIX groups. although if you need something much more specific, like give access to this object to userA,userB and userC, you will have to extend the default checks for identity. you may have to add some custom predicate and some GUI for administering them, which could be a nice contribution :) and I think some of the catwalk components can help here. As you can see, I'm just trying to give each user the ability to control what's done with there objects/data. Essentially, the application I'm working on is like a blog that would allow people to post to the world, have private posts, or share there posts with other users with the option of giving other users or groups of them permissions to perform specific tasks on their blog entry or entries. I have gone through the Identity Tutorial in the docs, but wasn't quite sure how to create user to user permissions on a per object basis. check out http://docs.turbogears.org/1.0/IdentityManagment for the new predicates this module should help you write them http://trac.turbogears.org/turbogears/browser/tags/1.0b1/turbogears/identity/conditions.py Thanks! --Nick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: New TurboGears installer, please test
On Oct 4, 2006, at 2:22 AM, Jorge Vargas wrote: On 9/26/06, Kevin Dangoor [EMAIL PROTECTED] wrote: On Sep 25, 2006, at 10:14 PM, gasolin wrote: Excuse me for seperate post, I just forgot to mention the setuptool's version is up to c3, so the tgsetup.py might to keep up that version ... Is the tgsetup.py in svn? I can help it out, too... At the moment, tgsetup.py is in the website svn. It is, in some ways, outside of the normal flow. is there a way we can add something that will tell people they need a compiler to go on. I have seen several people having trouble with ez_setup/tgsetup having weird tracebacks becasue the egg files are not found and comming to the list for help. Hmm... that'd be nice. Doesn't the error message (after egg not found) say something to that effect? We should have tgz files for anything where we don't have an egg. Kevin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Identity Testing
A link to the full test module: http://pastecode.com/6908 I have an almost identical set of tests for SQLObject that pass no problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Application Security With Identity Framework
Linicks wrote: 2)Grant Specific rights on objects, schedules , that the user owns. Here are some scenarios: - Lest say that user A would like to give user B the ability to view their schedule, but nothing else. - User A would like to give user C the ability to view and edit their schedule. - User B would like to give everyone the ability to view there schedules(make it public). There are some built-in identity conditions ('in_group', 'not_anonymous', 'has_permission'), but there is nothing preventing you from setting up your own conditions. If you had a function called can_view_schedule, and that function determined whether or not another user could see a particular schedule, you could then decorate your controller like: @expose(template=some_template) @identity.require(can_view_schedule()) def show_schedule(self): #your logic Of course, the logic to 'can_view_schedule' is specific to your app, but once you set it up, identity can use it pretty seamlessly. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Current Best Practices for SQLAlchemy in TG?
John Lavoie wrote: Is there any way to auto save/commit? All of the SA docs I have seen say that I need to force it with session.save and session.flush Jonathan, you might be interested in providing a context manager with SQLAlchemy to do this (for Python 2.5+); that would allow users to use a 'with' block. See http://projects.amor.org/dejavu/browser/trunk/test/test_context.py for an example of usage, and steal my implementation if you want: http://projects.amor.org/dejavu/browser/trunk/arenas.py#L655 (yes, it really can be that simple ;). Robert Brewer System Architect Amor Ministries [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: What's @expose?
John Henry wrote: The one confusing thing to a newbie like myself is not knowing which file and which directory the tutorial is talking about. Many a times, I found myself at a total lost simply because I don't know which file (and where) I am suppose to do certain things to. Hi: I just wrote an article that try to categorized all tg quickstart files for 4 purposes. Maybe this could help you to figure out which file suppose to do certain things to. For Deployment * README.txt # self explaination * setup.py # install related settings * (your project name)/release.py # application related infomation * (your project name).egg-info/ # auto-generated infomation from setup.py For Configuration * dev.cfg # for development use * sample-prod.cfg # for production use * (your project name)/config/ # for application specific settings For Testing * (your project name)/tests/ # self explaination For Development * (your project name)/model.py # Model * (your project name)/templates # View * (your project name)/json.py # Another View for AJAX application * (your project name)/controllers.py # Controller http://inet6.blogspot.com/2006/10/turbogears-in-minutes-getting-new.html And its super helpful to enhance turbogears document by making a comment under docs if you have found which file suppose to do certain things to. -- Fred --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: widget CalendarDatePicker again
jose [EMAIL PROTECTED] writes: Adam Jones wrote: What have you tried so far to get it working? AFAIK it should work in exactly the same way as any other widget, since all of the work that CDP does is on the display side. Please post whatever relevant code you have so we can figure this out. -Adam I'm trying this: widgets.CalendarDatePicker( name = mydate, label = 'date label:', default = None, validator = DateValidator(today_or_after=True), not_empty = True, ), I expect it doesn't allow me to input a date before today but it does. Can you try this and see if you get the same output as I did? from formencode.validators import DateValidator from datetime import datetime dv = DateValidator(today_or_after=True) dv.to_python(datetime.now()) datetime.datetime(2006, 10, 19, 21, 6, 15, 764979) datetime.fromordinal(10) datetime.datetime(274, 10, 16, 0, 0) date = datetime.fromordinal(10) dv.to_python(date) Traceback (most recent call last): File stdin, line 1, in ? File /home/godoy/desenvolvimento/python/TurboGears/1.0/thirdparty/formencode/formencode/api.py, line 319, in to_python vp(value, state) File /home/godoy/desenvolvimento/python/TurboGears/1.0/thirdparty/formencode/formencode/validators.py, line 844, in validate_python value, state) formencode.api.Invalid: The date must be sometime in the future -- Jorge Godoy [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: To TG or not TG?
I think what you are looking for is a content management system, at least for now. I am assuming that, aside from the hyperlinks, most of those files are static content. At least a few CMS' are pretty good at interpreting MS Office files, but will probably miss the hyperlinks, so the data entry shouldn't be too difficult. The big advantage is that a decent CMS will either have or have extensions which handle the low level work to provide the functionality you need. If you are looking for something a little more dynamic, TG might be a good fit. Django's admin interface (among other things) is spectacular, so take a look at that as well. I agree with Karl though, avoid PHP if at all possible. -Adam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: Identity, doing without sessions, and memcached
Check out Beaker if you haven't already. It's WSGI middleware for sessions and caching that is basically broken out from Myghty and supports memcached.On Oct 3, 2006, at 8:42 AM, lateef jackson wrote:+1A project I worked on implemented some caching abstraction. There where basically 2 options Cache and TimedCache. Cache was an open ended cache where the caching system would evict objects as it needed the space. TimedCache was a cache that would expire after a specific amount of time. Generally we used the TimedCache for web content that rarely changed. Note: objects that went into the open ended cache would also need to have code that invlidated those objects. We had 2 providers of back end caching memcache (http://www.danga.com/memcached/) and lrcucache (http://freshmeat.net/projects/lrucache/ ). Simplified Dict interface. Only supports 'in', setitem, and getitem, delitem.memcached is really a wonderful piece of software but only if you need it. You can probably get away with a simpler caching system if you are only running 1 TG instance and don't need to share the cache with anything outside of TG. On 10/3/06, Stuart Clarke [EMAIL PROTECTED] wrote: 2. From what I've read, memcached is cool. And is the one true solution for caching a scalable web application. I plan to use memcached to cache the DB content of my TG app. Question: does Identity support caching with memcached (from looking at the code, I suspect not)? Are there plans to introduce this? Does anyone else want it? I'm thinking of a system wherein, if it's not already there, the identity information for a particular user ID is placed in memcached (this goes for session IDs too), indexed by one of the unique keys (possibly username?). When the user accesses a page, their credentials are compared to the memcached data. If new data for that ID is written to the DB, or deleted from the DB, the associated memcached content would be updated or deleted accordingly.Addendum: TG would probably benefit from a generic caching mechanism, which would apply to all object data. A cache API could be implemented,and then used by Identity and whatever else wants to. We could thenhave several implementations behind the API: disk, local memory,memcached, none. The cache used by Identity would be selectable and tuneable from the config files. One could also create (potentiallyseveral different) cache instances to use in other parts of ones app.What do people think?Stuart --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: TurboGears B1 error with psycopg
I think psycopg2 is required for SqlObject --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: To TG or not TG?
On 10/19/06, Adam Jones [EMAIL PROTECTED] wrote: I agree with Karl though, avoid PHP if at all possible. I don't say that. I say use each tool for what it's good for. If you've got a one or two page app that displays a list of something (files, mysql rows, pre-formatted pics) PHP is a very fine solution. I tend to write such pages in PHP and advocate doing so because it's easy to write and deploy. If you go beyond that and into any sort of serious app (modern blogging engine, web forum, multi-page forms with validation, CMS, etc), PHP is not the best solution. For those I recommend a fourth generation* web framework. * I consider the generations to be: 1. generated static html, ssi 2. cgi/perl 3. *SP, PHP, etc 4. Full stack dynamic language (Rails was first) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---
[TurboGears] Re: To TG or not TG?
Karl Guertin wrote: On 10/19/06, Adam Jones [EMAIL PROTECTED] wrote: I agree with Karl though, avoid PHP if at all possible. I don't say that. I say use each tool for what it's good for. If you've got a one or two page app that displays a list of something (files, mysql rows, pre-formatted pics) PHP is a very fine solution. I tend to write such pages in PHP and advocate doing so because it's easy to write and deploy. If you go beyond that and into any sort of serious app (modern blogging engine, web forum, multi-page forms with validation, CMS, etc), PHP is not the best solution. For those I recommend a fourth generation* web framework. Sorry, I meant that in the context of building/managing a site to replicate the current hyperlinked spreadsheet/word document combination. I agree with you about where PHP is appropriate, but I would still hesitate to use it as my experience has been that most simple one or two page apps manage to expand until they are doing much more than you ever intended. -Adam * I consider the generations to be: 1. generated static html, ssi 2. cgi/perl 3. *SP, PHP, etc 4. Full stack dynamic language (Rails was first) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups TurboGears group. To post to this group, send email to turbogears@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~--~~~~--~~--~--~---