Compare commits
	
		
			No commits in common. "3master" and "bbmaster" have entirely different histories.
		
	
	
		
	
		
							
								
								
									
										7
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						|  | @ -1,14 +1,7 @@ | |||
| *.pyc | ||||
| *.pyo | ||||
| *.swp | ||||
| dist/ | ||||
| var/ | ||||
| *.egg-info | ||||
| *.project | ||||
| *.pydevproject | ||||
| *.ropeproject | ||||
| *.sublime-project | ||||
| *.sublime-workspace | ||||
| .env | ||||
| .settings | ||||
| adminuser.zcml | ||||
|  |  | |||
							
								
								
									
										21
									
								
								LICENSE
									
										
									
									
									
								
							
							
						
						|  | @ -1,21 +0,0 @@ | |||
| The MIT License (MIT)  | ||||
| 
 | ||||
| Copyright (C) 2023 cyberconcepts.org team | ||||
| 
 | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is | ||||
| furnished to do so, subject to the following conditions: | ||||
| 
 | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
| 
 | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
							
								
								
									
										222
									
								
								LICENSE.GPL
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,222 @@ | |||
|                        GNU GENERAL PUBLIC LICENSE | ||||
|    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||||
| 
 | ||||
|   0. This License applies to any program or other work which contains | ||||
| a notice placed by the copyright holder saying it may be distributed | ||||
| under the terms of this General Public License.  The "Program", below, | ||||
| refers to any such program or work, and a "work based on the Program" | ||||
| means either the Program or any derivative work under copyright law: | ||||
| that is to say, a work containing the Program or a portion of it, | ||||
| either verbatim or with modifications and/or translated into another | ||||
| language.  (Hereinafter, translation is included without limitation in | ||||
| the term "modification".)  Each licensee is addressed as "you". | ||||
| 
 | ||||
| Activities other than copying, distribution and modification are not | ||||
| covered by this License; they are outside its scope.  The act of | ||||
| running the Program is not restricted, and the output from the Program | ||||
| is covered only if its contents constitute a work based on the | ||||
| Program (independent of having been made by running the Program). | ||||
| Whether that is true depends on what the Program does. | ||||
| 
 | ||||
|   1. You may copy and distribute verbatim copies of the Program's | ||||
| source code as you receive it, in any medium, provided that you | ||||
| conspicuously and appropriately publish on each copy an appropriate | ||||
| copyright notice and disclaimer of warranty; keep intact all the | ||||
| notices that refer to this License and to the absence of any warranty; | ||||
| and give any other recipients of the Program a copy of this License | ||||
| along with the Program. | ||||
| 
 | ||||
| You may charge a fee for the physical act of transferring a copy, and | ||||
| you may at your option offer warranty protection in exchange for a fee. | ||||
| 
 | ||||
|   2. You may modify your copy or copies of the Program or any portion | ||||
| of it, thus forming a work based on the Program, and copy and | ||||
| distribute such modifications or work under the terms of Section 1 | ||||
| above, provided that you also meet all of these conditions: | ||||
| 
 | ||||
|     a) You must cause the modified files to carry prominent notices | ||||
|     stating that you changed the files and the date of any change. | ||||
| 
 | ||||
|     b) You must cause any work that you distribute or publish, that in | ||||
|     whole or in part contains or is derived from the Program or any | ||||
|     part thereof, to be licensed as a whole at no charge to all third | ||||
|     parties under the terms of this License. | ||||
| 
 | ||||
|     c) If the modified program normally reads commands interactively | ||||
|     when run, you must cause it, when started running for such | ||||
|     interactive use in the most ordinary way, to print or display an | ||||
|     announcement including an appropriate copyright notice and a | ||||
|     notice that there is no warranty (or else, saying that you provide | ||||
|     a warranty) and that users may redistribute the program under | ||||
|     these conditions, and telling the user how to view a copy of this | ||||
|     License.  (Exception: if the Program itself is interactive but | ||||
|     does not normally print such an announcement, your work based on | ||||
|     the Program is not required to print an announcement.) | ||||
| 
 | ||||
| These requirements apply to the modified work as a whole.  If | ||||
| identifiable sections of that work are not derived from the Program, | ||||
| and can be reasonably considered independent and separate works in | ||||
| themselves, then this License, and its terms, do not apply to those | ||||
| sections when you distribute them as separate works.  But when you | ||||
| distribute the same sections as part of a whole which is a work based | ||||
| on the Program, the distribution of the whole must be on the terms of | ||||
| this License, whose permissions for other licensees extend to the | ||||
| entire whole, and thus to each and every part regardless of who wrote it. | ||||
| 
 | ||||
| Thus, it is not the intent of this section to claim rights or contest | ||||
| your rights to work written entirely by you; rather, the intent is to | ||||
| exercise the right to control the distribution of derivative or | ||||
| collective works based on the Program. | ||||
| 
 | ||||
| In addition, mere aggregation of another work not based on the Program | ||||
| with the Program (or with a work based on the Program) on a volume of | ||||
| a storage or distribution medium does not bring the other work under | ||||
| the scope of this License. | ||||
| 
 | ||||
|   3. You may copy and distribute the Program (or a work based on it, | ||||
| under Section 2) in object code or executable form under the terms of | ||||
| Sections 1 and 2 above provided that you also do one of the following: | ||||
| 
 | ||||
|     a) Accompany it with the complete corresponding machine-readable | ||||
|     source code, which must be distributed under the terms of Sections | ||||
|     1 and 2 above on a medium customarily used for software interchange; or, | ||||
| 
 | ||||
|     b) Accompany it with a written offer, valid for at least three | ||||
|     years, to give any third party, for a charge no more than your | ||||
|     cost of physically performing source distribution, a complete | ||||
|     machine-readable copy of the corresponding source code, to be | ||||
|     distributed under the terms of Sections 1 and 2 above on a medium | ||||
|     customarily used for software interchange; or, | ||||
| 
 | ||||
|     c) Accompany it with the information you received as to the offer | ||||
|     to distribute corresponding source code.  (This alternative is | ||||
|     allowed only for noncommercial distribution and only if you | ||||
|     received the program in object code or executable form with such | ||||
|     an offer, in accord with Subsection b above.) | ||||
| 
 | ||||
| The source code for a work means the preferred form of the work for | ||||
| making modifications to it.  For an executable work, complete source | ||||
| code means all the source code for all modules it contains, plus any | ||||
| associated interface definition files, plus the scripts used to | ||||
| control compilation and installation of the executable.  However, as a | ||||
| special exception, the source code distributed need not include | ||||
| anything that is normally distributed (in either source or binary | ||||
| form) with the major components (compiler, kernel, and so on) of the | ||||
| operating system on which the executable runs, unless that component | ||||
| itself accompanies the executable. | ||||
| 
 | ||||
| If distribution of executable or object code is made by offering | ||||
| access to copy from a designated place, then offering equivalent | ||||
| access to copy the source code from the same place counts as | ||||
| distribution of the source code, even though third parties are not | ||||
| compelled to copy the source along with the object code. | ||||
| 
 | ||||
|   4. You may not copy, modify, sublicense, or distribute the Program | ||||
| except as expressly provided under this License.  Any attempt | ||||
| otherwise to copy, modify, sublicense or distribute the Program is | ||||
| void, and will automatically terminate your rights under this License. | ||||
| However, parties who have received copies, or rights, from you under | ||||
| this License will not have their licenses terminated so long as such | ||||
| parties remain in full compliance. | ||||
| 
 | ||||
|   5. You are not required to accept this License, since you have not | ||||
| signed it.  However, nothing else grants you permission to modify or | ||||
| distribute the Program or its derivative works.  These actions are | ||||
| prohibited by law if you do not accept this License.  Therefore, by | ||||
| modifying or distributing the Program (or any work based on the | ||||
| Program), you indicate your acceptance of this License to do so, and | ||||
| all its terms and conditions for copying, distributing or modifying | ||||
| the Program or works based on it. | ||||
| 
 | ||||
|   6. Each time you redistribute the Program (or any work based on the | ||||
| Program), the recipient automatically receives a license from the | ||||
| original licensor to copy, distribute or modify the Program subject to | ||||
| these terms and conditions.  You may not impose any further | ||||
| restrictions on the recipients' exercise of the rights granted herein. | ||||
| You are not responsible for enforcing compliance by third parties to | ||||
| this License. | ||||
| 
 | ||||
|   7. If, as a consequence of a court judgment or allegation of patent | ||||
| infringement or for any other reason (not limited to patent issues), | ||||
| conditions are imposed on you (whether by court order, agreement or | ||||
| otherwise) that contradict the conditions of this License, they do not | ||||
| excuse you from the conditions of this License.  If you cannot | ||||
| distribute so as to satisfy simultaneously your obligations under this | ||||
| License and any other pertinent obligations, then as a consequence you | ||||
| may not distribute the Program at all.  For example, if a patent | ||||
| license would not permit royalty-free redistribution of the Program by | ||||
| all those who receive copies directly or indirectly through you, then | ||||
| the only way you could satisfy both it and this License would be to | ||||
| refrain entirely from distribution of the Program. | ||||
| 
 | ||||
| If any portion of this section is held invalid or unenforceable under | ||||
| any particular circumstance, the balance of the section is intended to | ||||
| apply and the section as a whole is intended to apply in other | ||||
| circumstances. | ||||
| 
 | ||||
| It is not the purpose of this section to induce you to infringe any | ||||
| patents or other property right claims or to contest validity of any | ||||
| such claims; this section has the sole purpose of protecting the | ||||
| integrity of the free software distribution system, which is | ||||
| implemented by public license practices.  Many people have made | ||||
| generous contributions to the wide range of software distributed | ||||
| through that system in reliance on consistent application of that | ||||
| system; it is up to the author/donor to decide if he or she is willing | ||||
| to distribute software through any other system and a licensee cannot | ||||
| impose that choice. | ||||
| 
 | ||||
| This section is intended to make thoroughly clear what is believed to | ||||
| be a consequence of the rest of this License. | ||||
| 
 | ||||
|   8. If the distribution and/or use of the Program is restricted in | ||||
| certain countries either by patents or by copyrighted interfaces, the | ||||
| original copyright holder who places the Program under this License | ||||
| may add an explicit geographical distribution limitation excluding | ||||
| those countries, so that distribution is permitted only in or among | ||||
| countries not thus excluded.  In such case, this License incorporates | ||||
| the limitation as if written in the body of this License. | ||||
| 
 | ||||
|   9. The Free Software Foundation may publish revised and/or new versions | ||||
| of the General Public License from time to time.  Such new versions will | ||||
| be similar in spirit to the present version, but may differ in detail to | ||||
| address new problems or concerns. | ||||
| 
 | ||||
| Each version is given a distinguishing version number.  If the Program | ||||
| specifies a version number of this License which applies to it and "any | ||||
| later version", you have the option of following the terms and conditions | ||||
| either of that version or of any later version published by the Free | ||||
| Software Foundation.  If the Program does not specify a version number of | ||||
| this License, you may choose any version ever published by the Free Software | ||||
| Foundation. | ||||
| 
 | ||||
|   10. If you wish to incorporate parts of the Program into other free | ||||
| programs whose distribution conditions are different, write to the author | ||||
| to ask for permission.  For software which is copyrighted by the Free | ||||
| Software Foundation, write to the Free Software Foundation; we sometimes | ||||
| make exceptions for this.  Our decision will be guided by the two goals | ||||
| of preserving the free status of all derivatives of our free software and | ||||
| of promoting the sharing and reuse of software generally. | ||||
| 
 | ||||
|                             NO WARRANTY | ||||
| 
 | ||||
|   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | ||||
| FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN | ||||
| OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | ||||
| PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | ||||
| OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||||
| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS | ||||
| TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE | ||||
| PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | ||||
| REPAIR OR CORRECTION. | ||||
| 
 | ||||
|   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||||
| WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | ||||
| REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, | ||||
| INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING | ||||
| OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | ||||
| TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | ||||
| YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | ||||
| PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | ||||
| POSSIBILITY OF SUCH DAMAGES. | ||||
| 
 | ||||
|                      END OF TERMS AND CONDITIONS | ||||
							
								
								
									
										11
									
								
								MANIFEST.in
									
										
									
									
									
								
							
							
						
						|  | @ -1,11 +0,0 @@ | |||
| global-include *.cfg | ||||
| global-include *.css *.js | ||||
| global-include *.gif *.jpg *.png | ||||
| global-include *.dmp | ||||
| global-include *.md *.txt | ||||
| global-include *.mo *.po *.pot | ||||
| global-include *.pdf | ||||
| global-include *.pt | ||||
| global-include *.zcml | ||||
| 
 | ||||
| graft loops/integrator/testdata | ||||
|  | @ -1,7 +0,0 @@ | |||
| # Introduction | ||||
| 
 | ||||
| This is the main part of the code of the semantic  | ||||
| web application platform *loops*, based on  | ||||
| Zope 3 / bluebream. | ||||
| 
 | ||||
| More information: see https://www.cyberconcepts.org. | ||||
|  | @ -23,7 +23,7 @@ with lower-level aspects like type or state management. | |||
| 
 | ||||
| Let's also import some common stuff needed later. | ||||
| 
 | ||||
|   >>> from loops.common import adapted, baseObject | ||||
|   >>> from loops.common import adapted | ||||
|   >>> from loops.setup import addAndConfigureObject | ||||
| 
 | ||||
| 
 | ||||
|  | @ -48,14 +48,14 @@ top-level loops container and a concept manager: | |||
|   >>> cc1 = Concept() | ||||
|   >>> concepts['cc1'] = cc1 | ||||
|   >>> cc1.title | ||||
|   '' | ||||
|   u'' | ||||
|   >>> loopsRoot.getLoopsUri(cc1) | ||||
|   '.loops/concepts/cc1' | ||||
|   u'.loops/concepts/cc1' | ||||
| 
 | ||||
|   >>> cc2 = Concept('Zope 3') | ||||
|   >>> cc2 = Concept(u'Zope 3') | ||||
|   >>> concepts['cc2'] = cc2 | ||||
|   >>> cc2.title | ||||
|   'Zope 3' | ||||
|   u'Zope 3' | ||||
| 
 | ||||
| Now we want to relate the second concept to the first one. | ||||
| 
 | ||||
|  | @ -73,11 +73,11 @@ ConceptRelation): | |||
| We can now ask our concepts for their related child and parent concepts: | ||||
| 
 | ||||
|   >>> [getName(c) for c in cc1.getChildren()] | ||||
|   ['cc2'] | ||||
|   [u'cc2'] | ||||
|   >>> len(cc1.getParents()) | ||||
|   0 | ||||
|   >>> [getName(p) for p in cc2.getParents()] | ||||
|   ['cc1'] | ||||
|   [u'cc1'] | ||||
| 
 | ||||
|   >>> len(cc2.getChildren()) | ||||
|   0 | ||||
|  | @ -90,24 +90,24 @@ a special predicate 'hasType'. | |||
|   >>> typeObject = concepts['type'] | ||||
|   >>> typeObject.setConceptType(typeObject) | ||||
|   >>> typeObject.getConceptType().title | ||||
|   'Type' | ||||
|   u'Type' | ||||
| 
 | ||||
|   >>> concepts['unknown'] = Concept('Unknown Type') | ||||
|   >>> concepts['unknown'] = Concept(u'Unknown Type') | ||||
|   >>> unknown = concepts['unknown'] | ||||
|   >>> unknown.setConceptType(typeObject) | ||||
|   >>> unknown.getConceptType().title | ||||
|   'Type' | ||||
|   u'Type' | ||||
| 
 | ||||
|   >>> cc1.setConceptType(unknown) | ||||
|   >>> cc1.getConceptType().title | ||||
|   'Unknown Type' | ||||
|   u'Unknown Type' | ||||
| 
 | ||||
|   >>> concepts['topic'] = Concept('Topic') | ||||
|   >>> concepts['topic'] = Concept(u'Topic') | ||||
|   >>> topic = concepts['topic'] | ||||
|   >>> topic.setConceptType(typeObject) | ||||
|   >>> cc1.setConceptType(topic) | ||||
|   >>> cc1.getConceptType().title | ||||
|   'Topic' | ||||
|   u'Topic' | ||||
| 
 | ||||
| We get a list of types using the ConceptTypeSourceList. | ||||
| In order for the type machinery to work we first have to provide a | ||||
|  | @ -124,7 +124,7 @@ type manager. | |||
|   >>> from loops.concept import ConceptTypeSourceList | ||||
|   >>> types = ConceptTypeSourceList(cc1) | ||||
|   >>> sorted(t.title for t in types) | ||||
|   ['Customer', 'Domain', 'Predicate', 'Topic', 'Type', 'Unknown Type'] | ||||
|   [u'Customer', u'Domain', u'Predicate', u'Topic', u'Type', u'Unknown Type'] | ||||
| 
 | ||||
| Using a PredicateSourceList we can retrieve a list of the available | ||||
| predicates. | ||||
|  | @ -136,7 +136,7 @@ Note that the 'hasType' predicate is suppressed from this list as the | |||
| corresponding relation is only assigned via the conceptType attribute: | ||||
| 
 | ||||
|   >>> sorted(t.title for t in predicates) | ||||
|   ['subobject'] | ||||
|   [u'subobject'] | ||||
| 
 | ||||
| Concept Views | ||||
| ------------- | ||||
|  | @ -146,7 +146,7 @@ Concept Views | |||
| 
 | ||||
|   >>> children = list(view.children()) | ||||
|   >>> [c.title for c in children] | ||||
|   ['Zope 3'] | ||||
|   [u'Zope 3'] | ||||
| 
 | ||||
| The token attribute provided with the items returned by the children() and | ||||
| parents() methods identifies identifies not only the item itself but | ||||
|  | @ -154,19 +154,19 @@ also the relationship to the context object using a combination | |||
| of URIs to item and the predicate of the relationship: | ||||
| 
 | ||||
|   >>> [c.token for c in children] | ||||
|   ['.loops/concepts/cc2:.loops/concepts/standard'] | ||||
|   [u'.loops/concepts/cc2:.loops/concepts/standard'] | ||||
| 
 | ||||
| There is also a concept configuration view that allows updating the | ||||
| underlying context object: | ||||
| 
 | ||||
|   >>> cc3 = Concept('loops for Zope 3') | ||||
|   >>> cc3 = Concept(u'loops for Zope 3') | ||||
|   >>> concepts['cc3'] = cc3 | ||||
|   >>> view = ConceptConfigureView(cc1, | ||||
|   ...           TestRequest(action='assign', tokens=['.loops/concepts/cc3'])) | ||||
|   >>> view.update() | ||||
|   True | ||||
|   >>> sorted(c.title for c in cc1.getChildren()) | ||||
|   ['Zope 3', 'loops for Zope 3'] | ||||
|   [u'Zope 3', u'loops for Zope 3'] | ||||
| 
 | ||||
|   >>> input = {'action': 'remove', 'qualifier': 'children', | ||||
|   ...          'form.button.submit': 'Remove Chiildren', | ||||
|  | @ -175,18 +175,18 @@ underlying context object: | |||
|   >>> view.update() | ||||
|   True | ||||
|   >>> sorted(c.title for c in cc1.getChildren()) | ||||
|   ['loops for Zope 3'] | ||||
|   [u'loops for Zope 3'] | ||||
| 
 | ||||
| We can also create a new concept and assign it. | ||||
| 
 | ||||
|   >>> params = {'action': 'create', 'create.name': 'cc4', | ||||
|   ...           'create.title': 'New concept', | ||||
|   ...           'create.title': u'New concept', | ||||
|   ...           'create.type': '.loops/concepts/topic'} | ||||
|   >>> view = ConceptConfigureView(cc1, TestRequest(**params)) | ||||
|   >>> view.update() | ||||
|   True | ||||
|   >>> sorted(c.title for c in cc1.getChildren()) | ||||
|   ['New concept', 'loops for Zope 3'] | ||||
|   [u'New concept', u'loops for Zope 3'] | ||||
| 
 | ||||
| The concept configuration view provides methods for displaying concept | ||||
| types and predicates. | ||||
|  | @ -198,15 +198,15 @@ types and predicates. | |||
|   >>> component.provideAdapter(LoopsTerms, (IIterableSource, IBrowserRequest), ITerms) | ||||
| 
 | ||||
|   >>> sorted((t.title, t.token) for t in view.conceptTypes()) | ||||
|   [('Customer', '.loops/concepts/customer'), | ||||
|    ('Domain', '.loops/concepts/domain'), | ||||
|    ('Predicate', '.loops/concepts/predicate'), | ||||
|    ('Topic', '.loops/concepts/topic'), | ||||
|    ('Type', '.loops/concepts/type'), | ||||
|    ('Unknown Type', '.loops/concepts/unknown')] | ||||
|   [(u'Customer', '.loops/concepts/customer'), | ||||
|    (u'Domain', '.loops/concepts/domain'), | ||||
|    (u'Predicate', '.loops/concepts/predicate'), | ||||
|    (u'Topic', '.loops/concepts/topic'), | ||||
|    (u'Type', '.loops/concepts/type'), | ||||
|    (u'Unknown Type', '.loops/concepts/unknown')] | ||||
| 
 | ||||
|   >>> sorted((t.title, t.token) for t in view.predicates()) | ||||
|   [('subobject', '.loops/concepts/standard')] | ||||
|   [(u'subobject', '.loops/concepts/standard')] | ||||
| 
 | ||||
| Index attributes adapter | ||||
| ------------------------ | ||||
|  | @ -214,10 +214,10 @@ Index attributes adapter | |||
|   >>> from loops.concept import IndexAttributes | ||||
|   >>> idx = IndexAttributes(cc2) | ||||
|   >>> idx.text() | ||||
|   'cc2 Zope 3' | ||||
|   u'cc2 Zope 3' | ||||
| 
 | ||||
|   >>> idx.title() | ||||
|   'cc2 Zope 3' | ||||
|   u'cc2 Zope 3' | ||||
| 
 | ||||
| 
 | ||||
| Resources and what they have to do with Concepts | ||||
|  | @ -233,27 +233,27 @@ A common type of resource is a document: | |||
| 
 | ||||
|   >>> from loops.interfaces import IDocument | ||||
|   >>> from loops.resource import Document | ||||
|   >>> doc1 = Document('Zope Info') | ||||
|   >>> doc1 = Document(u'Zope Info') | ||||
|   >>> resources['doc1'] = doc1 | ||||
|   >>> doc1.title | ||||
|   'Zope Info' | ||||
|   u'Zope Info' | ||||
|   >>> doc1.data | ||||
|   '' | ||||
|   u'' | ||||
|   >>> doc1.contentType | ||||
|   '' | ||||
|   u'' | ||||
| 
 | ||||
| We can also directly use Resource objects; these behave like files. | ||||
| In fact, by using resource types we can explicitly assign a resource | ||||
| the 'file' type, but we will use this feature later: | ||||
| 
 | ||||
|   >>> img = Resource('A png Image') | ||||
|   >>> img = Resource(u'A png Image') | ||||
| 
 | ||||
| For testing we use some simple files from the tests directory: | ||||
| 
 | ||||
|   >>> from loops import tests | ||||
|   >>> import os | ||||
|   >>> path = os.path.join(*tests.__path__) | ||||
|   >>> img.data = open(os.path.join(path, 'test_icon.png'), 'rb').read() | ||||
|   >>> img.data = open(os.path.join(path, 'test_icon.png')).read() | ||||
|   >>> img.getSize() | ||||
|   381 | ||||
|   >>> img.getImageSize() | ||||
|  | @ -261,8 +261,8 @@ For testing we use some simple files from the tests directory: | |||
|   >>> img.contentType | ||||
|   'image/png' | ||||
| 
 | ||||
|   >>> pdf = Resource('A pdf File') | ||||
|   >>> pdf.data = open(os.path.join(path, 'test.pdf'), 'rb').read() | ||||
|   >>> pdf = Resource(u'A pdf File') | ||||
|   >>> pdf.data = open(os.path.join(path, 'test.pdf')).read() | ||||
|   >>> pdf.getSize() | ||||
|   25862 | ||||
|   >>> pdf.getImageSize() | ||||
|  | @ -287,7 +287,7 @@ from concepts to resources: | |||
|   ...         'tokens': ['.loops/resources/doc1:.loops/concepts/standard']} | ||||
|   >>> view = ConceptConfigureView(cc1, TestRequest(form=form)) | ||||
|   >>> [getName(r.context) for r in view.resources()] | ||||
|   ['doc1'] | ||||
|   [u'doc1'] | ||||
|   >>> view.update() | ||||
|   True | ||||
|   >>> len(cc1.getResources()) | ||||
|  | @ -316,10 +316,10 @@ Index attributes adapter | |||
|   >>> component.provideAdapter(FileAdapter, provides=IFile) | ||||
|   >>> idx = IndexAttributes(doc1) | ||||
|   >>> idx.text() | ||||
|   '' | ||||
|   u'' | ||||
| 
 | ||||
|   >>> idx.title() | ||||
|   'doc1 Zope Info' | ||||
|   u'doc1 Zope Info' | ||||
| 
 | ||||
| 
 | ||||
| Views/Nodes: Menus, Menu Items, Listings, Pages, etc | ||||
|  | @ -343,14 +343,14 @@ The view manager has already been created during setup. | |||
| The view space is typically built up with nodes; a node may be a top-level | ||||
| menu that may contain other nodes as menu or content items: | ||||
| 
 | ||||
|   >>> m1 = views['m1'] = Node('Menu') | ||||
|   >>> m11 = m1['m11'] = Node('Zope') | ||||
|   >>> m111 = m11['m111'] = Node('Zope in General') | ||||
|   >>> m112 = m11['m112'] = Node('Zope 3') | ||||
|   >>> m1 = views['m1'] = Node(u'Menu') | ||||
|   >>> m11 = m1['m11'] = Node(u'Zope') | ||||
|   >>> m111 = m11['m111'] = Node(u'Zope in General') | ||||
|   >>> m112 = m11['m112'] = Node(u'Zope 3') | ||||
|   >>> m112.title | ||||
|   'Zope 3' | ||||
|   u'Zope 3' | ||||
|   >>> m112.description | ||||
|   '' | ||||
|   u'' | ||||
| 
 | ||||
| There are a few convienence methods for accessing parent and child nodes: | ||||
| 
 | ||||
|  | @ -359,7 +359,7 @@ There are a few convienence methods for accessing parent and child nodes: | |||
|   >>> m11.getParentNode() is m1 | ||||
|   True | ||||
|   >>> [getName(child) for child in m11.getChildNodes()] | ||||
|   ['m111', 'm112'] | ||||
|   [u'm111', u'm112'] | ||||
| 
 | ||||
| What is returned by these may be controlled by the nodeType attribute: | ||||
| 
 | ||||
|  | @ -444,13 +444,13 @@ Node Views | |||
|   >>> page = view.page | ||||
|   >>> items = page.textItems | ||||
|   >>> for item in items: | ||||
|   ...     print(item.url, item.editable) | ||||
|   ...     print item.url, item.editable | ||||
|   http://127.0.0.1/loops/views/m1/m11/m112 False | ||||
| 
 | ||||
|   >>> menu = view.menu | ||||
|   >>> items = menu.menuItems | ||||
|   >>> for item in items: | ||||
|   ...     print(item.url, view.selected(item)) | ||||
|   ...     print item.url, view.selected(item) | ||||
|   http://127.0.0.1/loops/views/m1/m11 True | ||||
| 
 | ||||
| A NodeView provides an itemNum attribute that may be used to count elements | ||||
|  | @ -493,14 +493,14 @@ view; these views we have to provide as multi-adapters: | |||
|   >>> len(tt) | ||||
|   9 | ||||
|   >>> sorted((t.token, t.title) for t in view.targetTypes())[1] | ||||
|   ('.loops/concepts/domain', 'Domain') | ||||
|   ('.loops/concepts/domain', u'Domain') | ||||
|   >>> view.update() | ||||
|   True | ||||
|   >>> sorted(resources.keys()) | ||||
|   ['d001.txt', 'd002.txt', 'd003.txt', 'doc1', 'm1.m11.m111'] | ||||
|   [u'd001.txt', u'd002.txt', u'd003.txt', u'doc1', u'm1.m11.m111'] | ||||
| 
 | ||||
|   >>> view.target.title, view.target.token | ||||
|   ('New Resource', '.loops/resources/m1.m11.m111') | ||||
|   ('New Resource', u'.loops/resources/m1.m11.m111') | ||||
| 
 | ||||
| A node object provides the targetSchema of its target: | ||||
| 
 | ||||
|  | @ -537,28 +537,28 @@ view for rendering.) | |||
|   >>> component.provideAdapter(LoopsType) | ||||
|   >>> view = NodeView(m112, TestRequest()) | ||||
|   >>> view.renderTarget() | ||||
|   '<pre></pre>' | ||||
|   >>> doc1.data = 'Test data\n\nAnother paragraph' | ||||
|   u'<pre></pre>' | ||||
|   >>> doc1.data = u'Test data\n\nAnother paragraph' | ||||
|   >>> view.renderTarget() | ||||
|   '<pre>Test data\n\nAnother paragraph</pre>' | ||||
|   u'<pre>Test data\n\nAnother paragraph</pre>' | ||||
| 
 | ||||
|   >>> doc1.contentType = 'text/restructured' | ||||
|   >>> doc1.data = 'Test data\n\nAnother `paragraph <para>`_' | ||||
|   >>> doc1.data = u'Test data\n\nAnother `paragraph <para>`_' | ||||
| 
 | ||||
|   >>> from loops.wiki.base import wikiLinksActive | ||||
|   >>> wikiLinksActive(loopsRoot) | ||||
|   False | ||||
| 
 | ||||
|   >>> view.renderTarget() | ||||
|   '<p>Test data</p>\n<p>Another <a class="reference external" href="para">paragraph</a></p>\n' | ||||
|   u'<p>Test data</p>\n<p>Another <a class="reference external" href="para">paragraph</a></p>\n' | ||||
| 
 | ||||
| '<p>Test data</p>\n<p>Another <a class="reference create" | ||||
| u'<p>Test data</p>\n<p>Another <a class="reference create" | ||||
|     href="http://127.0.0.1/loops/wiki/create.html?linkid=0000001">?paragraph</a></p>\n' | ||||
| 
 | ||||
|   >>> #links = loopsRoot.getRecordManager()['links'] | ||||
|   >>> #links['0000001'] | ||||
| 
 | ||||
| <Link ['42', 1, '', '... ...', 'para', None]: {}> | ||||
| <Link ['42', 1, '', '... ...', u'para', None]: {}> | ||||
| 
 | ||||
| If the target object is removed from its container all references | ||||
| to it are removed as well. (To make this work we have to handle | ||||
|  | @ -632,7 +632,7 @@ Let's add some more nodes and reorder them: | |||
|   >>> m114 = Node() | ||||
|   >>> m11['m114'] = m114 | ||||
|   >>> m11.keys() | ||||
|   ['m111', 'm112', 'm113', 'm114'] | ||||
|   [u'm111', u'm112', u'm113', u'm114'] | ||||
| 
 | ||||
| A special management view provides methods for moving objects down, up, | ||||
| to the bottom, and to the top. | ||||
|  | @ -641,10 +641,10 @@ to the bottom, and to the top. | |||
|   >>> view = OrderedContainerView(m11, TestRequest()) | ||||
|   >>> view.move_bottom(('m113',)) | ||||
|   >>> m11.keys() | ||||
|   ['m111', 'm112', 'm114', 'm113'] | ||||
|   [u'm111', u'm112', u'm114', u'm113'] | ||||
|   >>> view.move_up(('m114',), 1) | ||||
|   >>> m11.keys() | ||||
|   ['m111', 'm114', 'm112', 'm113'] | ||||
|   [u'm111', u'm114', u'm112', u'm113'] | ||||
| 
 | ||||
| 
 | ||||
| Breadcrumbs | ||||
|  | @ -661,9 +661,9 @@ Breadcrumbs | |||
|   >>> view = NodeView(m114, request) | ||||
|   >>> request.annotations.setdefault('loops.view', {})['nodeView'] = view | ||||
|   >>> view.breadcrumbs() | ||||
|   [{'label': 'Menu', 'url': 'http://127.0.0.1/loops/views/m1'}, | ||||
|    {'label': 'Zope', 'url': 'http://127.0.0.1/loops/views/m1/m11'}, | ||||
|    {'label': '', 'url': 'http://127.0.0.1/loops/views/m1/m11/m114'}] | ||||
|   [{'url': 'http://127.0.0.1/loops/views/m1', 'label': u'Menu'}, | ||||
|    {'url': 'http://127.0.0.1/loops/views/m1/m11', 'label': u'Zope'}, | ||||
|    {'url': 'http://127.0.0.1/loops/views/m1/m11/m114', 'label': u''}] | ||||
| 
 | ||||
| 
 | ||||
| End-user Forms and Special Views | ||||
|  | @ -705,8 +705,8 @@ been created during setup. | |||
|   >>> custType = TypeConcept(customer) | ||||
|   >>> custType.options | ||||
|   [] | ||||
|   >>> cust1 = concepts['cust1'] = Concept('Zope Corporation') | ||||
|   >>> cust2 = concepts['cust2'] = Concept('cyberconcepts') | ||||
|   >>> cust1 = concepts['cust1'] = Concept(u'Zope Corporation') | ||||
|   >>> cust2 = concepts['cust2'] = Concept(u'cyberconcepts') | ||||
|   >>> for c in (cust1, cust2): c.conceptType = customer | ||||
|   >>> custType.options = ('qualifier:assign',) | ||||
|   >>> ConceptType(cust1).qualifiers | ||||
|  | @ -714,7 +714,7 @@ been created during setup. | |||
| 
 | ||||
|   >>> form = CreateObjectForm(m112, TestRequest()) | ||||
|   >>> form.presetTypesForAssignment | ||||
|   [{'title': 'Customer', 'token': 'loops:concept:customer'}] | ||||
|   [{'token': 'loops:concept:customer', 'title': u'Customer'}] | ||||
| 
 | ||||
| If the node's target is a type concept we don't get any assignments because | ||||
| it does not make much sense to assign resources or other concepts as | ||||
|  | @ -736,18 +736,16 @@ on data provided in this form: | |||
|   >>> note_tc = concepts['note'] | ||||
| 
 | ||||
|   >>> component.provideAdapter(NameChooser) | ||||
|   >>> request = TestRequest(form={'title': 'Test Note', | ||||
|   ...                             'form.type': '.loops/concepts/note', | ||||
|   ...                             'contentType': 'text/restructured', | ||||
|   ...                             'linkUrl': 'http://'}) | ||||
|   >>> request = TestRequest(form={'title': u'Test Note', | ||||
|   ...                             'form.type': u'.loops/concepts/note'}) | ||||
|   >>> view = NodeView(m112, request) | ||||
|   >>> cont = CreateObject(view, request) | ||||
|   >>> cont.update() | ||||
|   False | ||||
|   >>> sorted(resources.keys()) | ||||
|   [...'test_note'...] | ||||
|   [...u'test_note'...] | ||||
|   >>> resources['test_note'].title | ||||
|   'Test Note' | ||||
|   u'Test Note' | ||||
| 
 | ||||
| If there is a concept selected in the combo box we assign this to the newly | ||||
| created object: | ||||
|  | @ -755,8 +753,8 @@ created object: | |||
|   >>> from loops import util | ||||
|   >>> topicUid = util.getUidForObject(topic) | ||||
|   >>> predicateUid = util.getUidForObject(concepts.getDefaultPredicate()) | ||||
|   >>> request = TestRequest(form={'title': 'Test Note', | ||||
|   ...                             'form.type': '.loops/concepts/note', | ||||
|   >>> request = TestRequest(form={'title': u'Test Note', | ||||
|   ...                             'form.type': u'.loops/concepts/note', | ||||
|   ...                             'form.assignments.selected': | ||||
|   ...                                   [':'.join((topicUid, predicateUid))]}) | ||||
|   >>> view = NodeView(m112, request) | ||||
|  | @ -764,22 +762,22 @@ created object: | |||
|   >>> cont.update() | ||||
|   False | ||||
|   >>> sorted(resources.keys()) | ||||
|   [...'test_note-2'...] | ||||
|   [...u'test_note-2'...] | ||||
|   >>> note = resources['test_note-2'] | ||||
|   >>> sorted(t.__name__ for t in note.getConcepts()) | ||||
|   ['note', 'topic'] | ||||
|   [u'note', u'topic'] | ||||
| 
 | ||||
| When creating an object its name may be automatically generated using the title | ||||
| of the object. Let's make sure that the name chooser also handles special | ||||
| and possibly critcal cases: | ||||
| 
 | ||||
|   >>> nc = NameChooser(resources) | ||||
|   >>> nc.chooseName('', Resource('abc: (cde)')) | ||||
|   'abc__cde' | ||||
|   >>> nc.chooseName('', Resource('\xdcml\xe4ut')) | ||||
|   'uemlaeut' | ||||
|   >>> nc.chooseName('', Resource('A very very loooooong title')) | ||||
|   'a_title' | ||||
|   >>> nc.chooseName(u'', Resource(u'abc: (cde)')) | ||||
|   u'abc__cde' | ||||
|   >>> nc.chooseName(u'', Resource(u'\xdcml\xe4ut')) | ||||
|   u'uemlaeut' | ||||
|   >>> nc.chooseName(u'', Resource(u'A very very loooooong title')) | ||||
|   u'a_title' | ||||
| 
 | ||||
| Editing an Object | ||||
| ----------------- | ||||
|  | @ -796,7 +794,7 @@ that in turns calls formlibs ``setUpWidgets()``. | |||
| The new technique uses the ``fields`` and ``data`` attributes... | ||||
| 
 | ||||
|   >>> for f in view.fields: | ||||
|   ...     print(f.name, f.fieldType, f.required, f.vocabulary) | ||||
|   ...     print f.name, f.fieldType, f.required, f.vocabulary | ||||
|   title textline True None | ||||
|   data textarea False None | ||||
|   contentType dropdown True <...SimpleVocabulary object...> | ||||
|  | @ -804,22 +802,22 @@ The new technique uses the ``fields`` and ``data`` attributes... | |||
|   linkText textline False None | ||||
| 
 | ||||
|   >>> view.data | ||||
|   {'title': 'Test Note', 'data': '', 'contentType': 'text/restructured',  | ||||
|    'linkUrl': 'http://', 'linkText': ''} | ||||
|   {'linkUrl': u'http://', 'contentType': 'text/restructured', 'data': u'', | ||||
|    'linkText': u'', 'title': u'Test Note'} | ||||
| 
 | ||||
| The object is changed via a FormController adapter created for | ||||
| a NodeView. | ||||
| 
 | ||||
|   >>> form = dict( | ||||
|   ...     title='Test Note - changed', | ||||
|   ...     contentType='text/plain',) | ||||
|   ...     title=u'Test Note - changed', | ||||
|   ...     contentType=u'text/plain',) | ||||
|   >>> request = TestRequest(form=form) | ||||
|   >>> view = NodeView(m112, request) | ||||
|   >>> cont = EditObject(view, request) | ||||
|   >>> cont.update() | ||||
|   False | ||||
|   >>> resources['test_note'].title | ||||
|   'Test Note - changed' | ||||
|   u'Test Note - changed' | ||||
| 
 | ||||
| Virtual Targets | ||||
| --------------- | ||||
|  | @ -883,13 +881,13 @@ informations about all parents of an object. | |||
| 
 | ||||
|   >>> parents = m113.getAllParents() | ||||
|   >>> for p in parents: | ||||
|   ...     print(p.object.title) | ||||
|   ...     print p.object.title | ||||
|   Zope | ||||
|   Menu | ||||
| 
 | ||||
|   >>> parents = resources['test_note'].getAllParents() | ||||
|   >>> for p in parents: | ||||
|   ...     print(p.object.title, len(p.relations)) | ||||
|   ...     print p.object.title, len(p.relations) | ||||
|   Note 1 | ||||
|   Type 2 | ||||
| 
 | ||||
|  | @ -915,32 +913,6 @@ relates ISO country codes with the full name of the country. | |||
|   >>> sorted(adapted(concepts['countries']).data.items()) | ||||
|   [('at', ['Austria']), ('de', ['Germany'])] | ||||
| 
 | ||||
|   >>> countries.dataAsRecords() | ||||
|   [{'key': 'at', 'value': 'Austria'}, {'key': 'de', 'value': 'Germany'}] | ||||
| 
 | ||||
|   >>> countries.getRowsByValue('value', 'Germany') | ||||
|   [{'key': 'de', 'value': 'Germany'}] | ||||
| 
 | ||||
| The ``recordstable`` type is a variation of this datable type that contains | ||||
| a simple list of records - without a key column. A record in this  type is a | ||||
| dictionary with the field name as key and the field value as value. | ||||
| 
 | ||||
|   >>> from loops.table import IRecordsTable, RecordsTable | ||||
|   >>> component.provideAdapter(RecordsTable, provides=IRecordsTable) | ||||
| 
 | ||||
|   >>> drType = addAndConfigureObject(concepts, Concept, 'recordstable', | ||||
|   ...                   title='Records Table', conceptType=concepts['type'], | ||||
|   ...                   typeInterface=IRecordsTable) | ||||
| 
 | ||||
| We just reuse the existing ``countries`` table and convert it to a records table. | ||||
| 
 | ||||
|   >>> baseObject(countries).setType(drType) | ||||
| 
 | ||||
|   >>> countries = adapted(concepts['countries']) | ||||
| 
 | ||||
|   >>> countries.data | ||||
|   [{'key': 'at', 'value': 'Austria'}, {'key': 'de', 'value': 'Germany'}] | ||||
| 
 | ||||
| 
 | ||||
| Caching | ||||
| ======= | ||||
|  | @ -951,7 +923,7 @@ To be done... | |||
|   >>> obj = resources['test_note'] | ||||
|   >>> cxObj = cached(obj) | ||||
|   >>> [p.object.title for p in cxObj.getAllParents()] | ||||
|   ['Note', 'Type'] | ||||
|   [u'Note', u'Type'] | ||||
| 
 | ||||
| 
 | ||||
| Security | ||||
|  | @ -960,12 +932,6 @@ Security | |||
|   >>> from loops.security.browser import admin, audit | ||||
| 
 | ||||
| 
 | ||||
| Paster Shell Utilities - Repair Scripts | ||||
| ======================================= | ||||
| 
 | ||||
|   >>> from loops.repair.base import removeRecords | ||||
| 
 | ||||
| 
 | ||||
| Import/Export | ||||
| ============= | ||||
| 
 | ||||
							
								
								
									
										22
									
								
								__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,22 @@ | |||
| # | ||||
| #  Copyright (c) 2008 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ | ||||
| 
 | ||||
| $Id$ | ||||
| """ | ||||
|  | @ -1,13 +1,32 @@ | |||
| # loops.base | ||||
| # -*- coding: UTF-8 -*- | ||||
| # -*- Mode: Python; py-indent-offset: 4 -*- | ||||
| # | ||||
| #  Copyright (c) 2019 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Implementation of loops root object. | ||||
| """ | ||||
| The loops container class. | ||||
| """ | ||||
| 
 | ||||
| from zope.container.btree import BTreeContainer | ||||
| from zope.site.folder import Folder | ||||
| from zope.site.interfaces import IFolder | ||||
| from zope.app.container.btree import BTreeContainer | ||||
| from zope.app.folder.folder import Folder | ||||
| from zope.app.folder.interfaces import IFolder | ||||
| from zope.traversing.api import getPath, traverse | ||||
| from zope.interface import implementer | ||||
| from zope.interface import implements | ||||
| 
 | ||||
| from cybertools.util.jeep import Jeep | ||||
| from loops.interfaces import ILoops | ||||
|  | @ -15,8 +34,17 @@ from loops.interfaces import ILoops | |||
| loopsPrefix = '.loops' | ||||
| 
 | ||||
| 
 | ||||
| @implementer(ILoops) | ||||
| class Loops(Folder): | ||||
| #class Loops(BTreeContainer): | ||||
| 
 | ||||
|     implements(ILoops) | ||||
| 
 | ||||
|     #def getSiteManager(self): | ||||
|     #    return self.__parent__.getSiteManager() | ||||
| 
 | ||||
|     #@property | ||||
|     #def _SampleContainer__data(self): | ||||
|     #    return self.data | ||||
| 
 | ||||
|     _skinName = '' | ||||
|     def getSkinName(self): return self._skinName | ||||
|  | @ -46,7 +74,10 @@ class Loops(Folder): | |||
|         return self.get('records') | ||||
| 
 | ||||
|     def getLoopsUri(self, obj): | ||||
|         #return str(loopsPrefix + getPath(obj)[len(getPath(self)):]) | ||||
|         uri = loopsPrefix + getPath(obj)[len(getPath(self)):] | ||||
|         #if isinstance(uri, unicode): | ||||
|         #    uri = uri.encode('UTF-8') | ||||
|         return uri | ||||
| 
 | ||||
|     def loopsTraverse(self, uri): | ||||
|  | @ -1,9 +1,26 @@ | |||
| # loops.browser.action | ||||
| # | ||||
| #  Copyright (c) 2013 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Base classes (sort of views) for action portlet items. | ||||
| """ | ||||
| Base classes (sort of views) for action portlet items. | ||||
| """ | ||||
| 
 | ||||
| from urllib.parse import urlencode | ||||
| from urllib import urlencode | ||||
| from zope import component | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
|  | @ -75,8 +92,6 @@ class DialogAction(Action): | |||
|             urlParams['fixed_type'] = 'yes' | ||||
|         if self.viewTitle: | ||||
|             urlParams['view_title'] = self.viewTitle | ||||
|         #for k, v in self.page.sortInfo.items(): | ||||
|         #    urlParams['sortinfo_' + k] = v['fparam'] | ||||
|         urlParams.update(self.addParams) | ||||
|         if self.target is not None: | ||||
|             url = self.page.getUrlForTarget(self.target) | ||||
|  | @ -1,18 +1,35 @@ | |||
| # loops.browser.auth | ||||
| # | ||||
| #  Copyright (c) 2015 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Login, logout, unauthorized stuff. | ||||
| """ | ||||
| Login, logout, unauthorized stuff. | ||||
| """ | ||||
| 
 | ||||
| from zope.app.exception.browser.unauthorized import Unauthorized as DefaultUnauth | ||||
| from zope.authentication.interfaces import IAuthentication | ||||
| from zope.authentication.interfaces import ILogout, IUnauthenticatedPrincipal | ||||
| from zope.browserpage import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope.app.security.interfaces import IAuthentication | ||||
| from zope.app.security.interfaces import ILogout, IUnauthenticatedPrincipal | ||||
| from zope import component | ||||
| from zope.interface import implementer | ||||
| from zope.interface import implements | ||||
| 
 | ||||
| from loops.browser.concept import ConceptView | ||||
| from loops.browser.node import NodeView | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| 
 | ||||
| 
 | ||||
| template = ViewPageTemplateFile('auth.pt') | ||||
|  | @ -40,9 +57,9 @@ class LoginForm(NodeView): | |||
|         return self | ||||
| 
 | ||||
| 
 | ||||
| @implementer(ILogout) | ||||
| class Logout(object): | ||||
| 
 | ||||
|     implements(ILogout) | ||||
| 
 | ||||
|     def __init__(self, context, request): | ||||
|         self.context = context | ||||
|  | @ -50,11 +67,10 @@ class Logout(object): | |||
| 
 | ||||
|     def __call__(self): | ||||
|         nextUrl = self.request.get('nextURL') or self.request.URL[-1] | ||||
|         nx = self.request.response.redirect(nextUrl) | ||||
|         if not IUnauthenticatedPrincipal.providedBy(self.request.principal): | ||||
|             auth = component.getUtility(IAuthentication) | ||||
|             ILogout(auth).logout(self.request) | ||||
|         return nx | ||||
|         return self.request.response.redirect(nextUrl) | ||||
| 
 | ||||
| 
 | ||||
| class Unauthorized(ConceptView): | ||||
|  | @ -1,28 +1,46 @@ | |||
| # loops.browser.common | ||||
| # | ||||
| #  Copyright (c) 2016 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Common base class for loops browser view classes. | ||||
| """ | ||||
| Common base class for loops browser view classes. | ||||
| """ | ||||
| 
 | ||||
| from cgi import parse_qs, parse_qsl | ||||
| #import mimetypes   # use more specific assignments from cybertools.text | ||||
| from datetime import date, datetime | ||||
| from datetime import datetime | ||||
| from logging import getLogger | ||||
| import re | ||||
| from time import strptime | ||||
| from urllib.parse import parse_qs, parse_qsl, urlencode | ||||
| from urllib import urlencode | ||||
| from zope import component | ||||
| from zope.authentication.interfaces import IAuthentication, IUnauthenticatedPrincipal | ||||
| from zope.authentication.interfaces import IUnauthenticatedPrincipal | ||||
| from zope.authentication.interfaces import PrincipalLookupError | ||||
| from zope.browser.interfaces import ITerms | ||||
| from zope.browserpage import ViewPageTemplateFile | ||||
| from zope.app.form.browser.interfaces import ITerms | ||||
| from zope.app.i18n.interfaces import ITranslationDomain | ||||
| from zope.app.security.interfaces import IAuthentication, IUnauthenticatedPrincipal | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.app.security.interfaces import IUnauthenticatedPrincipal | ||||
| from zope.app.security.interfaces import PrincipalLookupError | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope.dottedname.resolve import resolve | ||||
| from zope.dublincore.interfaces import IZopeDublinCore | ||||
| from zope.formlib import form | ||||
| from zope.formlib.form import FormFields | ||||
| from zope.formlib.namedtemplate import NamedTemplate | ||||
| from zope.i18n.interfaces import ITranslationDomain | ||||
| from zope.interface import Interface, implementer | ||||
| from zope.interface import Interface, implements | ||||
| from zope.proxy import removeAllProxies | ||||
| from zope.publisher.browser import applySkin | ||||
| from zope.publisher.interfaces.browser import IBrowserSkinType, IBrowserView | ||||
|  | @ -44,21 +62,17 @@ from cybertools.stateful.interfaces import IStateful | |||
| from cybertools.text import mimetypes | ||||
| from cybertools.typology.interfaces import IType, ITypeManager | ||||
| from cybertools.util.date import toLocalTime | ||||
| from cybertools.util.format import formatDate | ||||
| from cybertools.util.jeep import Jeep | ||||
| from loops.browser.util import normalizeForUrl | ||||
| from loops.common import adapted, baseObject | ||||
| from loops.config.base import DummyOptions | ||||
| from loops.i18n.browser import I18NView | ||||
| from loops.interfaces import IResource, IView, INode, ITypeConcept | ||||
| from loops.organize.personal import favorite | ||||
| from loops.organize.party import getPersonForUser | ||||
| from loops.organize.tracking import access | ||||
| from loops.organize.util import getRolesForPrincipal | ||||
| from loops.resource import Resource | ||||
| from loops.security.common import checkPermission | ||||
| from loops.security.common import canAccessObject, canListObject, canWriteObject | ||||
| from loops.security.common import canEditRestricted | ||||
| from loops.type import ITypeConcept, LoopsTypeInfo | ||||
| from loops import util | ||||
| from loops.util import _, saveRequest | ||||
|  | @ -123,58 +137,7 @@ class EditForm(form.EditForm): | |||
|         return parentUrl + '/contents.html' | ||||
| 
 | ||||
| 
 | ||||
| class SortableMixin(object): | ||||
| 
 | ||||
|     @Lazy | ||||
|     def sortInfo(self): | ||||
|         result = {} | ||||
|         for k, v in self.request.form.items(): | ||||
|             if k.startswith('sortinfo_'): | ||||
|                 tableName = k[len('sortinfo_'):] | ||||
|                 if ',' in v: | ||||
|                     fn, dir = v.split(',') | ||||
|                 else: | ||||
|                     fn = v | ||||
|                     dir = 'asc' | ||||
|                 result[tableName] = dict( | ||||
|                     colName=fn, ascending=(dir=='asc'), fparam=v) | ||||
|         result = favorite.updateSortInfo(getPersonForUser( | ||||
|                         self.context, self.request), self.target, result) | ||||
|         return result | ||||
| 
 | ||||
|     def isSortableColumn(self, tableName, colName): | ||||
|         return False    # overwrite in subclass | ||||
| 
 | ||||
|     def getSortUrl(self, tableName, colName): | ||||
|         url = str(self.request.URL) | ||||
|         paramChar = '?' in url and '&' or '?' | ||||
|         si = self.sortInfo.get(tableName) | ||||
|         if si is not None and si.get('colName') == colName: | ||||
|             dir = si['ascending'] and 'desc' or 'asc' | ||||
|         else: | ||||
|             dir = 'asc' | ||||
|         return '%s%ssortinfo_%s=%s,%s' % (url, paramChar, tableName, colName, dir) | ||||
| 
 | ||||
|     def getSortParams(self, tableName): | ||||
|         url = str(self.request.URL) | ||||
|         paramChar = '?' in url and '&' or '?' | ||||
|         si = self.sortInfo.get(tableName) | ||||
|         if si is not None: | ||||
|             colName = si['colName'] | ||||
|             dir = si['ascending'] and 'asc' or 'desc' | ||||
|             return '%ssortinfo_%s=%s,%s' % (paramChar, tableName, colName, dir) | ||||
|         return '' | ||||
| 
 | ||||
|     def getSortImage(self, tableName, colName): | ||||
|         si = self.sortInfo.get(tableName) | ||||
|         if si is not None and si.get('colName') == colName: | ||||
|             if si['ascending']: | ||||
|                 return '/@@/cybertools.icons/arrowdown.gif' | ||||
|             else: | ||||
|                 return '/@@/cybertools.icons/arrowup.gif' | ||||
| 
 | ||||
| 
 | ||||
| class BaseView(GenericView, I18NView, SortableMixin): | ||||
| class BaseView(GenericView, I18NView): | ||||
| 
 | ||||
|     actions = {} | ||||
|     portlet_actions = [] | ||||
|  | @ -183,7 +146,6 @@ class BaseView(GenericView, I18NView, SortableMixin): | |||
|     icon = None | ||||
|     modeName = 'view' | ||||
|     isToplevel = False | ||||
|     isVisible = True | ||||
| 
 | ||||
|     def __init__(self, context, request): | ||||
|         context = baseObject(context) | ||||
|  | @ -201,10 +163,6 @@ class BaseView(GenericView, I18NView, SortableMixin): | |||
|             pass | ||||
|         saveRequest(request) | ||||
| 
 | ||||
|     def todayFormatted(self): | ||||
|         return formatDate(date.today(), 'date', 'short', | ||||
|                           self.languageInfo.language) | ||||
| 
 | ||||
|     def checkPermissions(self): | ||||
|         return canAccessObject(self.context) | ||||
| 
 | ||||
|  | @ -256,16 +214,6 @@ class BaseView(GenericView, I18NView, SortableMixin): | |||
|                 result.append(view) | ||||
|         return result | ||||
| 
 | ||||
|     @Lazy | ||||
|     def urlParamString(self): | ||||
|         return self.getUrlParamString() | ||||
| 
 | ||||
|     def getUrlParamString(self): | ||||
|         qs = self.request.get('QUERY_STRING') | ||||
|         if qs: | ||||
|             return '?' + qs | ||||
|         return '' | ||||
| 
 | ||||
|     @Lazy | ||||
|     def principalId(self): | ||||
|         principal = self.request.principal | ||||
|  | @ -399,10 +347,6 @@ class BaseView(GenericView, I18NView, SortableMixin): | |||
|     def isPartOfPredicate(self): | ||||
|         return self.conceptManager.get('ispartof') | ||||
| 
 | ||||
|     @Lazy | ||||
|     def queryTargetPredicate(self): | ||||
|         return self.conceptManager.get('querytarget') | ||||
| 
 | ||||
|     @Lazy | ||||
|     def memberPredicate(self): | ||||
|         return self.conceptManager.get('ismember') | ||||
|  | @ -451,10 +395,6 @@ class BaseView(GenericView, I18NView, SortableMixin): | |||
|     def description(self): | ||||
|         return self.adapted.description | ||||
| 
 | ||||
|     @Lazy | ||||
|     def tabTitle(self): | ||||
|         return u'Info' | ||||
| 
 | ||||
|     @Lazy | ||||
|     def additionalInfos(self): | ||||
|         return [] | ||||
|  | @ -807,8 +747,6 @@ class BaseView(GenericView, I18NView, SortableMixin): | |||
|         return result | ||||
| 
 | ||||
|     def checkState(self): | ||||
|         if checkPermission('loops.ManageSite', self.context): | ||||
|             return True | ||||
|         if not self.allStates: | ||||
|             return True | ||||
|         for stf in self.allStates: | ||||
|  | @ -883,10 +821,6 @@ class BaseView(GenericView, I18NView, SortableMixin): | |||
|     def canAccessRestricted(self): | ||||
|         return checkPermission('loops.ViewRestricted', self.context) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def canEditRestricted(self): | ||||
|         return canEditRestricted(self.context) | ||||
| 
 | ||||
|     def openEditWindow(self, viewName='edit.html'): | ||||
|         if self.editable: | ||||
|             if checkPermission('loops.ManageSite', self.context): | ||||
|  | @ -895,7 +829,6 @@ class BaseView(GenericView, I18NView, SortableMixin): | |||
| 
 | ||||
|     @Lazy | ||||
|     def xeditable(self): | ||||
|         return False | ||||
|         if self.typeOptions('no_external_edit'): | ||||
|             return False | ||||
|         ct = getattr(self.context, 'contentType', '') | ||||
|  | @ -1010,12 +943,6 @@ class BaseView(GenericView, I18NView, SortableMixin): | |||
|         jsCall = 'dojo.require("dojox.image.Lightbox");' | ||||
|         self.controller.macros.register('js-execute', jsCall, jsCall=jsCall) | ||||
| 
 | ||||
|     def registerDojoComboBox(self): | ||||
|         self.registerDojo() | ||||
|         jsCall = ('dojo.require("dijit.form.ComboBox");') | ||||
|         self.controller.macros.register('js-execute', | ||||
|                 'dojo.require.ComboBox', jsCall=jsCall) | ||||
| 
 | ||||
|     def registerDojoFormAll(self): | ||||
|         self.registerDojo() | ||||
|         self.registerDojoEditor() | ||||
|  | @ -1069,17 +996,17 @@ class LoggedIn(object): | |||
|             params = parse_qsl(qs) | ||||
|         params = [(k, v) for k, v in params if k != 'loops.messages.top:record'] | ||||
|         params.append(('loops.messages.top:record', message.encode('UTF-8'))) | ||||
|         url = url.encode('utf-8') | ||||
|         return '%s?%s' % (url, urlencode(params)) | ||||
| 
 | ||||
| # vocabulary stuff | ||||
| 
 | ||||
| @implementer(ITerms) | ||||
| class SimpleTerms(object): | ||||
|     """ Provide the ITerms interface, e.g. for usage in selection | ||||
|         lists. | ||||
|     """ | ||||
| 
 | ||||
|     implements(ITerms) | ||||
| 
 | ||||
|     def __init__(self, source, request): | ||||
|         # the source parameter is a list of tuples (token, title). | ||||
|         self.source = source | ||||
|  | @ -1094,12 +1021,13 @@ class SimpleTerms(object): | |||
|         return (token, self.terms[token]) | ||||
| 
 | ||||
| 
 | ||||
| @implementer(ITerms) | ||||
| class LoopsTerms(object): | ||||
|     """ Provide the ITerms interface, e.g. for usage in selection | ||||
|         lists. | ||||
|     """ | ||||
| 
 | ||||
|     implements(ITerms) | ||||
| 
 | ||||
|     def __init__(self, source, request): | ||||
|         # the source parameter is a view or adapter of a real context object: | ||||
|         self.source = source | ||||
|  | @ -1121,11 +1049,12 @@ class LoopsTerms(object): | |||
|         return self.loopsRoot.loopsTraverse(token) | ||||
| 
 | ||||
| 
 | ||||
| @implementer(ITerms) | ||||
| class InterfaceTerms(object): | ||||
|     """ Provide the ITerms interface for source list of interfaces. | ||||
|     """ | ||||
| 
 | ||||
|     implements(ITerms) | ||||
| 
 | ||||
|     def __init__(self, source, request): | ||||
|         self.source = source | ||||
|         self.request = request | ||||
|  | @ -1,22 +1,40 @@ | |||
| # loops.browser.concept | ||||
| # | ||||
| #  Copyright (c) 2013 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Definition of the concept view classes. | ||||
| """ | ||||
| Definition of the concept view classes. | ||||
| """ | ||||
| 
 | ||||
| from itertools import groupby | ||||
| from zope import interface, component, schema | ||||
| from zope.authentication.interfaces import IUnauthenticatedPrincipal | ||||
| from zope.browser.interfaces import ITerms | ||||
| from zope.browserpage import ViewPageTemplateFile | ||||
| from zope.app.catalog.interfaces import ICatalog | ||||
| from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent | ||||
| from zope.app.container.contained import ObjectRemovedEvent | ||||
| from zope.app.form.browser.interfaces import ITerms | ||||
| from zope.app.form.interfaces import IDisplayWidget | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.app.security.interfaces import IUnauthenticatedPrincipal | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope.catalog.interfaces import ICatalog | ||||
| from zope.container.contained import ObjectRemovedEvent | ||||
| from zope.dottedname.resolve import resolve | ||||
| from zope.event import notify | ||||
| from zope.formlib.form import EditForm, FormFields, setUpEditWidgets | ||||
| from zope.formlib.interfaces import IDisplayWidget | ||||
| from zope.formlib.namedtemplate import NamedTemplate | ||||
| from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent | ||||
| from zope.interface import implements | ||||
| from zope.publisher.interfaces import BadRequest | ||||
| from zope.publisher.interfaces.browser import IBrowserRequest | ||||
| from zope.schema.interfaces import IIterableSource | ||||
|  | @ -236,35 +254,18 @@ class ConceptView(BaseView): | |||
|                 result.append(view) | ||||
|         return result | ||||
| 
 | ||||
|     def viewModes(self): | ||||
|         modes = Jeep() | ||||
|         current = self.request.form.get('loops.viewName') | ||||
|         parts = (self.options('view_tabs') or  | ||||
|                     self.typeOptions('view_tabs') or []) | ||||
|         if not parts: | ||||
|             return modes | ||||
|         activeMode = None | ||||
|         for p in parts: | ||||
|             view = component.queryMultiAdapter( | ||||
|                         (self.adapted, self.request), name=p) | ||||
|             if view is None: | ||||
|                 view = component.queryMultiAdapter( | ||||
|                             (self.context, self.request), name=p) | ||||
|             if view is None: | ||||
|                 continue | ||||
|             active = (activeMode is None and p == current) | ||||
|             if active: | ||||
|                 activeMode = p | ||||
|             url = '%s?loops.viewName=%s' % (self.targetUrl, p) | ||||
|             modes.append(ViewMode(p, view.tabTitle, url, active)) | ||||
|         if activeMode is None: | ||||
|             modes[0].active = True | ||||
|         return modes | ||||
| 
 | ||||
|     @Lazy | ||||
|     def adapted(self): | ||||
|         return adapted(self.context, self.languageInfo) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def title(self): | ||||
|         return self.adapted.title or getName(self.context) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def description(self): | ||||
|         return self.adapted.description | ||||
| 
 | ||||
|     @Lazy | ||||
|     def targetUrl(self): | ||||
|         return self.nodeView.getUrlForTarget(self.context) | ||||
|  | @ -281,17 +282,8 @@ class ConceptView(BaseView): | |||
|     def breadcrumbsTitle(self): | ||||
|         return self.title | ||||
| 
 | ||||
|     @Lazy | ||||
|     def showInBreadcrumbs(self): | ||||
|         return (self.options('show_in_breadcrumbs') or  | ||||
|                 self.typeOptions('show_in_breadcrumbs')) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def breadcrumbsParent(self): | ||||
|         for p in self.context.getParents([self.defaultPredicate]): | ||||
|             view = self.nodeView.getViewForTarget(p) | ||||
|             if view is not None and view.showInBreadcrumbs: | ||||
|                 return view | ||||
|         return None | ||||
| 
 | ||||
|     def getData(self, omit=('title', 'description')): | ||||
|  | @ -397,8 +389,7 @@ class ConceptView(BaseView): | |||
|     children = getChildren | ||||
| 
 | ||||
|     def childrenAlphaGroups(self, predicates=None): | ||||
|         #result = Jeep() | ||||
|         result = {} | ||||
|         result = Jeep() | ||||
|         rels = self.getChildren(predicates=predicates or [self.defaultPredicate], | ||||
|                                 topLevelOnly=False, sort=False) | ||||
|         rels = sorted(rels, key=lambda r: r.title.lower()) | ||||
|  | @ -445,7 +436,7 @@ class ConceptView(BaseView): | |||
| 
 | ||||
|     def parents(self): | ||||
|         rels = sorted(self.context.getParentRelations(), | ||||
|                       key=(lambda x: x.first.title and x.first.title.lower() or '')) | ||||
|                       key=(lambda x: x.first.title and x.first.title.lower())) | ||||
|         for r in rels: | ||||
|             yield self.childViewFactory(r, self.request) | ||||
| 
 | ||||
|  | @ -458,7 +449,7 @@ class ConceptView(BaseView): | |||
|                 if r.order != pos: | ||||
|                     r.order = pos | ||||
| 
 | ||||
|     def getResources(self, relView=None, sort='default'): | ||||
|     def getResources(self): | ||||
|         form = self.request.form | ||||
|         #if form.get('loops.viewName') == 'index.html' and self.editable: | ||||
|         if self.editable: | ||||
|  | @ -467,17 +458,13 @@ class ConceptView(BaseView): | |||
|                 tokens = form.get('resources_tokens') | ||||
|                 if tokens: | ||||
|                     self.reorderResources(tokens) | ||||
|         if relView is None: | ||||
|         from loops.browser.resource import ResourceRelationView | ||||
|             relView = ResourceRelationView | ||||
|         from loops.organize.personal.browser.filter import FilterView | ||||
|         fv = FilterView(self.context, self.request) | ||||
|         rels = self.context.getResourceRelations(sort=sort) | ||||
|         rels = self.context.getResourceRelations() | ||||
|         for r in rels: | ||||
|             if fv.check(r.first): | ||||
|                 view = relView(r, self.request, contextIsSecond=True) | ||||
|                 if view.checkState(): | ||||
|                     yield view | ||||
|                 yield ResourceRelationView(r, self.request, contextIsSecond=True) | ||||
| 
 | ||||
|     def resources(self): | ||||
|         return self.getResources() | ||||
|  | @ -53,7 +53,7 @@ | |||
|     <h1 tal:define="tabview item/tabview|nothing" | ||||
|         tal:attributes="ondblclick item/openEditWindow"> | ||||
|       <a tal:omit-tag="python: level > 1" | ||||
|          tal:attributes="href string:${view/requestUrl}${item/urlParamString}" | ||||
|          tal:attributes="href request/URL" | ||||
|          tal:content="item/title">Title</a> | ||||
|       <a title="Show tabular view" | ||||
|          i18n:attributes="title" | ||||
|  | @ -367,21 +367,4 @@ | |||
| </metal:actions> | ||||
| 
 | ||||
| 
 | ||||
| <metal:sortable define-macro="sortable_column_header" | ||||
|                 tal:define="tableName tableName|nothing"> | ||||
|         <a title="tooltip_sort_column" | ||||
|            tal:define="colName col/name" | ||||
|            tal:omit-tag="python:not item.isSortableColumn(tableName, colName)" | ||||
|            tal:attributes="href python:item.getSortUrl(tableName, colName)" | ||||
|            i18n:attributes="title"> | ||||
|           <span tal:content="col/title" | ||||
|                 tal:attributes="class col/cssClass|nothing" | ||||
|                 i18n:translate="" /> | ||||
|           <img tal:define="src python:item.getSortImage(tableName, colName)" | ||||
|                tal:condition="src" | ||||
|                tal:attributes="src src" /> | ||||
|         </a> | ||||
| </metal:sortable> | ||||
| 
 | ||||
| 
 | ||||
| </html> | ||||
|  | @ -125,7 +125,7 @@ | |||
| 
 | ||||
|   <containerViews | ||||
|       for="loops.interfaces.ILoops" | ||||
|       index="zope.ManageSite" | ||||
|       index="zope.View" | ||||
|       contents="loops.ManageSite" | ||||
|       add="loops.ManageSite" /> | ||||
| 
 | ||||
|  | @ -365,7 +365,7 @@ | |||
| 
 | ||||
|   <containerViews | ||||
|       for="loops.interfaces.IViewManager" | ||||
|       index="zope.ManageSite" | ||||
|       index="zope.View" | ||||
|       add="loops.ManageSite" /> | ||||
| 
 | ||||
|   <menuItem | ||||
|  | @ -571,14 +571,6 @@ | |||
|       factory="loops.browser.concept.TabbedPage" | ||||
|       permission="zope.View" /> | ||||
| 
 | ||||
|   <!-- delete object action --> | ||||
| 
 | ||||
|   <page | ||||
|       name="delete_object" | ||||
|       for="loops.interfaces.INode" | ||||
|       class="loops.browser.form.DeleteObject" | ||||
|       permission="zope.ManageContent" /> | ||||
| 
 | ||||
|   <!-- dialogs/forms (end-user views) --> | ||||
| 
 | ||||
|   <page | ||||
|  | @ -1,8 +1,28 @@ | |||
| # loops.browser.external | ||||
| # | ||||
| #  Copyright (c) 2008 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ view class(es) for import/export. | ||||
| """ | ||||
| view class(es) for import/export. | ||||
| 
 | ||||
| $Id$ | ||||
| """ | ||||
| 
 | ||||
| from zope.interface import Interface, implements | ||||
| from zope.app import zapi | ||||
| from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB | 
| Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB | 
|  | @ -1,25 +1,41 @@ | |||
| # loops.browser.form | ||||
| # | ||||
| #  Copyright (c) 2012 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Classes for form presentation and processing. | ||||
| """ | ||||
| Classes for form presentation and processing. | ||||
| """ | ||||
| 
 | ||||
| from urllib.parse import urlencode, unquote_plus | ||||
| from zope import component, interface, schema | ||||
| from zope.component import adapts | ||||
| from zope.container.contained import ObjectRemovedEvent | ||||
| from zope.event import notify | ||||
| from zope.interface import Interface | ||||
| from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent | ||||
| from zope.container.interfaces import INameChooser | ||||
| from zope.lifecycleevent import ObjectAddedEvent | ||||
| from zope.browserpage import ViewPageTemplateFile | ||||
| 
 | ||||
| from zope.app.container.interfaces import INameChooser | ||||
| from zope.app.container.contained import ObjectAddedEvent | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope.contenttype import guess_content_type | ||||
| from zope.publisher.browser import FileUpload | ||||
| from zope.publisher.interfaces import BadRequest | ||||
| from zope.security.interfaces import ForbiddenAttribute, Unauthorized | ||||
| from zope.security.proxy import isinstance, removeSecurityProxy | ||||
| from zope.traversing.api import getName, getParent | ||||
| from zope.traversing.api import getName | ||||
| 
 | ||||
| from cybertools.ajax import innerHtml | ||||
| from cybertools.browser.form import FormController | ||||
|  | @ -52,25 +68,6 @@ from loops.util import _ | |||
| from loops.versioning.interfaces import IVersionable | ||||
| 
 | ||||
| 
 | ||||
| # delete object | ||||
| 
 | ||||
| class DeleteObject(NodeView): | ||||
| 
 | ||||
|     isTopLevel = True | ||||
| 
 | ||||
|     def __call__(self): | ||||
|         # todo: check permission; check security code | ||||
|         form = self.request.form | ||||
|         obj = util.getObjectForUid(form['uid']) | ||||
|         container = getParent(obj) | ||||
|         notify(ObjectRemovedEvent(obj)) | ||||
|         del container[getName(obj)] | ||||
|         message = 'The object requested has been deleted.' | ||||
|         params = [('loops.message', message.encode('UTF-8'))] | ||||
|         nextUrl = '%s?%s' % (self.request.URL[-1], urlencode(params)) | ||||
|         return self.request.response.redirect(nextUrl) | ||||
| 
 | ||||
| 
 | ||||
| # forms | ||||
| 
 | ||||
| class ObjectForm(NodeView): | ||||
|  | @ -165,10 +162,7 @@ class ObjectForm(NodeView): | |||
|                 field = self.schema.fields.get(k) | ||||
|                 if field: | ||||
|                     fi = field.getFieldInstance(self.instance) | ||||
|                     input = form[k] | ||||
|                     if isinstance(input, str): | ||||
|                         input = unquote_plus(input) | ||||
|                     data[k] = fi.marshall(fi.unmarshall(input)) | ||||
|                     data[k] = fi.marshall(fi.unmarshall(form[k])) | ||||
|                     #data[k] = toUnicode(form[k]) | ||||
|         return data | ||||
| 
 | ||||
|  | @ -202,37 +196,15 @@ class ObjectForm(NodeView): | |||
|     def typeManager(self): | ||||
|         return ITypeManager(self.target) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def targetType(self): | ||||
|         return self.target.getType() | ||||
| 
 | ||||
|     @Lazy | ||||
|     def presetTypesForAssignment(self): | ||||
|         types = [] | ||||
|         tn = getName(self.targetType) | ||||
|         for t in self.typeManager.listTypes(include=('assign',)): | ||||
|             # check if type is appropriate for the object to be created | ||||
|             opt = IOptions(adapted(t.context))('qualifier_assign_to') | ||||
|             #print '***', t.context.__name__, opt, tn | ||||
|             if not opt or tn in opt: | ||||
|                 types.append(t) | ||||
|         types = list(self.typeManager.listTypes(include=('assign',))) | ||||
|         assigned = [r.context.conceptType for r in self.assignments] | ||||
|         types = [t for t in types if t.typeProvider not in assigned] | ||||
|         return [dict(title=t.title, token=t.tokenForSearch) for t in types] | ||||
| 
 | ||||
|     def conceptsForType(self, token): | ||||
|         result = ConceptQuery(self).query(type=token) | ||||
|         # check typeOption: include only matching instances | ||||
|         include = [] | ||||
|         type = self.conceptManager[token.split(':')[-1]] | ||||
|         #print '###', token, repr(type) | ||||
|         opt = IOptions(adapted(type))('qualifier_assign_check_parents') | ||||
|         if opt: | ||||
|             for p in self.target.getAllParents([self.defaultPredicate]): | ||||
|                 for c in p.object.getChildren([self.defaultPredicate]): | ||||
|                     include.append(c) | ||||
|         if include: | ||||
|             result = [c for c in result if c in include] | ||||
|         fv = FilterView(self.context, self.request) | ||||
|         result = fv.apply(result) | ||||
|         result.sort(key=lambda x: x.title) | ||||
|  | @ -316,11 +288,8 @@ class CreateObjectForm(ObjectForm): | |||
| 
 | ||||
|     @Lazy | ||||
|     def defaultTypeToken(self): | ||||
|         setting = self.controller.params.get('form.create.defaultTypeToken') | ||||
|         if setting: | ||||
|             return setting | ||||
|         opt = self.globalOptions('form.create.default_type_token') | ||||
|         return opt and opt[0] or '.loops/concepts/textdocument' | ||||
|         return (self.controller.params.get('form.create.defaultTypeToken') | ||||
|                 or '.loops/concepts/textdocument') | ||||
| 
 | ||||
|     @Lazy | ||||
|     def typeToken(self): | ||||
|  | @ -341,15 +310,10 @@ class CreateObjectForm(ObjectForm): | |||
|         if typeToken: | ||||
|             return self.loopsRoot.loopsTraverse(typeToken) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def targetType(self): | ||||
|         return self.typeConcept | ||||
| 
 | ||||
|     @Lazy | ||||
|     def adapted(self): | ||||
|         ad = self.typeInterface(Resource()) | ||||
|         ad.storageName = 'unknown'  # hack for file objects: don't try to retrieve data | ||||
|         ad.__is_dummy__ = True | ||||
|         ad.__type__ = adapted(self.typeConcept) | ||||
|         return ad | ||||
| 
 | ||||
|  | @ -459,7 +423,6 @@ class CreateConceptForm(CreateObjectForm): | |||
|             return c | ||||
|         ad = ti(c) | ||||
|         ad.__is_dummy__ = True | ||||
|         ad.__type__ = adapted(self.typeConcept) | ||||
|         return ad | ||||
| 
 | ||||
|     @Lazy | ||||
|  | @ -2,7 +2,7 @@ | |||
| 
 | ||||
| 
 | ||||
| <metal:info define-macro="object_info" | ||||
|             tal:define="item nocall:view/targetItem"> | ||||
|             tal:define="item nocall:view/item"> | ||||
|   <table class="object_info" width="400"> | ||||
|     <tr> | ||||
|       <td colspan="2"><h2 i18n:translate="">Object Information</h2><br /></td> | ||||
|  | @ -52,7 +52,7 @@ | |||
| 
 | ||||
| 
 | ||||
| <metal:info define-macro="meta_info" | ||||
|             tal:define="item nocall:view/targetItem"> | ||||
|             tal:define="item nocall:view/item"> | ||||
|   <table class="object_info" width="400"> | ||||
|     <tr> | ||||
|       <td colspan="2"> | ||||
|  | @ -1,9 +1,26 @@ | |||
| # loops.browser.lobo.standard | ||||
| # | ||||
| #  Copyright (c) 2012 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ View classes for lobo (blueprint-based) layouts. | ||||
| """ | ||||
| View classes for lobo (blueprint-based) layouts. | ||||
| """ | ||||
| 
 | ||||
| from urllib.parse import parse_qs | ||||
| from cgi import parse_qs | ||||
| from zope import interface, component | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
|  | @ -1,4 +1,3 @@ | |||
| # loops.browser.lobo.tests | ||||
| 
 | ||||
| import unittest, doctest | ||||
| from zope.interface.verify import verifyClass | ||||
|  | @ -13,7 +12,7 @@ class Test(unittest.TestCase): | |||
| def test_suite(): | ||||
|     flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS | ||||
|     return unittest.TestSuite(( | ||||
|         unittest.TestLoader().loadTestsFromTestCase(Test), | ||||
|                 unittest.makeSuite(Test), | ||||
|                 doctest.DocFileSuite('README.txt', optionflags=flags), | ||||
|             )) | ||||
| 
 | ||||
|  | @ -238,21 +238,18 @@ fieldset.box td { | |||
|     font-weight: bold; | ||||
|     color: #444; | ||||
|     padding-top: 0.4em; | ||||
|     border-bottom: none; | ||||
| } | ||||
| 
 | ||||
| .content-4 h1, .content-3 h2, .content-2 h3, .content-1 h4, h4 { | ||||
|     font-size: 130%; | ||||
|     font-weight: normal; | ||||
|     padding-top: 0.3em; | ||||
|     border-bottom: none; | ||||
| } | ||||
| 
 | ||||
| .content-5 h1, .content-4 h2, .content-3 h3, content-2 h4, h5 { | ||||
|     font-size: 120%; | ||||
|     /* border: none; */ | ||||
|     padding-top: 0.2em; | ||||
|     border-bottom: none; | ||||
| } | ||||
| 
 | ||||
| .box { | ||||
|  | @ -47,35 +47,6 @@ function showIfIn(node, conditions) { | |||
|     }) | ||||
| } | ||||
| 
 | ||||
| function setIfIn(node, conditions) { | ||||
|     dojo.forEach(conditions, function(cond) { | ||||
|         if (node.value == cond[0]) { | ||||
|             target = dijit.byId(cond[1]); | ||||
|             target.setValue(cond[2]); | ||||
|         } | ||||
|     }) | ||||
| } | ||||
| 
 | ||||
| function setIf(node, cond, acts) { | ||||
|     if (node.value == cond) { | ||||
|         dojo.forEach(acts, function(act) { | ||||
|             target = dijit.byId(act[0]); | ||||
|             target.setValue(act[1]); | ||||
|         }) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| function setIfN(node, conds, acts) { | ||||
|     dojo.forEach(conds, function(cond) { | ||||
|         if (node.value == cond) { | ||||
|             dojo.forEach(acts, function(act) { | ||||
|                 target = dijit.byId(act[0]); | ||||
|                 target.setValue(act[1]); | ||||
|             }) | ||||
|         } | ||||
|     }) | ||||
| } | ||||
| 
 | ||||
| function destroyWidgets(node) { | ||||
|     dojo.forEach(dojo.query('[widgetId]', node), function(n) { | ||||
|         w = dijit.byNode(n); | ||||
|  | @ -132,7 +103,7 @@ function submitReplacing(targetId, formId, url) { | |||
|         mimetype: "text/html", | ||||
|         load: function(response, ioArgs) { | ||||
|             replaceNode(response, targetId); | ||||
|             return response; | ||||
|             return resonse; | ||||
|         } | ||||
|     }) | ||||
| } | ||||
|  | @ -144,7 +115,7 @@ function xhrSubmitPopup(formId, url) { | |||
|         mimetype: "text/html", | ||||
|         load: function(response, ioArgs) { | ||||
|             window.close(); | ||||
|             return response; | ||||
|             return resonse; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| Before Width: | Height: | Size: 942 B After Width: | Height: | Size: 942 B | 
|  | @ -1,11 +1,31 @@ | |||
| # loops.browser.mobile.default | ||||
| # | ||||
| #  Copyright (c) 2011 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Default layouts for the loops mobile skin. | ||||
| """ | ||||
| Default layouts for the loops mobile skin. | ||||
| 
 | ||||
| $Id$ | ||||
| """ | ||||
| 
 | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope import component | ||||
| from zope.interface import implements | ||||
| 
 | ||||
| from cybertools.browser.renderer import RendererFactory | ||||
| from cybertools.composer.layout.base import Layout | ||||
|  | @ -1,20 +1,37 @@ | |||
| # loops.browser.node | ||||
| # | ||||
| #  Copyright (c) 2016 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ View class for Node objects. | ||||
| """ | ||||
| View class for Node objects. | ||||
| """ | ||||
| 
 | ||||
| from logging import getLogger | ||||
| from urllib.parse import urlencode, urlparse, urlunparse | ||||
| #from urlparse import urlparse, urlunparse | ||||
| import urllib | ||||
| from urlparse import urlparse, urlunparse | ||||
| from zope import component, interface, schema | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope.annotation.interfaces import IAnnotations | ||||
| from zope.app.catalog.interfaces import ICatalog | ||||
| from zope.app.container.browser.contents import JustContents | ||||
| from zope.app.container.browser.adding import Adding | ||||
| from zope import component, interface, schema | ||||
| from zope.annotation.interfaces import IAnnotations | ||||
| from zope.authentication.interfaces import IUnauthenticatedPrincipal | ||||
| from zope.browserpage import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope.catalog.interfaces import ICatalog | ||||
| from zope.container.traversal import ItemTraverser | ||||
| from zope.app.container.traversal import ItemTraverser | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.app.security.interfaces import IUnauthenticatedPrincipal | ||||
| from zope.dottedname.resolve import resolve | ||||
| from zope.event import notify | ||||
| from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent | ||||
|  | @ -69,14 +86,10 @@ class NodeView(BaseView): | |||
|         super(NodeView, self).__init__(context, request) | ||||
|         self.viewAnnotations.setdefault('nodeView', self) | ||||
|         self.viewAnnotations.setdefault('node', self.context) | ||||
|         self.setSkin(self.viewConfig.get('skinName')) | ||||
|         viewConfig = getViewConfiguration(context, request) | ||||
|         self.setSkin(viewConfig.get('skinName')) | ||||
| 
 | ||||
|     def __call__(self, *args, **kw): | ||||
|         if self.nodeType == 'raw': | ||||
|             vn = self.context.viewName | ||||
|             if vn: | ||||
|                 self.request.response.setHeader('content-type', vn) | ||||
|             return self.context.body | ||||
|         tv = self.viewAnnotations.get('targetView') | ||||
|         if tv is not None: | ||||
|             if tv.isToplevel: | ||||
|  | @ -85,29 +98,6 @@ class NodeView(BaseView): | |||
|             self.controller.setMainPage() | ||||
|         return super(NodeView, self).__call__(*args, **kw) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def viewConfig(self): | ||||
|         return getViewConfiguration(self.context, self.request) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def viewConfigOptions(self): | ||||
|         result = {} | ||||
|         for opt in self.viewConfig.get('options') or []: | ||||
|             if ':' in opt: | ||||
|                 k, v = opt.split(':', 1) | ||||
|                 result[k] = v.split(',') | ||||
|             else: | ||||
|                 result[opt] = True | ||||
|         return result | ||||
| 
 | ||||
|     @Lazy | ||||
|     def copyright(self): | ||||
|         cr = self.viewConfigOptions.get('copyright') | ||||
|         if cr: | ||||
|             return cr[0] | ||||
|         cr = self.globalOptions('copyright') | ||||
|         return cr and cr[0] or 'cyberconcepts.org team' | ||||
| 
 | ||||
|     @Lazy | ||||
|     def macro(self): | ||||
|         return self.template.macros['content'] | ||||
|  | @ -125,9 +115,7 @@ class NodeView(BaseView): | |||
|             parts.extend(getParts(n)) | ||||
|         return parts | ||||
| 
 | ||||
|     def update(self, topLevel=True): | ||||
|         if topLevel and self.view != self: | ||||
|             return self.view.update(False) | ||||
|     def update(self): | ||||
|         result = super(NodeView, self).update() | ||||
|         self.recordAccess() | ||||
|         return result | ||||
|  | @ -141,7 +129,7 @@ class NodeView(BaseView): | |||
|             return [] | ||||
|         menu = self.menu | ||||
|         data = [dict(label=menu.title, url=menu.url)] | ||||
|         menuItem = self.getNearestMenuItem(all=True) | ||||
|         menuItem = self.nearestMenuItem | ||||
|         if menuItem != menu.context: | ||||
|             data.append(dict(label=menuItem.title, | ||||
|                              url=absoluteURL(menuItem, self.request))) | ||||
|  | @ -152,9 +140,6 @@ class NodeView(BaseView): | |||
|                                     url=absoluteURL(p, self.request))) | ||||
|         if self.virtualTarget: | ||||
|             data.extend(self.virtualTarget.breadcrumbs()) | ||||
|         if data and not '?' in data[-1]['url']: | ||||
|             if self.urlParamString: | ||||
|                 data[-1]['url'] += self.urlParamString | ||||
|         return data | ||||
| 
 | ||||
|     def viewModes(self): | ||||
|  | @ -381,10 +366,6 @@ class NodeView(BaseView): | |||
|     def editable(self): | ||||
|         return canWrite(self.context, 'body') | ||||
| 
 | ||||
|     def hasTopPage(self, name): | ||||
|         page = self.topMenu.context.get(name) | ||||
|         return page is not None | ||||
| 
 | ||||
|     # menu stuff | ||||
| 
 | ||||
|     @Lazy | ||||
|  | @ -430,9 +411,8 @@ class NodeView(BaseView): | |||
| 
 | ||||
|     @Lazy | ||||
|     def menuItems(self): | ||||
|         items = [NodeView(child, self.request).view | ||||
|         return [NodeView(child, self.request) | ||||
|                     for child in self.context.getMenuItems()] | ||||
|         return [item for item in items if item.isVisible] | ||||
| 
 | ||||
|     @Lazy | ||||
|     def parents(self): | ||||
|  | @ -440,13 +420,10 @@ class NodeView(BaseView): | |||
| 
 | ||||
|     @Lazy | ||||
|     def nearestMenuItem(self): | ||||
|         return self.getNearestMenuItem() | ||||
| 
 | ||||
|     def getNearestMenuItem(self, all=False): | ||||
|         menu = self.menuObject | ||||
|         menuItem = None | ||||
|         for p in [self.context] + self.parents: | ||||
|             if not all and not p.isMenuItem(): | ||||
|             if not p.isMenuItem(): | ||||
|                 menuItem = None | ||||
|             elif menuItem is None: | ||||
|                 menuItem = p | ||||
|  | @ -462,7 +439,7 @@ class NodeView(BaseView): | |||
| 
 | ||||
|     @Lazy | ||||
|     def logoutUrl(self): | ||||
|         nextUrl = urlencode(dict(nextUrl=self.menu.url)) | ||||
|         nextUrl = urllib.urlencode(dict(nextUrl=self.menu.url)) | ||||
|         return '%s/logout.html?%s' % (self.menu.url, nextUrl) | ||||
| 
 | ||||
|     @Lazy | ||||
|  | @ -492,7 +469,7 @@ class NodeView(BaseView): | |||
|     def targetView(self, name='index.html', methodName='show'): | ||||
|         if name == 'index.html':    # only when called for default view | ||||
|             tv = self.viewAnnotations.get('targetView') | ||||
|             if tv is not None and callable(tv): | ||||
|             if tv is not None: | ||||
|                 return tv() | ||||
|         if '?' in name: | ||||
|             name, params = name.split('?', 1) | ||||
|  | @ -590,21 +567,12 @@ class NodeView(BaseView): | |||
|         """ Return URL of given target view given as .XXX URL. | ||||
|         """ | ||||
|         if isinstance(target, BaseView): | ||||
|             miu = self.getMenuItemUrlForTarget(target.context) | ||||
|             if miu is not None: | ||||
|                 return miu | ||||
|             return self.makeTargetUrl(self.url, target.uniqueId, target.title) | ||||
|         else: | ||||
|             target = baseObject(target) | ||||
|             return self.makeTargetUrl(self.url, util.getUidForObject(target), | ||||
|                                       target.title) | ||||
| 
 | ||||
|     def getMenuItemUrlForTarget(self, tobj): | ||||
|         for node in tobj.getClients(): | ||||
|             if node.nodeType == 'page' and node.getMenu() == self.menuObject: | ||||
|                 return absoluteURL(node, self.request) | ||||
| 
 | ||||
| 
 | ||||
|     def getActions(self, category='object', page=None, target=None): | ||||
|         actions = [] | ||||
|         #self.registerDojo() | ||||
|  | @ -769,11 +737,11 @@ class InlineEdit(NodeView): | |||
|         if ti is not None: | ||||
|             target = ti(target) | ||||
|         data = self.request.form['editorContent'] | ||||
|         if not isinstance(data, str): | ||||
|         if type(data) != unicode: | ||||
|             try: | ||||
|                 data = data.decode('ISO-8859-15')  # IE hack | ||||
|             except UnicodeDecodeError: | ||||
|                 print('loops.browser.node.InlineEdit.save():', data) | ||||
|                 print 'loops.browser.node.InlineEdit.save():', data | ||||
|                 return | ||||
|         #    data = data.decode('UTF-8') | ||||
|         target.data = data | ||||
|  | @ -945,9 +913,9 @@ class NodeAdding(Adding): | |||
|         return info | ||||
| 
 | ||||
| 
 | ||||
| @interface.implementer(IViewConfiguratorSchema) | ||||
| class ViewPropertiesConfigurator(object): | ||||
| 
 | ||||
|     interface.implements(IViewConfiguratorSchema) | ||||
|     component.adapts(INode) | ||||
| 
 | ||||
|     def __init__(self, context): | ||||
|  | @ -1008,8 +976,7 @@ class NodeTraverser(ItemTraverser): | |||
|         if context.nodeType == 'menu': | ||||
|             setViewConfiguration(context, request) | ||||
|         if name == '.loops': | ||||
|             name = self.getTargetUid(request) | ||||
|             #return self.context.getLoopsRoot() | ||||
|             return self.context.getLoopsRoot() | ||||
|         if name.startswith('.'): | ||||
|             name = self.cleanUpTraversalStack(request, name)[1:] | ||||
|             target = self.getTarget(name) | ||||
|  | @ -1035,40 +1002,23 @@ class NodeTraverser(ItemTraverser): | |||
|                 return self.context | ||||
|         try: | ||||
|             obj = super(NodeTraverser, self).publishTraverse(request, name) | ||||
|         except NotFound: | ||||
|         except NotFound, e: | ||||
|             logger.warn('NodeTraverser: NotFound: URL = %s, name = %r' % | ||||
|                             (request.URL, name)) | ||||
|             raise | ||||
|         return obj | ||||
| 
 | ||||
|     def getTargetUid(self, request): | ||||
|         parent = self.context.getLoopsRoot() | ||||
|         stack = request._traversal_stack | ||||
|         for i in range(2): | ||||
|             name = stack.pop() | ||||
|             obj = parent.get(name) | ||||
|             if not obj: | ||||
|                 return name | ||||
|             parent = obj | ||||
|         return '.' + util.getUidForObject(obj) | ||||
| 
 | ||||
|     def cleanUpTraversalStack(self, request, name): | ||||
|         #traversalStack = request._traversal_stack | ||||
|         #while traversalStack and traversalStack[0].startswith('.'): | ||||
|         traversalStack = request._traversal_stack | ||||
|         while traversalStack and traversalStack[0].startswith('.'): | ||||
|             # skip obsolete target references in the url | ||||
|         #    name = traversalStack.pop(0) | ||||
|             name = traversalStack.pop(0) | ||||
|         traversedNames = request._traversed_names | ||||
|         for n in list(traversedNames): | ||||
|             if n.startswith('.'): | ||||
|                 # remove obsolete target refs | ||||
|                 traversedNames.remove(n) | ||||
|         #if traversedNames: | ||||
|         #    lastTraversed = traversedNames[-1] | ||||
|         #    if lastTraversed.startswith('.') and lastTraversed != name: | ||||
|         if traversedNames: | ||||
|             lastTraversed = traversedNames[-1] | ||||
|             if lastTraversed.startswith('.') and lastTraversed != name: | ||||
|                 # let <base .../> tag show the current object | ||||
|         #        traversedNames[-1] = name | ||||
|         # let <base .../> tag show the current object | ||||
|         traversedNames.append(name) | ||||
|                 traversedNames[-1] = name | ||||
|         return name | ||||
| 
 | ||||
|     def getTarget(self, name): | ||||
|  | @ -1086,9 +1036,7 @@ def setViewConfiguration(context, request): | |||
|     config = IViewConfiguratorSchema(context) | ||||
|     skinName = config.skinName | ||||
|     if not skinName: | ||||
|         root = removeSecurityProxy(context.getLoopsRoot()) | ||||
|         skinName = root.skinName | ||||
|         #skinName = context.getLoopsRoot().skinName | ||||
|         skinName = context.getLoopsRoot().skinName | ||||
|     if skinName: | ||||
|         viewAnnotations['skinName'] = skinName | ||||
|     if config.options: | ||||
|  | @ -1107,12 +1055,12 @@ def getViewConfiguration(context, request): | |||
| class TestView(NodeView): | ||||
| 
 | ||||
|     def __call__(self): | ||||
|         print( '*** begin') | ||||
|         print '*** begin' | ||||
|         for i in range(500): | ||||
|             #x = util.getObjectForUid('1994729849') | ||||
|             x = util.getObjectForUid('2018653366') | ||||
|             self.c = list(x.getChildren()) | ||||
|             #self.c = list(x.getChildren([self.defaultPredicate])) | ||||
|         print('*** end', len(self.c)) | ||||
|         print '*** end', len(self.c) | ||||
|         return 'done' | ||||
| 
 | ||||
| Before Width: | Height: | Size: 942 B After Width: | Height: | Size: 942 B | 
|  | @ -30,7 +30,7 @@ | |||
|                              item nocall:target" | ||||
|                  tal:attributes="class string:content-$level; | ||||
|                                  id id; | ||||
|                                  ondblclick python:target.openEditWindow('configure.html')"> | ||||
|                                  ondblclick python: target.openEditWindow('configure.html')"> | ||||
|               <metal:body use-macro="item/macro"> | ||||
|                 The body | ||||
|               </metal:body> | ||||
|  | @ -41,22 +41,17 @@ | |||
| 
 | ||||
| 
 | ||||
| <metal:body define-macro="conceptbody"> | ||||
|   <tal:body define="body item/body; | ||||
|                     itemNum view/itemNum; | ||||
|                     id string:$itemNum.body"> | ||||
|   <tal:body define="body item/body;"> | ||||
|     <div class="content-1" id="1" | ||||
|          tal:attributes="class string:content-$level; | ||||
|                          id string:${view/itemNum}.body; | ||||
|                          ondblclick python:item.openEditWindow('configure.html')"> | ||||
|                          ondblclick python: item.openEditWindow('configure.html')"> | ||||
|       <span tal:content="structure body">Node Body</span> | ||||
|     </div> | ||||
|     <div tal:define="item nocall:item/targetObjectView; | ||||
|     <tal:concepts define="item nocall:item/targetObjectView; | ||||
|                           macro item/macro"> | ||||
|       <div tal:attributes="class string:content-$level; | ||||
|                            id id;"> | ||||
|       <div metal:use-macro="macro" /> | ||||
|       </div> | ||||
|     </div> | ||||
|     </tal:concepts> | ||||
|   </tal:body> | ||||
| </metal:body> | ||||
| 
 | ||||
|  | @ -333,12 +328,11 @@ | |||
| <metal:login define-macro="login"> | ||||
|     <div> | ||||
|       <a href="login.html" | ||||
|          tal:attributes="href string:${view/topMenu/url}/login.html" | ||||
|             i18n:translate="">Log in</a></div> | ||||
|     <div tal:define="register python:view.globalOptions('provideLogin')" | ||||
|          tal:condition="python:register and register != True"> | ||||
|       <a tal:define="reg python:register[0]" | ||||
|          tal:attributes="href string:${view/topMenu/url}/$reg" | ||||
|          tal:condition="register"> | ||||
|       <a tal:condition="python:register != True" | ||||
|          tal:attributes="href python:register[0]" | ||||
|          i18n:translate="">Register new member</a></div> | ||||
| </metal:login> | ||||
| 
 | ||||
|  | @ -18,6 +18,10 @@ | |||
|           <a href="#" | ||||
|              tal:attributes="href string:${target/url}/@@configure.html" | ||||
|              tal:content="target/title">Document xy</a> | ||||
|           <tal:xedit define="xeditObjectUrl target/url" | ||||
|                      condition="target/xeditable"> | ||||
|             <metal:xedit use-macro="views/xedit_macros/editLink" /> | ||||
|           </tal:xedit> | ||||
|         </tal:target> | ||||
|       </div> | ||||
| 
 | ||||
|  | @ -1,18 +1,35 @@ | |||
| # loops.browser.resource | ||||
| # | ||||
| #  Copyright (c) 2014 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ View class for resource objects. | ||||
| """ | ||||
| View class for resource objects. | ||||
| """ | ||||
| 
 | ||||
| import os.path | ||||
| from zope.authentication.interfaces import IUnauthenticatedPrincipal | ||||
| from zope.browserpage import ViewPageTemplateFile | ||||
| import urllib | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope import component | ||||
| from zope.catalog.interfaces import ICatalog | ||||
| from zope.container.interfaces import INameChooser | ||||
| from zope.app.catalog.interfaces import ICatalog | ||||
| from zope.app.container.interfaces import INameChooser | ||||
| from zope.app.form.browser.textwidgets import FileWidget | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.app.security.interfaces import IUnauthenticatedPrincipal | ||||
| from zope.formlib.form import FormFields | ||||
| from zope.formlib.interfaces import DISPLAY_UNWRITEABLE | ||||
| from zope.formlib.textwidgets import FileWidget | ||||
| from zope.proxy import removeAllProxies | ||||
| from zope.schema.interfaces import IBytes | ||||
| from zope.security import canAccess, canWrite | ||||
|  | @ -30,7 +47,7 @@ from loops.browser.common import EditForm, BaseView | |||
| from loops.browser.concept import BaseRelationView, ConceptRelationView | ||||
| from loops.browser.concept import ConceptConfigureView | ||||
| from loops.browser.node import NodeView, node_macros | ||||
| from loops.common import adapted, baseObject, NameChooser, normalizeName | ||||
| from loops.common import adapted, NameChooser, normalizeName | ||||
| from loops.interfaces import IBaseResource, IDocument, ITextDocument | ||||
| from loops.interfaces import IMediaAsset as legacy_IMediaAsset | ||||
| from loops.interfaces import ITypeConcept | ||||
|  | @ -179,9 +196,6 @@ class ResourceView(BaseView): | |||
|         context = self.context | ||||
|         ct = context.contentType | ||||
|         response = self.request.response | ||||
|         if self.typeOptions('x_robots_tag_header', None) is not None: | ||||
|             tagVal = ', '.join(self.typeOptions('x_robots_tag_header')) | ||||
|             response.setHeader('X-Robots-Tag', tagVal) | ||||
|         self.recordAccess('show', target=self.uniqueId) | ||||
|         if ct.startswith('image/'): | ||||
|             #response.setHeader('Cache-Control', 'public,max-age=86400') | ||||
|  | @ -202,16 +216,6 @@ class ResourceView(BaseView): | |||
|             if filename is None: | ||||
|                 filename = (adapted(self.context).localFilename or  | ||||
|                                 getName(self.context)) | ||||
|                 if self.typeOptions('use_title_for_download_filename'): | ||||
|                     base, ext = os.path.splitext(filename) | ||||
|                     filename = context.title | ||||
|                     vr = IVersionable(baseObject(context)) | ||||
|                     if len(vr.versions) > 0: | ||||
|                         filename = vr.generateName(filename, ext, vr.versionId) | ||||
|                     else: | ||||
|                         if not filename.endswith(ext): | ||||
|                             filename += ext | ||||
|                     filename = filename.encode('UTF-8') | ||||
|             if self.typeOptions('no_normalize_download_filename'): | ||||
|                 filename = '"%s"' % filename | ||||
|             else: | ||||
|  | @ -254,21 +258,15 @@ class ResourceView(BaseView): | |||
|             #wp = wiki.createPage(getName(self.context)) | ||||
|             wp = wiki.addPage(LoopsWikiPage(self.context)) | ||||
|             wp.text = text | ||||
|             #print(wp.wiki.getManager()) | ||||
|             #print wp.wiki.getManager() | ||||
|             #return util.toUnicode(wp.render(self.request)) | ||||
|         return super(ResourceView, self).renderText(text, contentType) | ||||
| 
 | ||||
|     showMore = True | ||||
| 
 | ||||
|     def renderShortText(self): | ||||
|         return self.renderDescription() or self.createShortText(self.render()) | ||||
| 
 | ||||
|     def createShortText(self, text=None): | ||||
|         text = (text or self.render()).strip() | ||||
|         shortText = extractFirstPart(text) | ||||
|         if shortText == text: | ||||
|             self.showMore = False | ||||
|         return shortText | ||||
|         return extractFirstPart(text or self.render()) | ||||
| 
 | ||||
|     def download(self): | ||||
|         """ Force download, e.g. of a PDF file """ | ||||
|  | @ -449,7 +447,7 @@ class ExternalEditorView(ExternalEditorView, BaseView): | |||
|         r.append('meta_type:' + '.'.join((context.__module__, context.__class__.__name__))) | ||||
|         auth = self.request.get('_auth') | ||||
|         if auth: | ||||
|             print('ExternalEditorView: auth = ', auth) | ||||
|             print 'ExternalEditorView: auth = ', auth | ||||
|             if auth.endswith('\n'): | ||||
|                 auth = auth[:-1] | ||||
|             r.append('auth:' + auth) | ||||
|  | @ -473,3 +471,4 @@ class NoteView(DocumentView): | |||
|     def linkUrl(self): | ||||
|         ad = self.typeAdapter | ||||
|         return ad and ad.linkUrl or '' | ||||
| 
 | ||||
|  | @ -10,7 +10,7 @@ | |||
|         <div metal:use-macro="views/node_macros/object_actions" /> | ||||
|       </tal:actions> | ||||
|       <h1><a tal:omit-tag="python: level > 1" | ||||
|              tal:attributes="href view/requestUrl" | ||||
|              tal:attributes="href request/URL" | ||||
|              tal:content="item/title">Title</a></h1> | ||||
|       <tal:desc define="description description|item/renderedDescription" | ||||
|                 condition="description"> | ||||
|  | @ -51,7 +51,7 @@ | |||
|   <div tal:attributes="ondblclick python: item.openEditWindow('edit.html')"> | ||||
|     <div metal:use-macro="views/node_macros/object_actions" /> | ||||
|     <h1><a tal:omit-tag="python: level > 1" | ||||
|            tal:attributes="href view/requestUrl" | ||||
|            tal:attributes="href request/URL" | ||||
|            tal:content="item/title">Title</a></h1><br /> | ||||
|     <img tal:attributes="src | ||||
|                 string:${view/url}/.${view/targetId}/view?version=this" /> | ||||
|  | @ -72,7 +72,6 @@ | |||
|     <div> | ||||
|       <span class="button"> | ||||
|         <a i18n:translate="" | ||||
|            target="_blank" | ||||
|            tal:attributes="href | ||||
|                 string:${view/virtualTargetUrl}/download.html?version=this"> | ||||
|           Download | ||||
|  | @ -97,7 +96,6 @@ | |||
|         </a> | ||||
|       </span> | ||||
|     </div> | ||||
|     <metal:custom define-slot="custom_info" /> | ||||
|     <metal:fields use-macro="view/comment_macros/comments" /> | ||||
|   </div> | ||||
| </metal:block> | ||||
|  | @ -1,4 +1,6 @@ | |||
| # package loops.browser.skin | ||||
| """ | ||||
| $Id$ | ||||
| """ | ||||
| 
 | ||||
| from cybertools.browser.liquid import Liquid | ||||
| from cybertools.browser.blue import Blue | ||||
|  | @ -69,8 +69,8 @@ | |||
|          metal:define-macro="footer"> | ||||
|       <metal:footer define-slot="footer"> | ||||
|         © Copyright <span tal:replace="view/currentYear" />, | ||||
|         <span tal:replace="view/topMenu/copyright" /> | ||||
|         (<a i18n:translate="" | ||||
|         cyberconcepts IT-Consulting Dr. Helmut Merz | ||||
|         (<a href="#" | ||||
|           tal:attributes="href string:${view/topMenu/url}/impressum">Impressum</a>) | ||||
|         <br /> | ||||
|         Powered by | ||||
|  | @ -20,7 +20,6 @@ body { | |||
| 
 | ||||
| #portlets { | ||||
|     margin-top: 1em; | ||||
|     background-color: #ffffff; | ||||
| } | ||||
| 
 | ||||
| ul.view-modes { | ||||
|  | @ -109,14 +108,6 @@ thead th { | |||
|     background: none; | ||||
| } | ||||
| 
 | ||||
| /* printing */ | ||||
| 
 | ||||
| @media print { | ||||
|     .noprint { | ||||
|         display: none; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /* class-specific */ | ||||
| 
 | ||||
| .breadcrumbs td { | ||||
|  | @ -262,26 +253,10 @@ table.records th, table.records td { | |||
|     border: 1px solid lightgrey; | ||||
| } | ||||
| 
 | ||||
| table.report { | ||||
|     position: relative;  | ||||
|     z-index: 99;  | ||||
|     background: white; | ||||
| } | ||||
| 
 | ||||
| table.report th { | ||||
|     border-bottom: 1px solid #bbbbbb; | ||||
|     font-weight: bold; | ||||
| } | ||||
| 
 | ||||
| table.report td { | ||||
|     border-bottom: 1px dotted #dddddd; | ||||
|     vertical-align: top; | ||||
| } | ||||
| 
 | ||||
| .report-meta table { | ||||
|     width: auto; | ||||
| } | ||||
| 
 | ||||
| dl.docutils dt { | ||||
|     font-weight: bold; | ||||
|     margin-top: 0.3em; | ||||
|  | @ -11,18 +11,8 @@ body { | |||
|     display: none; | ||||
| } | ||||
| 
 | ||||
| .breadcrumbs { | ||||
|     display: none; | ||||
| } | ||||
| 
 | ||||
| .container { | ||||
|     width: auto; | ||||
|     margin: 0; | ||||
|     border: 0; | ||||
| } | ||||
| 
 | ||||
| #content { | ||||
|     width: auto; | ||||
| /*  width: 100%; */ | ||||
|     width: 80%; | ||||
|     color: Black; | ||||
| } | ||||
| 
 | ||||
| Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B | 
| Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB | 
|  | @ -10,7 +10,7 @@ | |||
|           method="post" name="listing" action="." | ||||
|           tal:define="target nocall:view/target" | ||||
|           tal:condition="python: target or items" | ||||
|           tal:attributes="action view/requestUrl"> | ||||
|           tal:attributes="action request/URL"> | ||||
|       <input type="hidden" name="action" value="assign" | ||||
|              tal:attributes="value action" /> | ||||
|       <table class="listing" summary="Currently assigned" | ||||
|  | @ -82,7 +82,7 @@ | |||
|   <fieldset> | ||||
|     <legend i18n:translate="">Create Target</legend> | ||||
|     <form method="post" name="listing" action="." | ||||
|         tal:attributes="action view/requestUrl"> | ||||
|         tal:attributes="action request/URL"> | ||||
|       <input type="hidden" name="action" value="create" /> | ||||
|       <div class="row"> | ||||
|         <span i18n:translate="">Name</span> | ||||
|  | @ -113,7 +113,7 @@ | |||
| 
 | ||||
| <metal:search define-macro="search"> | ||||
|   <form method="post" name="listing" action="." | ||||
|         tal:attributes="action view/requestUrl"> | ||||
|         tal:attributes="action request/URL"> | ||||
|       <input type="hidden" name="action" value="search" /> | ||||
|       <div class="row" | ||||
|            tal:define="searchTerm request/searchTerm | nothing; | ||||
|  | @ -1,13 +1,29 @@ | |||
| # loops.browser.util | ||||
| # | ||||
| #  Copyright (c) 2011 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Utilities. | ||||
| """ | ||||
| Utilities. | ||||
| """ | ||||
| 
 | ||||
| import re | ||||
| import urllib.parse | ||||
| from zope.browserpage import ViewPageTemplateFile | ||||
| from zope.browsermenu.menu import BrowserMenu | ||||
| from zope.browsermenu.interfaces import IBrowserSubMenuItem | ||||
| import re, urllib | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.app.publisher.browser.menu import BrowserMenu | ||||
| from zope.app.publisher.interfaces.browser import IBrowserSubMenuItem | ||||
| from zope import component | ||||
| from zope.formlib.namedtemplate import NamedTemplateImplementation | ||||
| 
 | ||||
|  | @ -52,4 +68,4 @@ def html_quote(text, character_entities=((u'&', u'&'), (u'<', u'<' ), | |||
| pattern = re.compile(r'[ /\?\+\|%]') | ||||
| 
 | ||||
| def normalizeForUrl(text): | ||||
|     return urllib.parse.quote(pattern.sub('-', text).encode('UTF-8')) | ||||
|     return urllib.quote(pattern.sub('-', text).encode('UTF-8')) | ||||
|  | @ -4,6 +4,8 @@ loops - Linked Objects for Organization and Processing Services | |||
| 
 | ||||
| Automatic classification of resources. | ||||
| 
 | ||||
|   ($Id$) | ||||
| 
 | ||||
| 
 | ||||
| Setting up a loops Site and Utilities | ||||
| ===================================== | ||||
|  | @ -37,7 +39,7 @@ from external files so we have something to work with. | |||
| 
 | ||||
|   >>> tExternalCollection = concepts['extcollection'] | ||||
|   >>> coll01 = addObject(concepts, Concept, 'coll01', | ||||
|   ...                    title='Collection One', conceptType=tExternalCollection) | ||||
|   ...                    title=u'Collection One', conceptType=tExternalCollection) | ||||
|   >>> aColl01 = adapted(coll01) | ||||
|   >>> aColl01.baseAddress = dataDir | ||||
|   >>> aColl01.address = '' | ||||
|  | @ -47,7 +49,7 @@ from external files so we have something to work with. | |||
|   7 | ||||
|   >>> rnames = list(sorted(resources.keys())) | ||||
|   >>> rnames[0] | ||||
|   'cust_im_contract_webbg_20071015.txt' | ||||
|   u'cust_im_contract_webbg_20071015.txt' | ||||
| 
 | ||||
| 
 | ||||
| Filename-based Classification | ||||
|  | @ -74,7 +76,7 @@ and follow the classifier step by step. | |||
|   >>> from loops.classifier.interfaces import IExtractor, IAnalyzer | ||||
|   >>> infoSet = InformationSet() | ||||
|   >>> for name in classifier.extractors.split(): | ||||
|   ...     print('extractor:', name) | ||||
|   ...     print 'extractor:', name | ||||
|   ...     extractor = component.getAdapter(adapted(r1), IExtractor, name=name) | ||||
|   ...     infoSet.update(extractor.extractInformationSet()) | ||||
|   extractor: filename | ||||
|  | @ -94,32 +96,32 @@ So there seems to be something missing - we have to create concepts | |||
| that may be identified as being candidates for classification. | ||||
| 
 | ||||
|   >>> tInstitution = addObject(concepts, Concept, 'institution', | ||||
|   ...                     title='Institution', conceptType=concepts['type']) | ||||
|   ...                     title=u'Institution', conceptType=concepts['type']) | ||||
|   >>> cust_im = addObject(concepts, Concept, 'im_editors', | ||||
|   ...                     title='im Editors', conceptType=tInstitution) | ||||
|   ...                     title=u'im Editors', conceptType=tInstitution) | ||||
|   >>> cust_mc = addObject(concepts, Concept, 'mc_consulting', | ||||
|   ...                     title='MC Management Consulting', conceptType=tInstitution) | ||||
|   ...                     title=u'MC Management Consulting', conceptType=tInstitution) | ||||
| 
 | ||||
|   >>> tDoctype = addObject(concepts, Concept, 'doctype', | ||||
|   ...                     title='Document Type', conceptType=concepts['type']) | ||||
|   ...                     title=u'Document Type', conceptType=concepts['type']) | ||||
|   >>> dt_note = addObject(concepts, Concept, 'dt_note', | ||||
|   ...                     title='Note', conceptType=tDoctype) | ||||
|   ...                     title=u'Note', conceptType=tDoctype) | ||||
|   >>> dt_contract = addObject(concepts, Concept, 'dt_contract', | ||||
|   ...                     title='Contract', conceptType=tDoctype) | ||||
|   ...                     title=u'Contract', conceptType=tDoctype) | ||||
| 
 | ||||
|   >>> tPerson = concepts['person'] | ||||
|   >>> webbg = addObject(concepts, Concept, 'webbg', | ||||
|   ...                     title='Gerald Webb', conceptType=tPerson) | ||||
|   ...                     title=u'Gerald Webb', conceptType=tPerson) | ||||
|   >>> smitha = addObject(concepts, Concept, 'smitha', | ||||
|   ...                     title='Angelina Smith', conceptType=tPerson) | ||||
|   ...                     title=u'Angelina Smith', conceptType=tPerson) | ||||
|   >>> watersj = addObject(concepts, Concept, 'watersj', | ||||
|   ...                     title='Jerry Waters', conceptType=tPerson) | ||||
|   ...                     title=u'Jerry Waters', conceptType=tPerson) | ||||
|   >>> millerj = addObject(concepts, Concept, 'millerj', | ||||
|   ...                     title='Jeannie Miller', conceptType=tPerson) | ||||
|   ...                     title=u'Jeannie Miller', conceptType=tPerson) | ||||
| 
 | ||||
|   >>> t.indexAll(concepts, resources) | ||||
| 
 | ||||
|   >>> from zope.catalog.interfaces import ICatalog | ||||
|   >>> from zope.app.catalog.interfaces import ICatalog | ||||
|   >>> cat = component.getUtility(ICatalog) | ||||
| 
 | ||||
|   >>> statements = analyzer.extractStatements(infoSet) | ||||
|  | @ -133,7 +135,7 @@ So we are now ready to have the whole stuff run in one call. | |||
| Classifier fileclassifier: Assigning: ... | ||||
| 
 | ||||
|   >>> list(sorted([c.title for c in r1.getConcepts()])) | ||||
|   ['Collection One', 'Contract', 'External File', 'Gerald Webb', 'im Editors'] | ||||
|   [u'Collection One', u'Contract', u'External File', u'Gerald Webb', u'im Editors'] | ||||
| 
 | ||||
|   >>> for name in rnames[1:]: | ||||
|   ...     classifier.process(resources[name]) | ||||
|  | @ -1,6 +1,25 @@ | |||
| # looops.classifier.base | ||||
| # | ||||
| #  Copyright (c) 2007 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Adapters and others classes for analyzing resources. | ||||
| """ | ||||
| Adapters and others classes for analyzing resources. | ||||
| 
 | ||||
| $Id$ | ||||
| """ | ||||
| 
 | ||||
| from itertools import tee | ||||
|  | @ -9,7 +28,7 @@ from zope.cachedescriptors.property import Lazy | |||
| from zope import component | ||||
| from zope.component import adapts | ||||
| from zope.event import notify | ||||
| from zope.interface import implementer | ||||
| from zope.interface import implements | ||||
| from zope.traversing.api import getName, getParent | ||||
| from cybertools.typology.interfaces import IType | ||||
| 
 | ||||
|  | @ -22,16 +41,15 @@ from loops.resource import Resource | |||
| from loops.setup import addAndConfigureObject | ||||
| from loops.type import TypeInterfaceSourceList | ||||
| 
 | ||||
| logger = getLogger('Classifier') | ||||
| 
 | ||||
| TypeInterfaceSourceList.typeInterfaces += (IClassifier,) | ||||
| 
 | ||||
| 
 | ||||
| @implementer(IClassifier) | ||||
| class Classifier(AdapterBase): | ||||
|     """ A concept adapter for analyzing resources. | ||||
|     """ | ||||
| 
 | ||||
|     implements(IClassifier) | ||||
|     adapts(IConcept) | ||||
| 
 | ||||
|     _contextAttributes = list(IClassifier) + list(IConcept) | ||||
|  | @ -84,7 +102,6 @@ class Classifier(AdapterBase): | |||
|         if resource not in resources: | ||||
|             concept.assignResource(resource, predicate) | ||||
|             message = u'Assigning: %s %s %s' | ||||
|             self.log(message % (resource.title, predicate.title, concept.title), 5) | ||||
|         else: | ||||
|             message = u'Already assigned: %s %s %s' | ||||
|         self.log(message % (resource.title, predicate.title, concept.title), 4) | ||||
|  | @ -92,12 +109,13 @@ class Classifier(AdapterBase): | |||
|     def log(self, message, level=5): | ||||
|         if level >= self.logLevel: | ||||
|             #print 'Classifier %s:' % getName(self.context), message | ||||
|             logger.info(u'%s: %s' % (getName(self.context), message)) | ||||
|             getLogger('Classifier').info( | ||||
|                 u'%s: %s' % (getName(self.context), message)) | ||||
| 
 | ||||
| 
 | ||||
| @implementer(IExtractor) | ||||
| class Extractor(object): | ||||
| 
 | ||||
|     implements(IExtractor) | ||||
|     adapts(IResource) | ||||
| 
 | ||||
|     def __init__(self, context): | ||||
|  | @ -107,9 +125,9 @@ class Extractor(object): | |||
|         return InformationSet() | ||||
| 
 | ||||
| 
 | ||||
| @implementer(IAnalyzer) | ||||
| class Analyzer(object): | ||||
| 
 | ||||
|     implements(IAnalyzer) | ||||
|     adapts(IClassifier) | ||||
| 
 | ||||
|     def __init__(self, context): | ||||
|  | @ -130,15 +148,15 @@ class Analyzer(object): | |||
|         return r1 | ||||
| 
 | ||||
| 
 | ||||
| @implementer(IInformationSet) | ||||
| class InformationSet(dict): | ||||
| 
 | ||||
|     pass | ||||
|     implements(IInformationSet) | ||||
| 
 | ||||
| 
 | ||||
| @implementer(IStatement) | ||||
| class Statement(object): | ||||
| 
 | ||||
|     implements(IStatement) | ||||
| 
 | ||||
|     def __init__(self, object=None, predicate=None, subject=None, relevance=100): | ||||
|         self.subject = subject | ||||
|         self.predicate = predicate | ||||
|  | @ -1,5 +1,5 @@ | |||
| # | ||||
| #  Copyright (c) 2015 Helmut Merz helmutm@cy55.de | ||||
| #  Copyright (c) 2007 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
|  | @ -18,20 +18,17 @@ | |||
| 
 | ||||
| """ | ||||
| View class(es) for resource classifiers. | ||||
| 
 | ||||
| $Id$ | ||||
| """ | ||||
| 
 | ||||
| from logging import getLogger | ||||
| import transaction | ||||
| from zope import interface, component | ||||
| from zope.app.pagetemplate import ViewPageTemplateFile | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope.traversing.api import getName | ||||
| 
 | ||||
| from loops.browser.concept import ConceptView | ||||
| from loops.common import adapted | ||||
| 
 | ||||
| logger = getLogger('ClassifierView') | ||||
| 
 | ||||
| 
 | ||||
| class ClassifierView(ConceptView): | ||||
| 
 | ||||
|  | @ -45,18 +42,12 @@ class ClassifierView(ConceptView): | |||
|         if 'update' in self.request.form: | ||||
|             cta = adapted(self.context) | ||||
|             if cta is not None: | ||||
|                 for idx, r in enumerate(collectResources(self.context)): | ||||
|                     if idx % 1000 == 0: | ||||
|                         logger.info('Committing, resource # %s' % idx) | ||||
|                         transaction.commit() | ||||
|                 for r in collectResources(self.context): | ||||
|                     cta.process(r) | ||||
|             logger.info('Finished processing') | ||||
|             transaction.commit() | ||||
|         return True | ||||
| 
 | ||||
| 
 | ||||
| def collectResources(concept, checkedConcepts=None, result=None): | ||||
|     logger.info('Start collecting resources for %s' % getName(concept)) | ||||
|     if result is None: | ||||
|         result = [] | ||||
|     if checkedConcepts is None: | ||||
|  | @ -68,5 +59,4 @@ def collectResources(concept, checkedConcepts=None, result=None): | |||
|         if c not in checkedConcepts: | ||||
|             checkedConcepts.append(c) | ||||
|             collectResources(c, checkedConcepts, result) | ||||
|     logger.info('Collected %s resources' % len(result)) | ||||
|     return result | ||||
|  | @ -1,11 +1,30 @@ | |||
| # loops.classifier.sample | ||||
| # | ||||
| #  Copyright (c) 2007 Helmut Merz helmutm@cy55.de | ||||
| # | ||||
| #  This program is free software; you can redistribute it and/or modify | ||||
| #  it under the terms of the GNU General Public License as published by | ||||
| #  the Free Software Foundation; either version 2 of the License, or | ||||
| #  (at your option) any later version. | ||||
| # | ||||
| #  This program is distributed in the hope that it will be useful, | ||||
| #  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| #  GNU General Public License for more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License | ||||
| #  along with this program; if not, write to the Free Software | ||||
| #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | ||||
| # | ||||
| 
 | ||||
| """ Sample classifier implementation. | ||||
| """ | ||||
| Sample classifier implementation. | ||||
| 
 | ||||
| $Id$ | ||||
| """ | ||||
| 
 | ||||
| from zope import component | ||||
| from zope.app.catalog.interfaces import ICatalog | ||||
| from zope.cachedescriptors.property import Lazy | ||||
| from zope.catalog.interfaces import ICatalog | ||||
| from zope.component import adapts | ||||
| from zope.traversing.api import getName | ||||
| 
 | ||||