Re: [Zope3-Users] Blog naming proposals

2007-05-29 Thread Vinny

Florian Lindner wrote:


One thing still missing is a good name. A name that quickly comes to my mind 
is zBlog but which is not very fancy.


What ideas have you for Zope3 blog package, what would you choose?


If you are using any of the 'Grok' stuff then you might
consider 'Grog'.  Say it out loud.

Grog

Grog

See? Sounds cool.  ;-)

Vinny
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.form 1.0.0 released!

2007-05-27 Thread Vinny

Stephan Richter wrote:

Hello everyone,

Roger and I are proud to announce the first release of the new form and widget
framework ``z3c.form``! After years of talking about it, months of thinking
about it and many weeks of implementation, we have finally completed it.


First of all, thanks for this, very kind of you to share
your hard work.



For the curious and impatient ...
-

To run the demos do the following::

  $ svn co svn://svn.zope.org/repos/main/z3c.formdemo/trunk formdemo
  $ cd formdemo
  $ python bootstrap.py
  $ ./bin/buildout
  $ ./bin/demo fg



I did try the above, but it complained about needing a
newer setuptools than I had.  No big deal, I can update
that easily enough.

Before I go further though, does the above command set
install a full version of zope and if so, what version?

Do I need 3.4.0a1 to run this demo or can I use 3.3.0
or 3.3.1?  I'm running 3.3.0 but can upgrade to 3.3.1.



Installation


All packages have been released in source and binary-egg format on PyPI and
``download.zope.org/distribution``. You can use setuptools to install
them. Here is a list of all packages:

* z3c.form
* z3c.formui
* z3c.formdemo
* jquery.javascript
* jquery.layer
* jquery.widget


So, perhaps I can install those packages (in instance/lib/python)
and I should be good to go?




Enjoy!

Regards,
Roger and Stephan


Thanks again!
Vinny
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Vocabulary

2007-03-08 Thread Vinny
On Sun, 28 Jan 2007 18:51:07 +0100
David Johnson <[EMAIL PROTECTED]> wrote:

> Does anyone know where I can find the latest methods on using  
> vocabularies?  I've using one approach for a while now using  
> SimpleVocabulary but that stopped working when I upgraded to 3.3.   
> The errors are "SimpleVocabulary is not called".
> 
> def getFunctions():
>  values = [ 'Black', 'Red', 'Blue' ]
>  return SimpleVocabulary.fromValues(values)
> 
> I thought this would be a good chance to build my vocabulary
> skills. I followed Stephan's book but I am receiving errors such as:
> 
>File "/Users/djohnson/sandbox/Zope-3.3.0/build/lib.macosx-10.3- 
> fat-2.4/zope/app/form/utility.py", line 64, in _createWidget
>  field = field.bind(context)
>File "/Users/djohnson/sandbox/Zope-3.3.0/build/lib.macosx-10.3- 
> fat-2.4/zope/schema/_field.py", line 239, in bind
>  assert ISource.providedBy(clone.vocabulary)
> 
> I figured that might be outdated, so I tried copying the "Connection  
> Names" vocabularly but again I get the same errors.
> 
> What am I missing? Where should I look?
> 

I came across this exact same error while playing with vocabularies
myself.

Here is a portion of my schema definition:

myProperty = Choice(title=_(u"A Property"),
description=_(u"Testing vocabs."),
vocabulary="Properties",
required=False)

The vocabulary using the utility directive (since vocabulary
is deprecated, I believe).

   

With a function as the component (in myproperty.py):

# Accepting the context argument was important even though
# it is not used in this function.
def getProperties(context):
"""
return a vocabulary of properties.
"""
list = ["one", "two"]
return SimpleVocabulary.fromValues(list)

One trick was to use the provides=IVocabularyFactory line in the
vocabulary's utility directive.  I had other ComponentLookup issues
before I set it to that.

I hope this helps because that assert error is in my logs
and I fixed it but I can't remember exactly what the key
change was at the time.  ;-)

Vinny


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Dict Widget

2007-02-27 Thread Vinny
On Tue, 27 Feb 2007 21:24:10 +0100
David Johnson <[EMAIL PROTECTED]> wrote:

> I've seen posts about this but I am confused. Is there a Dict
> widget? I tried it and I received IInputWidget errors.
> 
> myfield = Dict(title=u'My Dictionary',
>   key_type=TextLine(),
>   value_type=TextLine())
> 
>File "/Users/djohnson/sandbox/Zope-3.3.0/build/lib.macosx-10.3- 
> fat-2.4/zope/component/_api.py", line 103, in getMultiAdapter
>  raise ComponentLookupError(objects, interface, name)
> ComponentLookupError: (( 0x3a00190>,  URL=http://127.0.0.1:8080/My%20Contacts/+/addContact.html>),  
> , u'')
> 


I got the same thing trying to use a Tuple:

  File
"/usr/local/www/Zope3/lib/python/zope/app/form/browser/itemswidgets.py",
line 56, in CollectionInputWidget IInputWidget) File
"/usr/local/www/Zope3/lib/python/zope/component/_api.py", line 103, in
getMultiAdapter raise ComponentLookupError(objects, interface, name)
ComponentLookupError: ((,
None, http://zope.palaceofretention.ca:8080/hey/++preferences++/@@index.html>),
, u'')

It seems the more complex field types might need a custom
widget.  I simply broke the tuple down into its parts and
avoided the lack of a tuple input widget.

Vinny
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] User preferences for languages- possible?

2007-02-22 Thread Vinny
Hi,

[much snippage]

Try adding the code snippet shown below.  It detects
whether a principal is available and only checks
for preferences if there is one.  
 
class BrowserFormLanguages(BrowserLanguages):
implements(IModifiableUserPreferredLanguages)
 
language_store = []  # ignore this for now
 
def __init__(self, request):
super(BrowserFormLanguages, self).__init__(request)
print "created BFL", self.language_store
 
def setPreferredLanguages(self, langs):
#prefs = UserPreferences()
#print prefs.eods.general.language
self.language_store = langs
print "set language", self.language_store
 
def getPreferredLanguages(self):
langs =
super(BrowserFormLanguages,self).getPreferredLanguages() 
if self.language_store:
langs = self.language_store + langs
form_lang = self.request.get("Language", None)
if form_lang is not None:
langs.insert(0, form_lang)

# LOOK HERE 
# don't look up preferences unless we have
# something which _has_ preferences!
if self.request.principal != None:
prefs = UserPreferences()
print "Prefs", repr(prefs)
# substitute your own 'None' value case.
if prefs.eods.general.language is not None:  
langs.insert(0, prefs.eods.general.language)

print "My prefered override", langs
return langs


The principal annotation error seems to be avoided (since
we've made sure we have a principal).  

The language does seem to be set to the preference for page
displays, so what Philipp said about being able to ignore
uninteresting things until we've traversed far enough
was a good hint.

Vinny
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope Book: Internationalizing still up to date?

2007-02-22 Thread Vinny
Hi Florian,

Read the chapter in Stephan's book.  It is excellent and is
only out of date on some minor points.  Here's one:

New:

from zope.i18n import MessageFactory
_ = MessageFactory("translationdomain")

This can be found here:  

http://kpug.zwiki.org/WhatIsNewInZope33

See section 7 Porting to Zope 3.3.0 

Stephan's book ties together a good portion of the
details needed for many parts of i18n in zope.

> Any other good sources about i18n?
> 

I found the following helpful: 

http://wiki.zope.org/zope3/ZPTInternationalizationSupport

http://wiki.zope.org/zope3/ZPTInternationalizationExamples

I also think that these are useful and up-to-date as far
as I can tell:

http://wiki.zope.org/ZPT/MetalSpecification11
http://wiki.zope.org/ZPT/TALSpecification14

I've just been learning i18n as well so feel free
to post more questions!  Answers are even better. ;-)


Vinny
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Applying permissions to users from LDAP

2007-02-16 Thread Vinny
On Fri, 16 Feb 2007 09:03:29 -0400
"Alec Munro" <[EMAIL PROTECTED]> wrote:

[snip]
> 
> Thanks to all your excellent advice, I have gone ahead and extended
> the existing Group folder to automatically import and periodically
> synchronize it's groups with an LDAP directory. The functionality is
> currently a bit crude, but it gets the job done. I'm talking to my
> employer about open sourcing it, would anyone here be interested in
> it?
> 
> Alec

+1

I, for one, would probably learn something useful from the code, if
you decide to release it.  Thanks in advance if that is the case.

Vinny
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: How do I get the schema/field list from an instance?

2007-02-14 Thread Vinny
On Wed, 14 Feb 2007 19:22:53 +0100
Philipp von Weitershausen wrote:

> Vinny wrote:
> > In a ZPT I would do something like:
> > 
> > for field in fieldsInObject(row) # which has (ordered?) fields
> >   th cell: field.name
> > for row in rowView
> >   for field in fieldsInObject(row) # which has (ordered?) fields
> > td cell: field.value
> > 
> > I know the above is broken in several ways.  I've been
> > trying various methods all evening.  The closest I get
> > is the __dict__ usage.  Ideally, I would get the 
> > interface provided by the object and feed that to 
> > form.Fields() but I can't determine how to get an
> > interface value that can be fed to form.Fields().
> > 
> > iface = zope.interface.providedBy(obj)
> > 
> > doesn't seem to work.
> 
> By itself it won't work. You'll have to do a bit more. First of all,
> an object can provide 0, 1 or more interfaces. Second, schemas are
> just interfaces whose specifications are fields (a schema can also
> have method specifications, there's no restriction to "mixing" a
> traditional interface with a schema). Therefore:
> 
>for iface in zope.interface.providedBy(obj):
>for name in iface:
>field = iface[name]
>if zope.schema.interfaces.IField.providedBy(field):
># you've got a schema field, now you can work with
># field.title, field.description, etc. (see IField)
> 


Thank you Philipp,

I have achieved my goal of a generic page template and
sql container view.  There are a few quick questions in the
example code below.  Mainly on being more efficient.  Here
are the results for everyone to use/comment on.  Note that
if anyone wants the rest of the files for this app., just
let me know and I'll see what I can arrange.  I still have
to test it with more tables.

== iso639.py snippet =
from zope.publisher.browser import BrowserView
from zope.security.proxy import removeSecurityProxy
from zope.app import zapi
import zope.interface
from zope.sequencesort import sort
from zope.app.preference import UserPreferences

class SQLAlchemyContainerView(BrowserView):

def __init__(self, context, request):
self.context = context
self.request = request

def rowView(self):
"""
Presumably I have an instance of SQLAlchemyContainer
We will be yielding a list of dictionaries with name and value keys.

Philipp von Weitershausen provided some help on how to get to the
schema/IField interface.

"""

sqlRecordObjects = [sqlRecordObject for sqlRecordObject in 
self.context.values()]

sort_on = (('lookup', 'nocase', 'asc'),)
sorted_rows = sort(sqlRecordObjects, sort=sort_on)

#userPreferences = UserPreferences()
#print userPreferences.hello.sorting.sortGroups
#sorted_rows = sort(sqlRecordObjects, 
sort=userPreferences.hello.sorting.sortGroups)

for sqlRecordObject in sorted_rows:
sqlRecordObject = removeSecurityProxy(sqlRecordObject)

nameValues = []   # A list of two-term dictionaries
for iface in zope.interface.providedBy(sqlRecordObject):
for name in iface:
field = iface[name]
if zope.schema.interfaces.IField.providedBy(field):
# We've got a schema field, now we can work with
# field.title, field.description, etc. (see IField)

# Since we get a 'bonus' item in our schema called 
__name__
# we must ignore it.  We use a list containment 
condition in
# case we want to expand the list of ignored
if field.__name__ in ['__name__']:
pass
else:
#print (field.__name__, 
sqlRecordObject.__dict__[field.__name__], )
nameValues.append({'name': field.title, 'value': 
sqlRecordObject.__dict__[field.__name__]})
#print nameValues[key]

# At this point we yield a list of dictionaries.
# The dictionary has keys 'name' and 'value' and their values are,
# respectively, the schema field title and
# the value of the sql record's column
yield nameValues


def fieldsInObject(self):

objlist = [obj for obj in self.context.values()]
#oneLang = self.context.values(0)
sqlRecordObject = removeSecurityProxy(objlist[0])
# Note: there *must* be a better way of getting
# just one value from 

[Zope3-Users] How do I get the schema/field list from an instance?

2007-02-13 Thread Vinny

Hi,

Zope 3.3.0

I hope everyone is well today.  

If I have a container how do I find out what types of objects
it contains and then from that, how do I find out the schema
of the contained object?

Eg. I have a SQLAlchemyContainer with a SQLAlchemyContainerView.
The container contains the mapped class for a sqlalchemy 
table.  

Here's the view code that I've been struggling with:

class SQLAlchemyContainerView(BrowserView):

def __init__(self, context, request):
self.context = context
self.request = request

def fieldsInObject(self):
objlist = [obj for key, obj in self.context.items()]
obj = removeSecurityProxy(objlist[0])
return obj.__dict__

def rowView(self):
for obj in self.context.values():
yield obj

My goal is to generalize a view that creates an HTML table for
an arbitrary database table.  I want to register it for
the ISQLAlchemyContainer interface.  So I need to know the
objects contained and their schema.  

In a ZPT I would do something like:

for field in fieldsInObject(row) # which has (ordered?) fields
  th cell: field.name
for row in rowView
  for field in fieldsInObject(row) # which has (ordered?) fields
td cell: field.value

I know the above is broken in several ways.  I've been
trying various methods all evening.  The closest I get
is the __dict__ usage.  Ideally, I would get the 
interface provided by the object and feed that to 
form.Fields() but I can't determine how to get an
interface value that can be fed to form.Fields().

iface = zope.interface.providedBy(obj)

doesn't seem to work.

Anyone done this already or know of some (comprehensible, 
for a noob) documentation/source code for this?

Thanks in advance.
Vinny


 some code =

class IISO6392Language(Interface):
"""The interface definition of the iso639_2_language table.
"""

id = Int(
 title=_(u"serial id"),
 description=_(u"primary key is derived from this content"),
 readonly=True,
 required=True,
 )

lookup = TextLine(
 title=_(u"Lookup code.  Message Id"),
 description=_(u"This may be used as a message id in i18n terms.  
Should be unique in a table."),
 required=True,
 max_length=1024
 )


class ISO6392Language(object):
"""The implementation of IISO6392Language.  Hopefully, the
FieldProperty usage will help validate user data."""

implements(IISO6392Language)

id = FieldProperty(IISO6392Language['id'])
lookup = FieldProperty(IISO6392Language['lookup'])


iso639_2_language = sqlalchemy.Table(
 'iso639_2_language',
 z3c.zalchemy.metadata,
 sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
 sqlalchemy.Column('lookup', sqlalchemy.String(1024), nullable=False, 
default=u''),
 )

ISO6392Language.mapper = sqlalchemy.mapper(ISO6392Language, iso639_2_language)

==



___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Can't find MessageIDFactory

2007-02-09 Thread Vinny
On Sat, 10 Feb 2007 09:16:10 +1100
George Wright <[EMAIL PROTECTED]> wrote:

> Gidday zope3 users
> 
> I have been working through the Weitershausen Zope3 book (first  
> edition) and came to stuff on "Message IDs and translation domains.
> I can't import MessageIDFactory (page 125)!
> 
>  >> from zope.i18nmessageid import MessageIDFactory
> 
> Nor can I find any documentation on MessageIDFactory except of
> course what's in the book.
> Any ideas?

Hi George,

You'll need to use the newer boilerplate (I am running zope 3.3.0 FYI):

from zope.i18n import MessageFactory
_ = MessageFactory("translationdomain")

This can be found here:  

http://kpug.zwiki.org/WhatIsNewInZope33

See section 7 Porting to Zope 3.3.0 

There is other useful information on how to deal with
the other areas of the book which are slightly out of
date as well.

My thanks to the author, as a purchaser of the book, it
has been a great help in what has been an extremely steep
learning curve.  Any free upgrades to the second ed. if I 
show my receipt? ;-)

Vinny

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] broken formlib (nope, It was me!) - form.txt example

2007-02-06 Thread Vinny
On Tue, 6 Feb 2007 18:53:38 -0800 (PST)
Douglas Douglas <[EMAIL PROTECTED]> wrote:

> I guess you get this error because you're running the example as a
> single script in isolation. The script should run inside a Zope 3
> environment (with utilities and adapters registries set up).
> 
> If you want to try the example in IDLE you should create a Zope 3
> instance (using the mkzopeinstance script) and insert at the
> beginning of your script:
> 
> from zope.app.debug import Debugger
> debugger = Debugger(db='/some/path/to/the/instances/Data.fs/file',
> config_file='/some/path/to/the/instances/etcs/site.zcm/file')
> 
> That would start a Zope 3 environment (with utilities and adapters
> set up) and your example will run just fine.
> 

Hi Douglas (and thank you Tom D.),

You've hit the nail on the head.  I did as you instructed
above and was (mostly) able to correctly run the examples.
It was very nice of you (both) to provide some help when I was 
fairly high up on the frustration level.  

I had a nice end to my evening of zope exploration.  I
managed to get zalchemy to work--to my astonishment. ;-)
I have a SQLAlchemyContainer which has iso639 languages
and I can actually click on one of them, edit it and have
the changes reflected in the database.  Below are the
relevant files for those who are trying zalchemy.

I created a SQLAlchemyContainer called Langs using the
ZMI 'Add SQLalc...' feature while specifying the path to the 
ISO6392Language class after creating the iso639.py file 
below.  At the end of this message is the SQL for the
language table.  The table lives in a non-default postgresql
database schema named zope_schema (rather than public).

I was unable to get autoload to work for sqlalchemy 
table reflection.  This means I had to type all the 
Columns in by hand.  I'll have to write a short script
to build the interface, implementing class, and 
sqlalchemy.Table code, someday.  It will get tedious having to
cut and paste that for many tables.   

I hope this helps someone and that I haven't forgotten
anything.  

Vinny

= iso639.py ==
#

from zope.interface import implements
from zope.schema.fieldproperty import FieldProperty
from interfaces import IISO6392Language
from zope.publisher.browser import TestRequest

import sqlalchemy
import z3c.zalchemy
from z3c.zalchemy.datamanager import AlchemyEngineUtility

engineUtility = AlchemyEngineUtility(
 'pg',
 'postgres://user:[EMAIL PROTECTED]:5432/zopedb',
 echo=True
 )
  
from zope.component import provideUtility
provideUtility(engineUtility)


#pg = engineUtility.getEngine()
#print pg.connect()

#session = z3c.zalchemy.getSession

#z3c.zalchemy.assignTable('iso639_2_language', 'pg')

iso639_2_language = sqlalchemy.Table(
 'iso639_2_language',
 z3c.zalchemy.metadata,
 sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
 sqlalchemy.Column('lookup', sqlalchemy.String(1024), nullable=False, 
default=u''),
 sqlalchemy.Column('enabled', sqlalchemy.Boolean, default=True),
 sqlalchemy.Column('reportable', sqlalchemy.Boolean, default=True),
 sqlalchemy.Column('searchable', sqlalchemy.Boolean, default=True),
 sqlalchemy.Column('bibliographic_code', sqlalchemy.String(3), 
nullable=False, default=u''),
 sqlalchemy.Column('terminologic_code', sqlalchemy.String(3), 
nullable=False, default=u''),
 sqlalchemy.Column('alpha2_code', sqlalchemy.String(2), nullable=False, 
default=u''),
 #autoload=True,
 schema='zope_schema')


class ISO6392Language(object):
"""The implementation of IISO6392Language.  Hopefully, the
FieldProperty usage will help validate user data."""

implements(IISO6392Language)

id = FieldProperty(IISO6392Language['id'])
lookup = FieldProperty(IISO6392Language['lookup'])
enabled = FieldProperty(IISO6392Language['enabled'])
reportable = FieldProperty(IISO6392Language['reportable'])
searchable = FieldProperty(IISO6392Language['searchable'])
bibliographic_code = FieldProperty(IISO6392Language['bibliographic_code'])
terminologic_code = FieldProperty(IISO6392Language['terminologic_code'])
alpha2_code = FieldProperty(IISO6392Language['alpha2_code'])

def __repr__(self):
   return "%s(%r,%r)" % (
   self.__class__.__name__, self.lookup, self.id)
   
ISO6392Language.mapper = sqlalchemy.mapper(ISO6392Language, iso639_2_language)
#z3c.zalchemy.createTable('iso639_2_language')

from zope.formlib import form
from zope.app.pagetemplate i

[Zope3-Users] broken formlib - form.txt example

2007-02-06 Thread Vinny
Hello,

Platform details:

# pkg_info | grep zope
zope-3.3.0  An object-based web application platform
# uname -a
FreeBSD the.palaceofretention.ca 6.2-RELEASE #1:
# python
Python 2.4.3 (#2, Dec 26 2006, 16:13:56)
[GCC 3.4.4 [FreeBSD] 20050518] on freebsd6

Using IDLE 1.1.3

Using instructions from:
/usr/local/www/Zope3/lib/python/zope/formlib/form.txt

With code straight out of it typed into the IDLE editor, saved
as form.py and run using the F5 command:

=== 8< 
from zope import interface, schema
class IOrder(interface.Interface):
identifier = schema.Int(title=u"Identifier", readonly=True)
name = schema.TextLine(title=u"Name")
min_size = schema.Float(title=u"Minimum size")
max_size = schema.Float(title=u"Maximum size")
now = schema.Datetime(title=u"Now", readonly=True)

from zope.formlib import form
class MyForm:
form_fields = form.Fields(IOrder)

#This sets up a set of form fields from the interface, IOrder.

print len(MyForm.form_fields)

print [w.__name__ for w in MyForm.form_fields]

class MyForm:
form_fields = form.Fields(IOrder, omit_readonly=True)

def __init__(self, context, request):
self.context, self.request = context, request

def __call__(self, ignore_request=False):
widgets = form.setUpWidgets(
self.form_fields, 'form', self.context, self.request,
ignore_request=ignore_request)
return '\n'.join([w() for w in widgets])

from zope.publisher.browser import TestRequest
request = TestRequest()
print MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE

Saving and running this gives: 

>>> === RESTART 
>>> 
5
['identifier', 'name', 'min_size', 'max_size', 'now']

Traceback (most recent call last):
  File "/usr/local/www/Zope3/mv/lib/python/hello/form.py", line 33, in
-toplevel-
print MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE
  File "/usr/local/www/Zope3/mv/lib/python/hello/form.py", line 28, in
__call__
ignore_request=ignore_request)
  File "/usr/local/www/Zope3/lib/python/zope/formlib/form.py", line
256, in setUpWidgets
IInputWidget)
  File "/usr/local/www/Zope3/lib/python/zope/component/_api.py", line
103, in getMultiAdapter
raise ComponentLookupError(objects, interface, name)
ComponentLookupError: ((, http://127.0.0.1>), , u'')


Sigh.  Am I jinxed?  I've been trying to learn zope 3 for six
months now.  All I want is to be able to make a form from an
interface and display the dang thing.  Is that too much to
ask?  /rant

Does anyone know what's going wrong?  Do I need to upgrade
anything?

Thanks in advance.

Vinny

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Logging level for transcript.log

2007-02-04 Thread Vinny
Hi Jim,

Thanks for answering.  I appreciate you're a busy man.  
Further discussion follows below inline.

Vinny

On Sat, 03 Feb 2007 11:15:58 -0500
Jim Fulton <[EMAIL PROTECTED]> wrote:
> Vinny wrote:
> > Hi,
> > 
> > Where can I find the configuration setting for the 
> > logging level used in the transcript.log file?
> > 
> > I have tried looking in etc/zope.conf, etc/zdaemon.conf
> > and came up empty handed.  I can see ERROR levels easily
> > enough. 
> 
> The transcript log is created by zdaemon and captures
> all output from the application being run, in this case,
> Zope.  It has nothing to do with the Python logging system
> and has no concept of log level.

So, the zdaemon is catching _all_ output?  Including output
destined to a specified file?  Preventing it from getting to
file?  Is this expected behaviour?  Can anyone reproduce this?

It is entirely possible that I am doing something completely
stupid.  My background is in cold fusion (yes, I know, eeww),
so I am out of my depth with both python's object orientation 
_and_ zope 3 being new to me.  Hence, I hope to determine
some sort of process flow by placing logging statements all
over the place.

> 
>  > This works and shows up in transcript.log:
>  >
>  > import logging
>  >
>  > logging.basicConfig(level=logging.DEBUG,
>  > format='%(asctime)s %(levelname)-8s
>  > %(message)s', datefmt='%a, %d %b %Y %H:%M:%S',
>  > 
> filename='/usr/local/www/Zope3/mv/lib/python/hello/utility/log',
>  > filemode='a')
>  >
>  > logging.error('Pack my box with %d dozen %s', 5, 'liquor jugs')
>  >
>  > But this does not show up in transcript.log:
>  >
>  > logging.debug('Pack my box with %d dozen %s', 5, 'liquor jugs')
>  >
>  > Both messages end up in my local log file.  

Hmm, my statement above is not correct.  I was confused (and still
am, I guess).  The messages are not being written to my log
file when zope starts/runs (see above and below).  They are written when
I run the __init__.py files manually, though.  I made sure that
the access permissions on the file/directory were ok for user www.
Doesn't seem to make a difference.  The messages are not written
to my specified file (even to one in the /tmp directory). 

[snip]

>  > with zope.  Where do I find out about the zope logger?
> 
> That's a good question.  Logging is controlled through ZConfig and
> I'm not aware that our ZConfig setup is documented, except through
> comments in sample zope.conf files.  I'm not a big fan of how we
> currently do configuration.
> 
> I think you want to change the logging level by adding a level
> option to the event log:
> 
> 
>level debug
> 
>
>  path $LOGDIR/z3.log
>  formatter zope.exceptions.log.Formatter
>
> 
>
>  path STDOUT
>  formatter zope.exceptions.log.Formatter
>
> 
> 
> In this example, I have set the logging level for the
> event logger to debug, so you will see debug messages.
> The default logging level is info.

Using the 'level debug' config. option certainly has added
a great deal of interesting information to the transcript.log.
I thank you for that, in as much as it will provide future
enlightenment on just what is going on at zope startup. 
It has also allowed me to use the logging.debug setting
even though, now that I know the default level is INFO,
I should probably just be using logging.info().

> 
> Note that in the example above we are sending output to
> 2 places, z3.log and standard output.  Because the zdaemon
> transcript log captures standard output, it is the standard
> output logger that affects the transcript log.  IMO, it is
> silly to log to two places. I would just log to standard
> output.  (The only problem with this is that older versions
> os zdaemon don't support log rotation. I have fixed this
> in the latest version of zdaemon.)

The logging in two places confused me at first.  I didn't know
which log was more accurate, or in use.  I only surmised 
after a while that transcript held some of the errors that I 
usually came across and that z3 didn't.  Although there doesn't
seem to be detectable, by me, consistency in what gets logged
where.  

> 
> Jim
> 

I suppose my last question is: Can I use the python logging
facility to write my own logfiles?  What have I missed?
I ought to be able to write my own logs, eh?

My little 'hello' application has a simple __init__.py that 
looks like this:

/usr/local/www/Zope3/mv/lib/python/hello/__init__.py
=
import logging

log

[Zope3-Users] Logging level for transcript.log

2007-02-02 Thread Vinny
Hi,

Where can I find the configuration setting for the 
logging level used in the transcript.log file?

I have tried looking in etc/zope.conf, etc/zdaemon.conf
and came up empty handed.  I can see ERROR levels easily
enough.  This works and shows up in transcript.log:  

import logging

logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S', 

filename='/usr/local/www/Zope3/mv/lib/python/hello/utility/log',
filemode='a') 

logging.error('Pack my box with %d dozen %s', 5, 'liquor jugs')

But this does not show up in transcript.log:

logging.debug('Pack my box with %d dozen %s', 5, 'liquor jugs')

Both messages end up in my local log file.  I think I understand 
that the logging function is using mine and a logger registered
with zope.  Where do I find out about the zope logger?

Thanks in advance!

Vinny

P.S. Gosh this zope 3 stuff is hard.
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users