示例#1
0
        else:
            value = self.REQUEST.get('display', None)

        if isinstance(value, list):
            value = value[0]

        return value

    def getGotHereRecords(self, limit=40):
        """ Look at the referers table for how they got here """
        sql_select = self.SQLSelectCountByURL
        urls = [self.absolute_url()]
        for i in range(len(urls)):
            urls[i] = urls[i] + '%'
        return sql_select(limit=limit, urls=urls)

    def prepareExtraDisplays(self):
        self.manage_addDisplay('tiny', 75, 75)
        self.manage_addDisplay('puny', 20, 20)

zpts = (('zpt/view_photo', 'view'), )
addTemplates2Class(PeterbePhoto, zpts, extension='zpt')

dtmls = (
    'dtml/cookieDisplaySizeJS',
    ('dtml/got_here', 'manage_GotHere'),
)
addTemplates2Class(PeterbePhoto, dtmls, extension='dtml')

InitializeClass(PeterbePhoto)
示例#2
0
                get_transaction.abort()
            else:
                # the >2.8 way of doing it
                transaction.get().abort()
            RESPONSE.setStatus(405)
        else:
            body = REQUEST.get('BODY').strip()

            try:
                Utils.ValidConfiguration(body, be_angry=True)
                self.configuration = body
            except Utils.ConfigurationError, m:
                LOG("ZTinyMCE",
                    ERROR,
                    "Invalid configuration: %s" % m,
                    error=sys.exc_info())
            except:
                LOG("ZTinyMCE", ERROR, "", error=sys.exc_info())

            RESPONSE.setStatus(204)
            return RESPONSE


templates = (
    'dtml/manage_Configure',
    'dtml/manage_TestConfiguration',
    'dtml/test_config_content',
)
addTemplates2Class(TinyMCEConfiguration, templates)

InitializeClass(TinyMCEConfiguration)
示例#3
0
    def getBags(self, sortkey="mod_date"):
        """ return all bag objects """
        objects = self._getBagObjects()

        if Utils.same_type(sortkey, "s"):
            sortkey = (sortkey,)

        if sortkey:
            objects = self.sortSequence(objects, (sortkey,))

        return objects


zpts = ({"f": "zpt/wishlist_index", "n": "index_html"},)

addTemplates2Class(Wishlist, zpts, extension="zpt")

dtmls = ("dtml/manage_RefreshWishlist",)
addTemplates2Class(Wishlist, dtmls, extension="dtml")

InitializeClass(Wishlist)

# -----------------------------------------------------------------


class WishBag(Folder.Folder, Persistent):
    """ Souped up Amazon bag item """

    meta_type = WISHLIST_BAG_METATYPE

    icon = "misc_/Peterbecom/wishlist_icon.gif"
示例#4
0
            if len(shortened) + len(desc) > maxlength:
                desc = self.lengthLimit(desc, maxlength-len(title))

            if html:
                return u"<b>%s</b>, %s"%(shortened, desc)
            else:
                return u"%s, %s"%(shortened, desc)


    def get__dict__keys(self):
        """ return the names of the keys we might have """
        return ('issueid', 'action', 'title', 'comment',
                'fromname', 'email', 'display_format',
                'acl_adder', 'is_autosave')

    def get__dict__nicely(self):
        """ same as get__dict__keys() but we wrap it nicely """
        ok = []
        for key in self.get__dict__keys():
            if self.__dict__.get(key, None) is not None:
                ok.append({'key':key,
                           'value':self.__dict__.get(key)})
        return ok


dtmls = ({'f':'dtml/draftissuethread_properties', 'n':'manage_draftthread_properties'},
         )
addTemplates2Class(IssueTrackerDraftIssueThread, dtmls, "dtml")

InitializeClass(IssueTrackerDraftIssueThread)
                if isinstance(option, (tuple, list)):
                    value_, label = option
                else:
                    value_, label = option, option

                if compare_custom_value(value_, value, self.python_type):
                    return label

            # default
            return value
        else:
            return value


zpts = ("zpt/customfield/manage_field", "zpt/customfield/manage_validation", "zpt/customfield/index_html")
addTemplates2Class(CustomField, zpts)

security = ClassSecurityInfo()
security.declareProtected(VMS, "index_html")
security.declareProtected(VMS, "manage_field")
security.declareProtected(VMS, "manage_validation")
security.apply(CustomField)


InitializeClass(CustomField)


# ----------------------------------------------------------------------------
from OFS.SimpleItem import SimpleItem
from OFS.PropertyManager import PropertyManager
示例#6
0
        if isinstance(value, list):
            value = value[0]
            
        return value
    
    def getGotHereRecords(self, limit=40):
        """ Look at the referers table for how they got here """
        sql_select = self.SQLSelectCountByURL
        urls = [self.absolute_url()]
        for i in range(len(urls)):
            urls[i] = urls[i]+'%'
        return sql_select(limit=limit, urls=urls)
    
    
    def prepareExtraDisplays(self):
        self.manage_addDisplay('tiny', 75, 75)
        self.manage_addDisplay('puny', 20, 20)
                
            
        
zpts =(('zpt/view_photo','view'),)
addTemplates2Class(PeterbePhoto, zpts, extension='zpt')

dtmls = ('dtml/cookieDisplaySizeJS',
         ('dtml/got_here', 'manage_GotHere'),
        )
addTemplates2Class(PeterbePhoto, dtmls, extension='dtml')        
    
InitializeClass(PeterbePhoto)

示例#7
0
        self._uploadDTMLDocument(container, filename, dtml_content)
        self._uploadFileGzipped(container,
                                filename_gzip,
                                content,
                                content_type='text/css')

    def _uploadHTMLDTMLDocument(self, container, filename, data):
        tmpl = '''<dtml-call "doCache(%s)">''' % CACHE_HOURS
        content = data.read()
        content = tmpl + content
        self._uploadDTMLDocument(container, filename, content)

    def _uploadDTMLDocument(self, container, filename, content):
        """ create the DTML Document """
        debug("Adding DTMLDocument %r inside %s" %
              (filename, container.absolute_url_path()))
        container.manage_addDTMLDocument(filename, title='', file=content)
        # XXX We might want to upload the optimized version here too

    def _uploadImage(self, container, filename, data):
        """ upload a plain image """
        debug("Adding Image %r inside %s" %
              (filename, container.absolute_url_path()))
        container.manage_addImage(filename, title='', file=data)

templates = (  #'dtml/something',
    'dtml/manage_Update', )
addTemplates2Class(TinyMCE, templates)

InitializeClass(TinyMCE)
示例#8
0
        for each in COMMON_USER_AGENTS:
            tofind, nick = each
            if user_agent.find(tofind) > -1:
                return nick

        return user_agent[:45]

    security.declareProtected(VMS, 'manage_UpdatePlogRank')

    def manage_UpdatePlogRank(self):
        """ use PlogMatrix to calculate every plogrank """
        return UpdatePlogRank(self)


zpts = (('zpt/blogcontainer_index', 'index_html'), )
addTemplates2Class(PeterbeBlogContainer, zpts, extension='zpt')

dtmls = (
    ('dtml/blogcontainer_stats', 'manage_Statistics'),
    'dtml/blogcontainer_calendar',
)
addTemplates2Class(PeterbeBlogContainer, dtmls, extension='dtml')

setattr(PeterbeBlogContainer, 'rss.xml', PeterbeBlogContainer.RSS10)

security = ClassSecurityInfo()
security.declareProtected(VMS, 'manage_Statistics')
security.apply(PeterbeBlogContainer)

InitializeClass(PeterbeBlogContainer)
示例#9
0
        while object.meta_type != mtype:
            object = object.aq_parent
        return object

    def addComment(self, name, email, comment, REQUEST=None):
        """ wrap to parent """
        script = self.getParent().addComment
        return script(name, email, comment, toobject=self,
                      REQUEST=REQUST)

    def getCommentPath(self):
        """ return the difference between the blogitem and
            the comments URL.
        """
        blogitem = self.getParent()
        blogitempath = blogitem.absolute_url()
        path = self.absolute_url().replace(blogitempath,'')
        return path


# Add all templates
zpts = ('zpt/show_inline_comments',
        )
addTemplates2Class(BlogItemComment, zpts, extension='zpt')


InitializeClass(BlogItemComment)


#-----------------------------------------------------------------
示例#10
0



    security.declareProtected(VMS, 'manage_UpdatePlogRank')
    def manage_UpdatePlogRank(self):
        """ use PlogMatrix to calculate every plogrank """
        return UpdatePlogRank(self)






zpts = (('zpt/blogcontainer_index', 'index_html'),)
addTemplates2Class(PeterbeBlogContainer, zpts, extension='zpt')

dtmls = (('dtml/blogcontainer_stats','manage_Statistics'),
         'dtml/blogcontainer_calendar',
         )
addTemplates2Class(PeterbeBlogContainer, dtmls, extension='dtml')

setattr(PeterbeBlogContainer, 'rss.xml', PeterbeBlogContainer.RSS10)

security = ClassSecurityInfo()
security.declareProtected(VMS, 'manage_Statistics')
security.apply(PeterbeBlogContainer)



示例#11
0
	else:
	    m = "Pin code invalid"
	    raise "InvalidPincode", m
	
    def discontinue(self, emailreminderid):
	""" Delete the Email Reminder object """
	self.manage_delObjects([emailreminderid])
	return self.discontinued(self, self.REQUEST)
    
#-----------------------------------------------------------------    
zpts = ('zpt/addEmailreminder',
        ('zpt/changelogdescriber_index_html','index_html'),
	('zpt/changelogdescriber_manage_index_html','manage_index_html'),
	('zpt/changelogdescriber_discontinued','discontinued'),
       )
addTemplates2Class(ChangeLogDescriber, zpts, extension='zpt')

InitializeClass(ChangeLogDescriber)
    
#-----------------------------------------------------------------

manage_addEmailReminderForm = DTMLFile('dtml/addemailreminderform',
                                       globals())
def manage_addEmailReminder(dispatcher, *args, **kw):
    """ not in use """
    raise "NotImplemented", "EmailReminders are created via script"

#-----------------------------------------------------------------

class EmailReminder(SimpleItem.SimpleItem):
    """ Email Reminder object """
示例#12
0
        """ return the blog item object from whereever
        we are. """
        mtype = BLOGITEM_METATYPE
        object = self
        while object.meta_type != mtype:
            object = object.aq_parent
        return object

    def addComment(self, name, email, comment, REQUEST=None):
        """ wrap to parent """
        script = self.getParent().addComment
        return script(name, email, comment, toobject=self, REQUEST=REQUST)

    def getCommentPath(self):
        """ return the difference between the blogitem and
            the comments URL.
        """
        blogitem = self.getParent()
        blogitempath = blogitem.absolute_url()
        path = self.absolute_url().replace(blogitempath, '')
        return path


# Add all templates
zpts = ('zpt/show_inline_comments', )
addTemplates2Class(BlogItemComment, zpts, extension='zpt')

InitializeClass(BlogItemComment)

#-----------------------------------------------------------------
示例#13
0
                                        SubmitError=SubmitError)
        
        
    def _createNewPage(self, title):
        """create the new Page instance and return it"""
        
        oid = _title_to_id(title)
        page = Page(oid, title, u"")
        self._setObject(oid, page)
        return getattr(self, oid)
        
    
zpts = ('zpt/Pages/index_html',
        'zpt/Pages/addNewPage_template',
)    
addTemplates2Class(PageFolder, zpts, extension='zpt')

InitializeClass(PageFolder)

#----------------------------------------------------------------------------


#----------------------------------------------------------------------------


class Page(Folder, Persistent):
    """A page is like a wiki page but without all the wiki aspects"""

    meta_type = PAGE_METATYPE
    
    _properties=({'id':'title',         'type': 'ustring', 'mode':'w'},
示例#14
0
                except KeyError:
                    warnings.warn("ZCatalog (%s) out of date. Press Update Everything" %\
                                  catalog.absolute_url_path())
                    continue
                if not thread.getActualTimeHours():
                    continue

                if not _has_threaddate_index:
                    # we have to manually filter it
                    if thread.getThreadDate() < start_date:
                        continue
                    if issue.getThreadDate() > end_date:
                        continue

                total += thread.getActualTimeHours()
                #threads.append(thread)

        #count_threads = len(threads)
        return total


zpts = (
        'zpt/show_summary',
        )



addTemplates2Class(SummaryBase, zpts, extension='zpt')

InitializeClass(SummaryBase)
示例#15
0
            # put some of the description ontop
            if len(shortened) + len(desc) > maxlength:
                desc = self.lengthLimit(desc, maxlength - len(title))

            if html:
                return u"<b>%s</b>, %s" % (shortened, desc)
            else:
                return u"%s, %s" % (shortened, desc)

    def get__dict__keys(self):
        """ return the names of the keys we might have """
        return ('issueid', 'action', 'title', 'comment', 'fromname', 'email',
                'display_format', 'acl_adder', 'is_autosave')

    def get__dict__nicely(self):
        """ same as get__dict__keys() but we wrap it nicely """
        ok = []
        for key in self.get__dict__keys():
            if self.__dict__.get(key, None) is not None:
                ok.append({'key': key, 'value': self.__dict__.get(key)})
        return ok


dtmls = ({
    'f': 'dtml/draftissuethread_properties',
    'n': 'manage_draftthread_properties'
}, )
addTemplates2Class(IssueTrackerDraftIssueThread, dtmls, "dtml")

InitializeClass(IssueTrackerDraftIssueThread)
示例#16
0
    def getBags(self, sortkey='mod_date'):
        """ return all bag objects """
        objects = self._getBagObjects()

        if Utils.same_type(sortkey, 's'):
            sortkey = (sortkey, )

        if sortkey:
            objects = self.sortSequence(objects, (sortkey, ))

        return objects


zpts = ({'f': 'zpt/wishlist_index', 'n': 'index_html'}, )

addTemplates2Class(Wishlist, zpts, extension='zpt')

dtmls = ('dtml/manage_RefreshWishlist', )
addTemplates2Class(Wishlist, dtmls, extension='dtml')

InitializeClass(Wishlist)

#-----------------------------------------------------------------


class WishBag(Folder.Folder, Persistent):
    """ Souped up Amazon bag item """

    meta_type = WISHLIST_BAG_METATYPE

    icon = 'misc_/Peterbecom/wishlist_icon.gif'
示例#17
0
        if not REQUEST.get('BODY'):
            if transaction is None:
                get_transaction.abort()
            else:
                # the >2.8 way of doing it
                transaction.get().abort()
            RESPONSE.setStatus(405)
        else:
            body = REQUEST.get('BODY').strip()
            
            try:
                Utils.ValidConfiguration(body, be_angry=True)
                self.configuration = body
            except Utils.ConfigurationError, m:
                LOG("ZTinyMCE", ERROR, "Invalid configuration: %s"%m, error=sys.exc_info())
            except:
                LOG("ZTinyMCE", ERROR, "", error=sys.exc_info())
                
            RESPONSE.setStatus(204)
            return RESPONSE
        
    
        
        
templates = ('dtml/manage_Configure',
             'dtml/manage_TestConfiguration',
             'dtml/test_config_content',
            )
addTemplates2Class(TinyMCEConfiguration, templates)
                
InitializeClass(TinyMCEConfiguration)
示例#18
0
        try:
            u = self.DestinationURL()
        except AttributeError:
            u = REQUEST['URL1']

        if submit == " Add and Edit ":
            u = "%s/%s" % (u, quote(id))
        REQUEST.RESPONSE.redirect(u+'/manage_main')
    return ''



#-----------------------------------------------------------------------------


class PeterbePageTemplate(ZopePageTemplate):
    """ Page Templates just for Peterbecom """
    meta_type = PETERBEPAGETEMPLATE_METATYPE
    

    manage_options = ZopePageTemplate.manage_options[:2] + \
        ({'label':'Misc', 'action':'PageTemplateMisc'},) + \
        ZopePageTemplate.manage_options[2:]
        
    _default_content_fn = os.path.join(package_home(globals()),
                                       'zpt','default.zpt')

dtmls = ('dtml/PageTemplateMisc',)
addTemplates2Class(PeterbePageTemplate, dtmls, extension='dtml')
示例#19
0
        """ init """
        assert isinstance(geocode, tuple), "geocode not a tuple"
        assert isinstance(geocode[0], float), "geocode x not a float"
        assert isinstance(geocode[1], float), "geocode y not a float"

        self.geocode = geocode
        self.place = place

        Photo.__init__(self,
                       id,
                       title,
                       file,
                       content_type='',
                       precondition='',
                       store=store,
                       engine=engine,
                       quality=quality,
                       pregen=0,
                       timeout=0,
                       description=description,
                       pub_date=pub_date)

    def getGeocode(self):
        return self.geocode


zpts = ()
addTemplates2Class(PeterbeOutandaboutItem, zpts, extension='zpt')

InitializeClass(PeterbeOutandaboutItem)
示例#20
0
                                        SubmitError=SubmitError)

    def _createNewPage(self, title):
        """create the new Page instance and return it"""

        oid = _title_to_id(title)
        page = Page(oid, title, u"")
        self._setObject(oid, page)
        return getattr(self, oid)


zpts = (
    'zpt/Pages/index_html',
    'zpt/Pages/addNewPage_template',
)
addTemplates2Class(PageFolder, zpts, extension='zpt')

InitializeClass(PageFolder)

#----------------------------------------------------------------------------

#----------------------------------------------------------------------------


class Page(Folder, Persistent):
    """A page is like a wiki page but without all the wiki aspects"""

    meta_type = PAGE_METATYPE

    _properties = (
        {
示例#21
0
        
    def __init__(self, id, title, file, geocode, content_type='', precondition='',
                 store='ExtImage', engine='ImageMagick', quality=100,
                 pregen=False, timeout=0, description='',
                 pub_date=None, 
                 place=u'',
                 ):
        """ init """
        assert isinstance(geocode, tuple), "geocode not a tuple"
        assert isinstance(geocode[0], float), "geocode x not a float"
        assert isinstance(geocode[1], float), "geocode y not a float"
        
        self.geocode = geocode
        self.place = place
        
        Photo.__init__(self, id, title, file, content_type='', 
                       precondition='', store=store, engine=engine, 
                       quality=quality, pregen=0, timeout=0,
                       description=description,
                       pub_date=pub_date)

    def getGeocode(self):
        return self.geocode
            
        
zpts =()
addTemplates2Class(PeterbeOutandaboutItem, zpts, extension='zpt')

    
InitializeClass(PeterbeOutandaboutItem)
        
示例#22
0
	cmd += IN + ' ' + OUT
	
	os.system(cmd)
	
	# Upload new thumbnail
	thumbimage = open(OUT, 'rb')
	self.manage_addImage(thumbid, file=thumbimage.read(), 
	                     title=self.getTitle())
	# Clean up
	os.remove(IN)
	os.remove(OUT)
	
	
	return str(self.ZopeTime())
    
    security.declareProtected(VMS, 'manage_moderate')
    def manage_moderate(self):
	""" change moderation to true """
	self.moderated = 1
	
InitializeClass(MMSMessage)

#-----------------------------------------------------------------

# Add all templates
zpts = (('zpt/mmsmessage_index_html','index_html'),)
addTemplates2Class(MMSMessage, zpts, extension='zpt')

#-----------------------------------------------------------------

示例#23
0
            for brain in catalog(**search):
                try:
                    thread = brain.getObject()
                except KeyError:
                    warnings.warn("ZCatalog (%s) out of date. Press Update Everything" %\
                                  catalog.absolute_url_path())
                    continue
                if not thread.getActualTimeHours():
                    continue

                if not _has_threaddate_index:
                    # we have to manually filter it
                    if thread.getThreadDate() < start_date:
                        continue
                    if issue.getThreadDate() > end_date:
                        continue

                total += thread.getActualTimeHours()
                #threads.append(thread)

        #count_threads = len(threads)
        return total


zpts = ('zpt/show_summary', )

addTemplates2Class(SummaryBase, zpts, extension='zpt')

InitializeClass(SummaryBase)
示例#24
0
                oid = str(time()+c) + ext
                
                
        # NB! This is a hack until I can figure
        if not geocode_x and not geocode_y and not location:
            logger.warn("Randomesque geocode in action!")
            from random import choice, random
            default_x = 51.5087157485
            default_y = -0.128424167633
            geocode_x = default_x + choice([-1,1]) * random()*0.3
            geocode_y = default_y + choice([-1,1]) * random()*0.3
                
        photo = script(id=oid, title=title, file=file, 
                       geocode_x=geocode_x, geocode_y=geocode_y,
                       location=location, country=country)
                       

        
        return '%s/view' % photo.absolute_url()

    

        
zpts = ('zpt/outandaboutcontainer/map',)
addTemplates2Class(PeterbeOutandaboutContainer, zpts, extension='zpt')
        
        
InitializeClass(PeterbeOutandaboutContainer)
        
from GoogleKey import GOOGLEMAPS_API_KEY
setattr(PeterbeOutandaboutContainer, 'GOOGLEMAPS_API_KEY', GOOGLEMAPS_API_KEY)